From 1210afd6bcef4b0705235923ff2f5dd48d328b3b Mon Sep 17 00:00:00 2001 From: JucaBlues Date: Sat, 12 Jul 2008 12:28:57 +0000 Subject: [PATCH] now one can visually adjust glyph kerning. (still doesn save that info in the file, though) --- src/ui/dialog/svg-fonts-dialog.cpp | 28 ++++++++++++++++++++++++++-- src/ui/dialog/svg-fonts-dialog.h | 3 +++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index d28085367..7df7e3b89 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -68,11 +68,33 @@ void GlyphComboBox::update(SPFont* spfont){ } } +void SvgFontsDialog::on_kerning_changed(){ + //set kerning value = spin.value() + this->kerning_pair->k = kerning_spin.get_value(); + kerning_preview.redraw(); + _font_da.redraw(); +} + void SvgFontsDialog::on_glyphs_changed(){ std::string str1(first_glyph.get_active_text()); std::string str2(second_glyph.get_active_text()); kerning_preview.set_text((gchar*) (str1+str2).c_str()); kerning_preview.redraw(); + + + //look for this kerning pair on the currently selected font + this->kerning_pair = NULL; + for(SPObject* node = this->get_selected_spfont()->children; node; node=node->next){ + if (SP_IS_HKERN(node) && ((SPGlyphKerning*)node)->u1->contains((gchar) first_glyph.get_active_text().c_str()[0]) + && ((SPGlyphKerning*)node)->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){ + this->kerning_pair = (SPGlyphKerning*)node; + continue; + } + } + +//TODO: + //if not found, + //create new kern node } /* Add all fonts in the document to the combobox. */ @@ -147,13 +169,15 @@ SvgFontsDialog::SvgFontsDialog() Gtk::HBox* kerning_selector = Gtk::manage(new Gtk::HBox()); kerning_selector->add(first_glyph); kerning_selector->add(second_glyph); + kerning_spin.set_range(0,1000); + kerning_spin.set_increments(10,20); first_glyph.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_glyphs_changed)); second_glyph.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_glyphs_changed)); + kerning_spin.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_kerning_changed)); - Gtk::SpinButton* kerning_spin = Gtk::manage(new Gtk::SpinButton()); kernvbox->add(*kerning_selector); kernvbox->add((Gtk::Widget&) kerning_preview); - kernvbox->add(*kerning_spin); + kernvbox->add(kerning_spin); //Text Preview: _preview_entry.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_preview_text_changed)); diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index 09378130c..837fc0478 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -65,6 +65,7 @@ public: void on_font_selection_changed(); void on_preview_text_changed(); void on_glyphs_changed(); + void on_kerning_changed(); private: class Columns : public Gtk::TreeModel::ColumnRecord { @@ -87,6 +88,8 @@ private: Gtk::Entry _preview_entry; SvgFontDrawingArea _font_da, kerning_preview; GlyphComboBox first_glyph, second_glyph; + SPGlyphKerning* kerning_pair; + Gtk::SpinButton kerning_spin; class EntryWidget : public Gtk::HBox { -- 2.30.2