From 512f06a80f013e903d513b6ffa069d48c6abbfaa Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Sat, 5 Jan 2008 10:38:18 +0000 Subject: Applying Gail's patch for font-specification (Closes LP: #169973) - New attribute in an object's style string called -inkscape-font-specification stores full font name - This will be useful when we can support fonts that don't fit into the confines of CSS (if either pango enhances their PangoFontDescription structure, or we can get around its limitations) - Framework in place to separate font families from their "styles" (faces) in the text and font dialog - need only the code that does the actual separation - Text and Styles dialog shows only fonts it can handle (bzr r4392) --- src/dialogs/text-edit.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/dialogs/text-edit.cpp') diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index 279c5b5e7..d96583f85 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -527,7 +527,11 @@ sp_get_text_dialog_style () font_instance *font = sp_font_selector_get_font (SP_FONT_SELECTOR (fontsel)); if ( font ) { + Glib::ustring fontName = font_factory::Default()->ConstructFontSpecification(font); + sp_repr_css_set_property (css, "-inkscape-font-specification", fontName.c_str()); + gchar c[256]; + font->Family(c, 256); sp_repr_css_set_property (css, "font-family", c); @@ -736,12 +740,15 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, // create temporary style SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); // query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection - int result_family = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY); - int result_style = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE); + int result_fontspec = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION); + int result_family = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY); + int result_style = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE); int result_numbers = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS); // If querying returned nothing, read the style from the text tool prefs (default style for new texts) - if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING || result_numbers == QUERY_STYLE_NOTHING) { + // (Ok to not get a font specification - must just rely on the family and style in that case) + if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING + || result_numbers == QUERY_STYLE_NOTHING) { repr = inkscape_get_repr (INKSCAPE, "tools.text"); if (repr) { gtk_widget_set_sensitive (notebook, TRUE); @@ -752,7 +759,11 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, } // FIXME: process result_family/style == QUERY_STYLE_MULTIPLE_DIFFERENT by showing "Many" in the lists - font_instance *font = (font_factory::Default())->Face ( query->text->font_family.value, font_style_to_pos(*query) ); + + // Get a font_instance using the font-specification attribute stored in SPStyle if available + font_instance *font = font_factory::Default()->FaceFromStyle(query); + + if (font) { // the font is oversized, so we need to pass the true size separately sp_font_selector_set_font (SP_FONT_SELECTOR (fontsel), font, query->font_size.computed); -- cgit v1.2.3