diff options
| author | John Smith <john.smith7545@yahoo.com> | 2012-08-16 08:20:16 +0000 |
|---|---|---|
| committer | John Smith <john.smith7545@yahoo.com> | 2012-08-16 08:20:16 +0000 |
| commit | b61db3c2d4c3d2fb497d62b4ddb3364031f5fdec (patch) | |
| tree | 5fcd18179bd2d75c411027dcc19f4957b1b1ce2d /src | |
| parent | code style (use NULL for pointers instead of 0) (diff) | |
| download | inkscape-b61db3c2d4c3d2fb497d62b4ddb3364031f5fdec.tar.gz inkscape-b61db3c2d4c3d2fb497d62b4ddb3364031f5fdec.zip | |
Fix for 168164 : Font sizes in points option
(bzr r11608)
Diffstat (limited to 'src')
| -rw-r--r-- | src/desktop-style.cpp | 2 | ||||
| -rw-r--r-- | src/ink-comboboxentry-action.cpp | 11 | ||||
| -rw-r--r-- | src/ink-comboboxentry-action.h | 1 | ||||
| -rw-r--r-- | src/sp-text.cpp | 3 | ||||
| -rw-r--r-- | src/style.cpp | 61 | ||||
| -rw-r--r-- | src/style.h | 5 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.cpp | 7 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.h | 1 | ||||
| -rw-r--r-- | src/ui/dialog/text-edit.cpp | 18 | ||||
| -rw-r--r-- | src/widgets/font-selector.cpp | 70 | ||||
| -rw-r--r-- | src/widgets/text-toolbar.cpp | 58 |
11 files changed, 192 insertions, 45 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index b29799bb3..74e15e3e2 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1096,6 +1096,8 @@ objects_query_fontstyle (GSList *objects, SPStyle *style_res) style_res->font_stretch.value = style_res->font_stretch.computed = style->font_stretch.computed; style_res->font_variant.value = style_res->font_variant.computed = style->font_variant.computed; style_res->text_align.value = style_res->text_align.computed = style->text_align.computed; + style_res->font_size.value = style->font_size.value; + style_res->font_size.unit = style->font_size.unit; } if (texts == 0 || !set) diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index ad9f775c4..869296f87 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -573,6 +573,17 @@ void ink_comboboxentry_action_popup_disable( Ink_ComboBoxEntry_Action* action ) action->entry_completion = 0; } } +void ink_comboboxentry_action_set_tooltip( Ink_ComboBoxEntry_Action* action, const gchar* tooltip ) { + + // Widget may not have been created.... + if( action->entry ) { + gtk_widget_set_tooltip_text ( GTK_WIDGET(action->entry), tooltip); + } + if( action->combobox ) { + gtk_widget_set_tooltip_text ( GTK_WIDGET(action->combobox), tooltip); + } + +} void ink_comboboxentry_action_set_warning( Ink_ComboBoxEntry_Action* action, const gchar* warning ) { diff --git a/src/ink-comboboxentry-action.h b/src/ink-comboboxentry-action.h index 9d9287e17..95306bcaa 100644 --- a/src/ink-comboboxentry-action.h +++ b/src/ink-comboboxentry-action.h @@ -89,6 +89,7 @@ void ink_comboboxentry_action_popup_enable( Ink_ComboBoxEntry_Action* actio void ink_comboboxentry_action_popup_disable( Ink_ComboBoxEntry_Action* action ); void ink_comboboxentry_action_set_warning( Ink_ComboBoxEntry_Action* action, const gchar* warning ); +void ink_comboboxentry_action_set_tooltip( Ink_ComboBoxEntry_Action* action, const gchar* tooltip ); void ink_comboboxentry_action_set_altx_name( Ink_ComboBoxEntry_Action* action, const gchar* altx_name ); diff --git a/src/sp-text.cpp b/src/sp-text.cpp index f930bb636..0b60c1960 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -38,6 +38,7 @@ #include "display/drawing-text.h" #include "attributes.h" #include "document.h" +#include "preferences.h" #include "desktop-handles.h" #include "sp-namedview.h" #include "style.h" @@ -48,12 +49,14 @@ #include "mod360.h" #include "sp-title.h" #include "sp-desc.h" +#include "sp-text.h" #include "sp-textpath.h" #include "sp-tref.h" #include "sp-tspan.h" #include "text-editing.h" +#include "unit-constants.h" /*##################################################### # SPTEXT diff --git a/src/style.cpp b/src/style.cpp index a67852e11..5c343cdf1 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -61,6 +61,8 @@ using std::vector; #define BMAX 8192 +#define SP_CSS_FONT_SIZE_DEFAULT 12.0; + class SPStyleEnum; /*######################### @@ -2442,6 +2444,55 @@ sp_style_set_to_uri_string (SPStyle *style, bool isfill, const gchar *uri) sp_style_set_ipaint_to_uri_string (style, isfill? &style->fill : &style->stroke, uri); } +gchar const * +sp_style_get_css_unit_string(int unit) +{ + // specify px by default, see inkscape bug 1221626, mozilla bug 234789 + + switch (unit) { + + case SP_CSS_UNIT_NONE: return "px"; + case SP_CSS_UNIT_PX: return "px"; + case SP_CSS_UNIT_PT: return "pt"; + case SP_CSS_UNIT_PC: return "pc"; + case SP_CSS_UNIT_MM: return "mm"; + case SP_CSS_UNIT_CM: return "cm"; + case SP_CSS_UNIT_IN: return "in"; + case SP_CSS_UNIT_EM: return "em"; + case SP_CSS_UNIT_EX: return "ex"; + case SP_CSS_UNIT_PERCENT: return "%"; + default: return "px"; + } + return "px"; +} + +/* + * Convert a size in pixels into another CSS unit size + */ +double +sp_style_get_css_font_size_units(double size, int unit) +{ + double unit_size = size; + switch (unit) { + + case SP_CSS_UNIT_NONE: unit_size = size; break; + case SP_CSS_UNIT_PX: unit_size = size; break; + case SP_CSS_UNIT_PT: unit_size = size * PT_PER_PX; break; + case SP_CSS_UNIT_PC: unit_size = size * (PT_PER_PX / PT_PER_PC); break; + case SP_CSS_UNIT_MM: unit_size = size * MM_PER_PX; break; + case SP_CSS_UNIT_CM: unit_size = size * CM_PER_PX; break; + case SP_CSS_UNIT_IN: unit_size = size * IN_PER_PX; break; + case SP_CSS_UNIT_EM: unit_size = size / SP_CSS_FONT_SIZE_DEFAULT; break; + case SP_CSS_UNIT_EX: unit_size = size * 2.0 / SP_CSS_FONT_SIZE_DEFAULT ; break; + case SP_CSS_UNIT_PERCENT: unit_size = size * 100.0 / SP_CSS_FONT_SIZE_DEFAULT; break; + + default: + g_warning("sp_style_get_css_font_size_units conversion to %d not implemented.", unit); + break; + } + + return unit_size; +} /** * */ @@ -3300,6 +3351,7 @@ sp_style_read_ilength(SPILength *val, gchar const *str) * X server or whatever). E.g. don't fill in computed here, do * it at the same time as percentage units are done. */ + val->value = value; if (!*e) { /* Userspace */ val->unit = SP_CSS_UNIT_NONE; @@ -3327,11 +3379,11 @@ sp_style_read_ilength(SPILength *val, gchar const *str) } else if (!strcmp(e, "em")) { /* EM square */ val->unit = SP_CSS_UNIT_EM; - val->value = value; + val->computed = value * SP_CSS_FONT_SIZE_DEFAULT; } else if (!strcmp(e, "ex")) { /* ex square */ val->unit = SP_CSS_UNIT_EX; - val->value = value; + val->computed = value * 0.5 * SP_CSS_FONT_SIZE_DEFAULT; } else if (!strcmp(e, "%")) { /* Percentage */ val->unit = SP_CSS_UNIT_PERCENT; @@ -4166,7 +4218,9 @@ sp_style_write_ifontsize(gchar *p, gint const len, gchar const *key, } } else if (val->type == SP_FONT_SIZE_LENGTH) { Inkscape::CSSOStringStream os; - os << key << ":" << val->computed << "px;"; // must specify px, see inkscape bug 1221626, mozilla bug 234789 + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); + os << key << ":" << sp_style_get_css_font_size_units(val->computed, unit) << sp_style_get_css_unit_string(unit) << ";"; return g_strlcpy(p, os.str().c_str(), len); } else if (val->type == SP_FONT_SIZE_PERCENTAGE) { Inkscape::CSSOStringStream os; @@ -4290,7 +4344,6 @@ void SPIPaint::clear() } } - /** * Clear filter object, and disconnect style from paintserver (if present). */ diff --git a/src/style.h b/src/style.h index bdea441a6..de32166fb 100644 --- a/src/style.h +++ b/src/style.h @@ -120,7 +120,7 @@ struct SPIString { gchar *value; }; -enum { +enum SPCSSUnit { SP_CSS_UNIT_NONE, SP_CSS_UNIT_PX, SP_CSS_UNIT_PT, @@ -441,6 +441,9 @@ gchar *sp_style_write_difference(SPStyle const *from, SPStyle const *to); void sp_style_set_to_uri_string (SPStyle *style, bool isfill, const gchar *uri); +gchar const *sp_style_get_css_unit_string(int unit); +double sp_style_get_css_font_size_units(double size, int unit); + /* SPTextStyle */ enum SPCSSFontSize { diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index aab8ccc04..0e4d7fd56 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -313,6 +313,7 @@ void InkscapePreferences::initPageTools() //Selector this->AddPage(_page_selector, _("Selector"), iter_tools, PREFS_PAGE_TOOLS_SELECTOR); + AddSelcueCheckbox(_page_selector, "/tools/select", false); _page_selector.add_group_header( _("When transforming, show")); _t_sel_trans_obj.init ( _("Objects"), "/tools/select/show", "content", true, 0); @@ -441,6 +442,12 @@ void InkscapePreferences::initPageTools() _page_text.add_line( false, "", _font_dialog, "", _("Show font substitution warning dialog when requested fonts are not available on the system")); } + Glib::ustring sizeLabels[] = {_("Pixel"), _("Point"), _("Pica"), _("Millimeter"), _("Centimeter"), _("Inch"), _("Em square")/*, _("Ex square"), _("Percent")*/}; + int sizeValues[] = {SP_CSS_UNIT_PX, SP_CSS_UNIT_PT, SP_CSS_UNIT_PC, SP_CSS_UNIT_MM, SP_CSS_UNIT_CM, SP_CSS_UNIT_IN, SP_CSS_UNIT_EM/*, SP_CSS_UNIT_EX, SP_CSS_UNIT_PERCENT*/}; + + _font_unit_type.init( "/options/font/unitType", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), SP_CSS_UNIT_PT ); + _page_text.add_line( false, _("Text size unit type:"), _font_unit_type, "", + _("Set the type of unit used in the text toolbar and text dialogs"), false); this->AddNewObjectsStyle(_page_text, "/tools/text"); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index d100f74f7..6d13b9d20 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -286,6 +286,7 @@ protected: UI::Widget::PrefSlider _snap_delay; UI::Widget::PrefSlider _snap_weight; UI::Widget::PrefCheckButton _font_dialog; + UI::Widget::PrefCombo _font_unit_type; UI::Widget::PrefCheckButton _misc_comment; UI::Widget::PrefCheckButton _misc_default_metadata; diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 791b49af9..5a983fc1a 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -316,7 +316,10 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ ) font_instance *font = font_factory::Default()->FaceFromStyle(query); if (font) { - sp_font_selector_set_font (fsel, font, query->font_size.computed); + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); + sp_font_selector_set_font (fsel, font, sp_style_get_css_font_size_units(query->font_size.computed, unit) ); setPreviewText(font, phrase); font->Unref(); font=NULL; @@ -362,13 +365,16 @@ void TextEdit::setPreviewText (font_instance *font, Glib::ustring phrase) } char *desc = pango_font_description_to_string(font->descr); - double size = sp_font_selector_get_size(fsel); + double unit_size = sp_font_selector_get_size(fsel); + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); + double px_size = unit_size * (unit_size / sp_style_get_css_font_size_units(unit_size, unit)); gchar *const phrase_escaped = g_markup_escape_text(phrase.c_str(), -1); gchar *markup = g_strdup_printf("<span font=\"%s\" size=\"%d\">%s</span>", - desc, (int) (size * PANGO_SCALE), phrase_escaped); - + desc, (int) (px_size * PANGO_SCALE), phrase_escaped); preview_label.set_markup(markup); @@ -461,7 +467,9 @@ SPCSSAttr *TextEdit::getTextStyle () sp_repr_css_set_property (css, "font-variant", c); Inkscape::CSSOStringStream os; - os << sp_font_selector_get_size (fsel) << "px"; // must specify px, see inkscape bug 1221626 and 1610103 + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); + os << sp_font_selector_get_size (fsel) << sp_style_get_css_unit_string(unit); sp_repr_css_set_property (css, "font-size", os.str().c_str()); font->Unref(); diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index a690b6948..0244621bf 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -32,6 +32,7 @@ #include "desktop.h" #include "widgets/font-selector.h" #include "preferences.h" +#include "unit-constants.h" /* SPFontSelector */ @@ -84,15 +85,7 @@ static void sp_font_selector_size_changed (GtkComboBox *combobo SPFontSelector *fsel); static void sp_font_selector_emit_set (SPFontSelector *fsel); - -namespace { - const char *sizes[] = { - "4", "6", "8", "9", "10", "11", "12", "13", "14", - "16", "18", "20", "22", "24", "28", - "32", "36", "40", "48", "56", "64", "72", "144", - NULL - }; -} +static void sp_font_selector_set_sizes( SPFontSelector *fsel ); static GtkHBoxClass *fs_parent_class = NULL; static guint fs_signals[LAST_SIGNAL] = { 0 }; @@ -136,6 +129,15 @@ static void sp_font_selector_class_init(SPFontSelectorClass *c) object_class->dispose = sp_font_selector_dispose; } +void sp_font_selector_set_size_tooltip(SPFontSelector *fsel) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); + Glib::ustring tooltip = Glib::ustring::format("Font size (", sp_style_get_css_unit_string(unit), ")"); + gtk_widget_set_tooltip_text (fsel->size, _(tooltip.c_str())); +} + + static void sp_font_selector_init(SPFontSelector *fsel) { gtk_box_set_homogeneous(GTK_BOX(fsel), TRUE); @@ -227,7 +229,7 @@ This conditional and its #else block can be deleted in the future. fsel->size = gtk_combo_box_entry_new_text (); #endif - gtk_widget_set_tooltip_text (fsel->size, _("Font size (px)")); + sp_font_selector_set_size_tooltip(fsel); gtk_widget_set_size_request(fsel->size, 90, -1); g_signal_connect (G_OBJECT(fsel->size), "changed", G_CALLBACK (sp_font_selector_size_changed), fsel); gtk_box_pack_end (GTK_BOX(hb), fsel->size, FALSE, FALSE, 0); @@ -236,14 +238,7 @@ This conditional and its #else block can be deleted in the future. gtk_widget_show_all (l); gtk_box_pack_end(GTK_BOX (hb), l, TRUE, TRUE, 0); - for (unsigned int n = 0; sizes[n]; ++n) - { -#if GTK_CHECK_VERSION(2, 24,0) - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(fsel->size), sizes[n]); -#else - gtk_combo_box_append_text (GTK_COMBO_BOX(fsel->size), sizes[n]); -#endif - } + sp_font_selector_set_sizes(fsel); gtk_widget_show_all (fsel->size); @@ -327,6 +322,39 @@ static void sp_font_selector_style_select_row (GtkTreeSelection *selection, } } + +/* + * Set the default list of font sizes, scaled to the users preferred unit + */ +static void sp_font_selector_set_sizes( SPFontSelector *fsel ) +{ + GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model (GTK_COMBO_BOX(fsel->size))); + gtk_list_store_clear(store); + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); + + int sizes[] = { + 4, 6, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 28, + 32, 36, 40, 48, 56, 64, 72, 144 + }; + + // Array must be same length as SPCSSUnit in style.h + float ratios[] = {1, 1, 1, 10, 4, 40, 100, 16, 8, 0.16}; + + for (unsigned int n = 0; n < G_N_ELEMENTS(sizes); ++n) + { + double size = sizes[n] / ratios[unit]; + +#if GTK_CHECK_VERSION(2, 24,0) + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(fsel->size), Glib::ustring::format(size).c_str()); +#else + gtk_combo_box_append_text (GTK_COMBO_BOX(fsel->size), size); +#endif + } + +} + static void sp_font_selector_size_changed( GtkComboBox */*cbox*/, SPFontSelector *fsel ) { char *text = NULL; @@ -502,7 +530,6 @@ void sp_font_selector_set_font (SPFontSelector *fsel, font_instance *font, doubl if (font) { Gtk::TreePath path; - font_instance *tempFont = NULL; Glib::ustring family = font_factory::Default()->GetUIFamilyString(font->descr); @@ -536,6 +563,8 @@ void sp_font_selector_set_font (SPFontSelector *fsel, font_instance *font, doubl g_snprintf (s, 8, "%.5g", size); // UI, so printf is ok gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(fsel->size))), s); fsel->fontsize = size; + sp_font_selector_set_size_tooltip(fsel); + sp_font_selector_set_sizes(fsel); } } @@ -550,6 +579,9 @@ font_instance* sp_font_selector_get_font(SPFontSelector *fsel) return fsel->font; } +/* + * Return the font size in pixels + */ double sp_font_selector_get_size(SPFontSelector *fsel) { return fsel->fontsize; diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 160bc22f3..b769c41f6 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -445,9 +445,10 @@ static void sp_text_fontsize_value_changed( Ink_ComboBoxEntry_Action *act, GObje size = max_size; // Set css font size. + int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); SPCSSAttr *css = sp_repr_css_attr_new (); Inkscape::CSSOStringStream osfs; - osfs << size << "px"; // For now always use px + osfs << size << sp_style_get_css_unit_string(unit); sp_repr_css_set_property (css, "font-size", osfs.str().c_str()); // Apply font size to selected objects. @@ -900,7 +901,6 @@ static void sp_text_letterspacing_value_changed( GtkAdjustment *adj, GObject *tb SPDesktop *desktop = SP_ACTIVE_DESKTOP; sp_desktop_set_style (desktop, css, true, false); - // If no selected objects, set default. SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); int result_numbers = @@ -919,7 +919,6 @@ static void sp_text_letterspacing_value_changed( GtkAdjustment *adj, GObject *tb sp_style_unref(query); - sp_repr_css_attr_unref (css); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@ -1080,6 +1079,31 @@ static void sp_text_orientation_mode_changed( EgeSelectOneAction *act, GObject * } /* + * Set the default list of font sizes, scaled to the users preferred unit + */ +void sp_text_set_sizes(GtkListStore* model_size, int unit) +{ + gtk_list_store_clear(model_size); + + // List of font sizes for drop-down menu + int sizes[] = { + 4, 6, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 28, + 32, 36, 40, 48, 56, 64, 72, 144 + }; + + // Array must be same length as SPCSSUnit in style.h + float ratios[] = {1, 1, 1, 10, 4, 40, 100, 16, 8, 0.16}; + + for( unsigned int i = 0; i < G_N_ELEMENTS(sizes); ++i ) { + GtkTreeIter iter; + Glib::ustring size = Glib::ustring::format(sizes[i] / (float)ratios[unit]); + gtk_list_store_append( model_size, &iter ); + gtk_list_store_set( model_size, &iter, 0, size.c_str(), -1 ); + } +} + + +/* * This function sets up the text-tool tool-controls, setting the entry boxes * etc. to the values from the current selection or the default if no selection. * It is called whenever a text selection is changed, including stepping cursor @@ -1191,16 +1215,22 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ ink_comboboxentry_action_set_active_text( fontFamilyAction, fontFamily ); } - // Size (average of text selected) - double size = query->font_size.computed; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); + double size = sp_style_get_css_font_size_units(query->font_size.computed, unit); + gchar size_text[G_ASCII_DTOSTR_BUF_SIZE]; g_ascii_dtostr (size_text, sizeof (size_text), size); Ink_ComboBoxEntry_Action* fontSizeAction = INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontSizeAction" ) ); + sp_text_set_sizes(GTK_LIST_STORE(ink_comboboxentry_action_get_model(fontSizeAction)), unit); ink_comboboxentry_action_set_active_text( fontSizeAction, size_text ); + Glib::ustring tooltip = Glib::ustring::format("Font size (", sp_style_get_css_unit_string(unit), ")"); + ink_comboboxentry_action_set_tooltip ( fontSizeAction, tooltip.c_str()); + // Font styles font_instance *font = font_factory::Default()->FaceFromStyle(query); sp_text_fontstyle_populate(tbl, font); @@ -1451,20 +1481,16 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje { // List of font sizes for drop-down menu GtkListStore* model_size = gtk_list_store_new( 1, G_TYPE_STRING ); - gchar const *const sizes[] = { - "4", "6", "8", "9", "10", "11", "12", "13", "14", "16", - "18", "20", "22", "24", "28", "32", "36", "40", "48", "56", - "64", "72", "144" - }; - for( unsigned int i = 0; i < G_N_ELEMENTS(sizes); ++i ) { - GtkTreeIter iter; - gtk_list_store_append( model_size, &iter ); - gtk_list_store_set( model_size, &iter, 0, sizes[i], -1 ); - } + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); + + sp_text_set_sizes(model_size, unit); + + Glib::ustring tooltip = Glib::ustring::format("Font size (", sp_style_get_css_unit_string(unit), ")"); Ink_ComboBoxEntry_Action* act = ink_comboboxentry_action_new( "TextFontSizeAction", _("Font Size"), - _("Font size (px)"), + _(tooltip.c_str()), NULL, GTK_TREE_MODEL(model_size), 4 ); // Width in characters |
