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/extension/internal/pdf-cairo.cpp | 2 +- src/extension/internal/pdfinput/svg-builder.cpp | 9 ++++++++- src/extension/internal/ps.cpp | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/pdf-cairo.cpp b/src/extension/internal/pdf-cairo.cpp index 4baab1740..ae17a6edd 100644 --- a/src/extension/internal/pdf-cairo.cpp +++ b/src/extension/internal/pdf-cairo.cpp @@ -830,7 +830,7 @@ PrintCairoPDF::text(Inkscape::Extension::Print *mod, char const *text, NR::Point } // create font instance from style and use it - font_instance *tf = (font_factory::Default())->Face(style->text->font_family.value, font_style_to_pos(*style)); + font_instance *tf = font_factory::Default()->FaceFromStyle(style); if (tf == NULL) { // do something g_printf("Warning: trouble getting font_instance\n"); tf = (font_factory::Default())->Face("sans", font_style_to_pos(*style)); diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 3d96991a6..076f12906 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -1169,7 +1169,14 @@ void SvgBuilder::_flushText() { break; } else { tspan_node = _xml_doc->createElement("svg:tspan"); - tspan_node->setAttribute("inkscape:font-specification", glyph.font_specification); + + /////// + // Create a font specification string and save the attribute in the style + PangoFontDescription *descr = pango_font_description_from_string(glyph.font_specification); + Glib::ustring properFontSpec = font_factory::Default()->ConstructFontSpecification(descr); + pango_font_description_free(descr); + sp_repr_css_set_property(glyph.style, "-inkscape-font-specification", properFontSpec.c_str()); + // Set style and unref SPCSSAttr if it won't be needed anymore sp_repr_css_change(tspan_node, glyph.style, "style"); if ( glyph.style_changed && i != _glyphs.begin() ) { // Free previous style diff --git a/src/extension/internal/ps.cpp b/src/extension/internal/ps.cpp index fedde86a2..6cc27988d 100644 --- a/src/extension/internal/ps.cpp +++ b/src/extension/internal/ps.cpp @@ -913,7 +913,7 @@ PrintPS::image(Inkscape::Extension::Print *mod, guchar *px, unsigned int w, unsi char const * PrintPS::PSFontName(SPStyle const *style) { - font_instance *tf = (font_factory::Default())->Face(style->text->font_family.value, font_style_to_pos(*style)); + font_instance *tf = font_factory::Default()->FaceFromStyle(style); char const *n; char name_buf[256]; @@ -1273,7 +1273,8 @@ PrintPS::text(Inkscape::Extension::Print *mod, char const *text, NR::Point p, * that's why using PSFontName() method just to get the PS fontname * is not enough and not appropriate */ - font_instance *tf = (font_factory::Default())->Face(style->text->font_family.value, font_style_to_pos(*style)); + font_instance *tf = font_factory::Default()->FaceFromStyle(style); + const gchar *fn = NULL; char name_buf[256]; -- cgit v1.2.3