svg-fonts-dialog.cpp revision cbffe310300d15d435ad99b787ecef187975cdf3
/** @file
* @brief SVG Fonts dialog - implementation
*/
/* Authors:
* Felipe C. da S. Sanches <felipe.sanches@gmail.com>
*
* Copyright (C) 2008 Authors
* Released under GNU GPLv2 (or later). Read the file 'COPYING' for more information.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef ENABLE_SVG_FONTS
#include "document-private.h"
#include <gtkmm/notebook.h>
#include <message-stack.h>
#include "selection.h"
#include <string.h>
#include "svg-fonts-dialog.h"
this->text = "";
}
}
redraw();
}
void SvgFontDrawingArea::set_size(int x, int y){
this->x = x;
this->y = y;
}
void SvgFontDrawingArea::redraw(){
}
if (this->svgfont){
cr->set_font_face( Cairo::RefPtr<Cairo::FontFace>(new Cairo::FontFace(this->svgfont->get_font_face(), false /* does not have reference */)) );
}
return TRUE;
}
namespace Inkscape {
namespace UI {
namespace Dialog {
/*
Gtk::HBox* SvgFontsDialog::AttrEntry(gchar* lbl, const SPAttributeEnum attr){
Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox());
hbox->add(* Gtk::manage(new Gtk::Label(lbl)) );
Gtk::Entry* entry = Gtk::manage(new Gtk::Entry());
hbox->add(* entry );
hbox->show_all();
entry->signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_attr_changed));
return hbox;
}
*/
this->dialog = d;
this->show_all();
}
if (!t) return;
}
switch(this->attr){
case SP_PROP_FONT_FAMILY:
if (SP_IS_FONTFACE(node)){
o = node;
continue;
}
break;
default:
o = NULL;
}
}
if(name && o) {
_("Set SVG Font attribute"));
}
}
return hbox;
}
/*
Gtk::HBox* SvgFontsDialog::AttrSpin(gchar* lbl){
Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox());
hbox->add(* Gtk::manage(new Gtk::Label(lbl)) );
hbox->add(* Gtk::manage(new Gtk::SpinBox()) );
hbox->show_all();
return hbox;
}*/
/*** SvgFontsDialog ***/
}
if (!spfont) return
//TODO: figure out why do we need to append_text("") before clearing items properly...
this->clear_items();
if (SP_IS_GLYPH(node)){
}
}
}
void SvgFontsDialog::on_kerning_value_changed(){
if (!this->kerning_pair) return;
//TODO: I am unsure whether this is the correct way of calling sp_document_maybe_done
undokey += ":";
//slider values increase from right to left so that they match the kerning pair preview
this->kerning_pair->repr->setAttribute("k", Glib::Ascii::dtostr(get_selected_spfont()->horiz_adv_x - kerning_slider.get_value()).c_str());
sp_document_maybe_done(document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, _("Adjust kerning value"));
//populate_kerning_pairs_box();
}
{
}
}
{
}
}
{
}
}
{
}
{
}
{
}
void SvgFontsDialog::update_sensitiveness(){
if (get_selected_spfont()){
global_vbox.set_sensitive(true);
glyphs_vbox.set_sensitive(true);
kerning_vbox.set_sensitive(true);
} else {
global_vbox.set_sensitive(false);
glyphs_vbox.set_sensitive(false);
kerning_vbox.set_sensitive(false);
}
}
/* Add all fonts in the document to the combobox. */
void SvgFontsDialog::update_fonts()
{
}
}
void SvgFontsDialog::on_preview_text_changed(){
}
if (!kern) {
return;
}
this->kerning_pair = kern;
//slider values increase from right to left so that they match the kerning pair preview
}
void SvgFontsDialog::update_global_settings_tab(){
if (!font) return;
if (SP_IS_FONTFACE(obj)){
}
}
}
void SvgFontsDialog::on_font_selection_changed(){
if (!spfont) return;
kerning_slider.set_draw_value(false);
}
void SvgFontsDialog::on_setwidth_changed(){
if (spfont){
//TODO: tell cairo that the glyphs cache has to be invalidated
// The current solution is to recreate the whole cairo svgfont.
// This is not a good solution to the issue because big fonts will result in poor performance.
}
}
{
if(i)
return (*i)[_KerningPairsListColumns.spnode];
return NULL;
}
{
if(i)
return NULL;
}
{
if(i)
return NULL;
}
{
if(i)
return (*i)[_GlyphsListColumns.glyph_node];
return NULL;
}
/* global_vbox->add(*AttrCombo((gchar*) _("Style:"), SP_PROP_FONT_STYLE));
global_vbox->add(*AttrCombo((gchar*) _("Variant:"), SP_PROP_FONT_VARIANT));
global_vbox->add(*AttrCombo((gchar*) _("Weight:"), SP_PROP_FONT_WEIGHT));
*/
//Set Width (horiz_adv_x):
return &global_vbox;
}
void
{
if (!_GlyphsListStore) return;
if (SP_IS_GLYPH(node)){
}
}
}
void
{
if (!_KerningPairsListStore) return;
if (SP_IS_HKERN(node)){
row[_KerningPairsListColumns.first_glyph] = ((SPGlyphKerning*) node)->u1->attribute_string().c_str();
row[_KerningPairsListColumns.second_glyph] = ((SPGlyphKerning*) node)->u2->attribute_string().c_str();
}
}
}
{
// create a new glyph
// Append the new glyph node to the current font
// get corresponding object
g_assert(SP_IS_GLYPH(g));
return g;
}
void SvgFontsDialog::update_glyphs(){
if (!font) return;
get_selected_svgfont()->refresh();
}
void SvgFontsDialog::add_glyph(){
}
if (!desktop) {
g_warning("SvgFontsDialog: No active desktop");
return;
}
char *msg = _("Select a <b>path</b> to define the curves of a glyph");
return;
}
if (!node) return;//TODO: should this be an assert?
char *msg = _("The selected object does not have a <b>path</b> description.");
return;
} //TODO: //Is there a better way to tell it to to the user?
//This matrix flips the glyph vertically
Geom::Matrix m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(0));
pathv*=m;
//then we offset it
if (!glyph){
char *msg = _("No glyph selected in the SVGFonts dialog.");
return;
}
}
if (!desktop) {
g_warning("SvgFontsDialog: No active desktop");
return;
}
char *msg = _("Select a <b>path</b> to define the curves of a glyph");
return;
}
if (!node) return;//TODO: should this be an assert?
char *msg = _("The selected object does not have a <b>path</b> description.");
return;
} //TODO: //Is there a better way to tell it to to the user?
//This matrix flips the glyph vertically
Geom::Matrix m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(0));
pathv*=m;
//then we offset it
// pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(get_selected_spfont()->horiz_adv_x));
if (SP_IS_MISSING_GLYPH(obj)){
}
}
}
if (!desktop) {
g_warning("SvgFontsDialog: No active desktop");
return;
}
if (SP_IS_MISSING_GLYPH(obj)){
}
}
}
if (!i) return;
}
if (!i) return;
}
void SvgFontsDialog::remove_selected_font(){
update_fonts();
}
void SvgFontsDialog::remove_selected_glyph(){
if(!_GlyphsList.get_selection()) return;
if(!i) return;
}
if(!_KerningPairsList.get_selection()) return;
if(!i) return;
}
_GlyphsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &SvgFontsDialog::glyphs_list_button_release));
create_glyphs_popup_menu(_GlyphsList, sigc::mem_fun(*this, &SvgFontsDialog::remove_selected_glyph));
missing_glyph_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::missing_glyph_description_from_selected_path));
missing_glyph_reset_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::reset_missing_glyph_description));
_GlyphsListScroller.set_size_request(-1, 290);//It seems that is does not work. Why? I want a box with larger height
glyph_from_path_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::set_glyph_description_from_selected_path));
dynamic_cast<Gtk::CellRendererText*>( _GlyphsList.get_column_cell_renderer(0))->signal_edited().connect(
dynamic_cast<Gtk::CellRendererText*>( _GlyphsList.get_column_cell_renderer(1))->signal_edited().connect(
return &glyphs_vbox;
}
void SvgFontsDialog::add_kerning_pair(){
//look for this kerning pair on the currently selected font
this->kerning_pair = NULL;
//TODO: It is not really correct to get only the first byte of each string.
//TODO: We should also support vertical kerning
if (SP_IS_HKERN(node) && ((SPGlyphKerning*)node)->u1->contains((gchar) first_glyph.get_active_text().c_str()[0])
continue;
}
}
if (this->kerning_pair) return; //We already have this kerning pair
// create a new hkern node
// Append the new hkern node to the current font
// get corresponding object
}
_KerningPairsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &SvgFontsDialog::kerning_pairs_list_button_release));
create_kerning_pairs_popup_menu(_KerningPairsList, sigc::mem_fun(*this, &SvgFontsDialog::remove_selected_kerning_pair));
//Kerning Setup:
add_kernpair_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::add_kerning_pair));
_KerningPairsList.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_kerning_pair_selection_changed));
kerning_slider.signal_value_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_kerning_value_changed));
// _KerningPairsList.append_column_numeric_editable(_("Kerning Value"), _KerningPairsListColumns.kerning_value, "%f");
return &kerning_vbox;
}
{
// create a new font
//By default, set the horizontal advance to 1024 units
// Append the new font node to defs
//create a missing glyph
//create a missing glyph
// get corresponding object
g_assert(SP_IS_FONT(f));
return f;
}
if (!font) return;
if (SP_IS_FONTFACE(obj)){
}
}
}
void SvgFontsDialog::add_font(){
if (SP_IS_FONTFACE(obj)){
}
}
update_fonts();
// select_font(font);
}
{
//List of SVGFonts declared in a document:
_FontsList.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_font_selection_changed));
this->update_fonts();
tabs->set_scrollable();
//Text Preview:
_preview_entry.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_preview_text_changed));
_FontsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &SvgFontsDialog::fonts_list_button_release));
_getContents()->show_all();
}
SvgFontsDialog::~SvgFontsDialog(){}
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
#endif //#ifdef ENABLE_SVG_FONTS
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :