diff options
| author | Liam P. White <inkscapebronyat-signgmaildotcom> | 2014-04-29 01:00:39 +0000 |
|---|---|---|
| committer | Liam P. White <inkscapebronyat-signgmaildotcom> | 2014-04-29 01:00:39 +0000 |
| commit | eca72e61451c8deae7f2f5fbaa9885aec946c790 (patch) | |
| tree | 76d436abbbe469e0bc3b4a254e0ab6e5b4525e3b /src/libnrtype | |
| parent | Update to trunk (diff) | |
| parent | when removing LPE, with 'flattening' option, don't recalculate/rewrite ellips... (diff) | |
| download | inkscape-eca72e61451c8deae7f2f5fbaa9885aec946c790.tar.gz inkscape-eca72e61451c8deae7f2f5fbaa9885aec946c790.zip | |
Update to trunk and fix issues
(bzr r13090.1.67)
Diffstat (limited to 'src/libnrtype')
| -rw-r--r-- | src/libnrtype/FontFactory.cpp | 10 | ||||
| -rw-r--r-- | src/libnrtype/Layout-TNG-Input.cpp | 5 | ||||
| -rw-r--r-- | src/libnrtype/Layout-TNG.h | 2 | ||||
| -rw-r--r-- | src/libnrtype/font-lister.cpp | 42 | ||||
| -rw-r--r-- | src/libnrtype/font-lister.h | 8 | ||||
| -rw-r--r-- | src/libnrtype/font-style-to-pos.h | 2 |
6 files changed, 51 insertions, 18 deletions
diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 7c0b4ffba..4ae408397 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -825,17 +825,17 @@ font_instance* font_factory::FaceFromStyle(SPStyle const *style) if (style) { // First try to use the font specification if it is set - if (style->text->font_specification.set - && style->text->font_specification.value - && *style->text->font_specification.value) { + if (style->font_specification.set + && style->font_specification.value + && *style->font_specification.value) { - font = FaceFromFontSpecification(style->text->font_specification.value); + font = FaceFromFontSpecification(style->font_specification.value); } // If that failed, try using the CSS information in the style if (!font) { - font = Face(style->text->font_family.value, font_style_to_pos(*style)); + font = Face(style->font_family.value, font_style_to_pos(*style)); // That was a hatchet job... so we need to check if this font exists!! Glib::ustring fontSpec = font_factory::Default()->ConstructFontSpecification(font); diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp index cb3e6f620..fa1e8c11b 100644 --- a/src/libnrtype/Layout-TNG-Input.cpp +++ b/src/libnrtype/Layout-TNG-Input.cpp @@ -286,16 +286,15 @@ font_instance *Layout::InputStreamTextSource::styleGetFontInstance() const PangoFontDescription *Layout::InputStreamTextSource::styleGetFontDescription() const { - if (style->text == NULL) return NULL; PangoFontDescription *descr = pango_font_description_new(); // Pango can't cope with spaces before or after the commas - let's remove them. // this code is not exactly unicode-safe, but it's similar to what's done in // pango, so it's not the limiting factor Glib::ustring family; - if (style->text->font_family.value == NULL) { + if (style->font_family.value == NULL) { family = "sans-serif"; } else { - gchar **families = g_strsplit(style->text->font_family.value, ",", -1); + gchar **families = g_strsplit(style->font_family.value, ",", -1); if (families) { for (gchar **f = families ; *f ; ++f) { g_strstrip(*f); diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h index c3ccbffb5..efb5ebc24 100644 --- a/src/libnrtype/Layout-TNG.h +++ b/src/libnrtype/Layout-TNG.h @@ -34,7 +34,7 @@ namespace Inkscape { using Inkscape::Extension::Internal::CairoRenderContext; #endif -struct SPStyle; +class SPStyle; class Shape; struct SPPrintContext; class SVGLength; diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 89d0cb037..98589d9d7 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -97,6 +97,34 @@ namespace Inkscape // } // font_list_store->foreach_iter( sigc::mem_fun(*this, &FontLister::print_document_font )); + + /* Used to insert a font that was not in the document and not on the system into the font list. */ + void + FontLister::insert_font_family( Glib::ustring new_family ) { + + GList *styles = default_styles; + + /* In case this is a fallback list, check if first font-family on system. */ + std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(",", new_family ); + if( !tokens.empty() && !tokens[0].empty() ) { + + Gtk::TreeModel::iterator iter2 = font_list_store->get_iter( "0" ); + while( iter2 != font_list_store->children().end() ) { + Gtk::TreeModel::Row row = *iter2; + if( row[FontList.onSystem] && tokens[0].compare( row[FontList.family] ) == 0 ) { + styles = row[FontList.styles]; + break; + } + ++iter2; + } + } + + Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend(); + (*treeModelIter)[FontList.family] = reinterpret_cast<const char*>(g_strdup(new_family.c_str())); + (*treeModelIter)[FontList.styles] = styles; + (*treeModelIter)[FontList.onSystem] = false; + } + void FontLister::update_font_list( SPDocument* document ) { @@ -330,8 +358,8 @@ namespace Inkscape sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION); //std::cout << " Attempting selected style" << std::endl; - if( result != QUERY_STYLE_NOTHING && query->text->font_specification.set ) { - fontspec = query->text->font_specification.value; + if( result != QUERY_STYLE_NOTHING && query->font_specification.set ) { + fontspec = query->font_specification.value; //std::cout << " fontspec from query :" << fontspec << ":" << std::endl; } @@ -665,15 +693,15 @@ std::pair<Glib::ustring, Glib::ustring> FontLister::new_font_family (Glib::ustri if (style) { // First try to use the font specification if it is set - if (style->text->font_specification.set - && style->text->font_specification.value - && *style->text->font_specification.value) { + if (style->font_specification.set + && style->font_specification.value + && *style->font_specification.value) { - fontspec = style->text->font_specification.value; + fontspec = style->font_specification.value; } else { - fontspec = style->text->font_family.value; + fontspec = style->font_family.value; fontspec += ","; switch (style->font_weight.computed) { diff --git a/src/libnrtype/font-lister.h b/src/libnrtype/font-lister.h index 5a8f578d9..a460388d3 100644 --- a/src/libnrtype/font-lister.h +++ b/src/libnrtype/font-lister.h @@ -26,7 +26,7 @@ class SPObject; class SPDocument; class SPCSSAttr; -struct SPStyle; +class SPStyle; namespace Inkscape { @@ -127,6 +127,12 @@ namespace Inkscape const Glib::RefPtr<Gtk::ListStore> get_style_list () const; + /** Inserts a font family or font-fallback list (for use when not + * already in document or on system). + */ + void + insert_font_family ( Glib::ustring new_family ); + /** Updates font list to include fonts in document * */ diff --git a/src/libnrtype/font-style-to-pos.h b/src/libnrtype/font-style-to-pos.h index 56eb391c2..41ba6cf72 100644 --- a/src/libnrtype/font-style-to-pos.h +++ b/src/libnrtype/font-style-to-pos.h @@ -3,7 +3,7 @@ #include <libnrtype/nr-type-pos-def.h> -struct SPStyle; +class SPStyle; NRTypePosDef font_style_to_pos(SPStyle const &style); |
