summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2016-09-01 12:02:12 +0000
committertavmjong-free <tavmjong@free.fr>2016-09-01 12:02:12 +0000
commit0fb25eebd29911c6b0c3515f0cdc86a8dde373a6 (patch)
treef4b29384cc91a5add01dd979415a4f5c76f63e43 /src
parentDrop unused cxxtest fork in favour of Googletest (diff)
downloadinkscape-0fb25eebd29911c6b0c3515f0cdc86a8dde373a6.tar.gz
inkscape-0fb25eebd29911c6b0c3515f0cdc86a8dde373a6.zip
Fix font style handling for non-system fonts.
Gets rid of some Pango-CRITICAL and Gtk_CRITICAL warnings. (bzr r15097)
Diffstat (limited to 'src')
-rw-r--r--src/libnrtype/FontFactory.cpp6
-rw-r--r--src/libnrtype/font-lister.cpp14
2 files changed, 16 insertions, 4 deletions
diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp
index 1fbdce036..6865e923e 100644
--- a/src/libnrtype/FontFactory.cpp
+++ b/src/libnrtype/FontFactory.cpp
@@ -295,6 +295,7 @@ void font_factory::GetUIFamilies(std::vector<PangoFontFamily *>& out)
const char* displayName = pango_font_family_get_name(families[currentFamily]);
if (displayName == 0 || *displayName == '\0') {
+ std::cerr << "font_factory::GetUIFamilies: Missing displayName! " << std::endl;
continue;
}
sorted.push_back(std::make_pair(families[currentFamily], displayName));
@@ -313,6 +314,10 @@ GList* font_factory::GetUIStyles(PangoFontFamily * in)
// Gather the styles for this family
PangoFontFace** faces = NULL;
int numFaces = 0;
+ if (in == NULL) {
+ std::cerr << "font_factory::GetUIStyles(): PangoFontFamily is NULL" << std::endl;
+ return ret;
+ }
pango_font_family_list_faces(in, &faces, &numFaces);
for (int currentFace = 0; currentFace < numFaces; currentFace++) {
@@ -322,6 +327,7 @@ GList* font_factory::GetUIStyles(PangoFontFamily * in)
const gchar* displayName = pango_font_face_get_face_name(faces[currentFace]);
// std::cout << "Display Name: " << displayName << std::endl;
if (displayName == NULL || *displayName == '\0') {
+ std::cerr << "font_factory::GetUIStyles: Missing displayName! " << std::endl;
continue;
}
diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp
index 4deae821a..48fcf2a22 100644
--- a/src/libnrtype/font-lister.cpp
+++ b/src/libnrtype/font-lister.cpp
@@ -135,6 +135,8 @@ void FontLister::ensureRowStyles(GtkTreeModel* model, GtkTreeIter const* iterato
if (!row[FontList.styles]) {
if (row[FontList.pango_family]) {
row[FontList.styles] = font_factory::Default()->GetUIStyles(row[FontList.pango_family]);
+ } else {
+ row[FontList.styles] = default_styles;
}
}
}
@@ -177,6 +179,7 @@ void FontLister::insert_font_family(Glib::ustring new_family)
(*treeModelIter)[FontList.family] = new_family;
(*treeModelIter)[FontList.styles] = styles;
(*treeModelIter)[FontList.onSystem] = false;
+ (*treeModelIter)[FontList.pango_family] = NULL;
}
void FontLister::update_font_list(SPDocument *document)
@@ -256,7 +259,8 @@ void FontLister::update_font_list(SPDocument *document)
Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend();
(*treeModelIter)[FontList.family] = reinterpret_cast<const char *>(g_strdup((*i).c_str()));
(*treeModelIter)[FontList.styles] = styles;
- (*treeModelIter)[FontList.onSystem] = false;
+ (*treeModelIter)[FontList.onSystem] = false; // false if document font
+ (*treeModelIter)[FontList.pango_family] = NULL; // CHECK ME (set to pango_family if on system?)
}
@@ -993,7 +997,7 @@ Glib::ustring FontLister::get_best_style_match(Glib::ustring family, Glib::ustri
}
catch (...)
{
- //std::cout << " ERROR: can't find family: " << family << std::endl;
+ std::cerr << "FontLister::get_best_style_match(): can't find family: " << family << std::endl;
return (target_style);
}
@@ -1002,10 +1006,12 @@ Glib::ustring FontLister::get_best_style_match(Glib::ustring family, Glib::ustri
//font_description_dump( target );
- if (!row[FontList.styles]) {
+ GList *styles = default_styles;
+ if (row[FontList.onSystem] && !row[FontList.styles]) {
row[FontList.styles] = font_factory::Default()->GetUIStyles(row[FontList.pango_family]);
+ styles = row[FontList.styles];
}
- GList *styles = row[FontList.styles];
+
for (GList *l = styles; l; l = l->next) {
Glib::ustring fontspec = family + ", " + ((StyleNames *)l->data)->CssName;
PangoFontDescription *candidate = pango_font_description_from_string(fontspec.c_str());