| 1 | Upstream-Status: Pending, patch based on https://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/15097 with additional null-checks for familyUIName and styleUIName |
| 2 | |
| 3 | === modified file 'src/libnrtype/FontFactory.cpp' |
| 4 | --- src/libnrtype/FontFactory.cpp 2016-08-30 11:38:29 +0000 |
| 5 | +++ src/libnrtype/FontFactory.cpp 2016-09-01 12:02:12 +0000 |
| 6 | @@ -295,6 +295,7 @@ |
| 7 | const char* displayName = pango_font_family_get_name(families[currentFamily]); |
| 8 | |
| 9 | if (displayName == 0 || *displayName == '\0') { |
| 10 | + std::cerr << "font_factory::GetUIFamilies: Missing displayName! " << std::endl; |
| 11 | continue; |
| 12 | } |
| 13 | sorted.push_back(std::make_pair(families[currentFamily], displayName)); |
| 14 | @@ -313,6 +314,10 @@ |
| 15 | // Gather the styles for this family |
| 16 | PangoFontFace** faces = NULL; |
| 17 | int numFaces = 0; |
| 18 | + if (in == NULL) { |
| 19 | + std::cerr << "font_factory::GetUIStyles(): PangoFontFamily is NULL" << std::endl; |
| 20 | + return ret; |
| 21 | + } |
| 22 | pango_font_family_list_faces(in, &faces, &numFaces); |
| 23 | |
| 24 | for (int currentFace = 0; currentFace < numFaces; currentFace++) { |
| 25 | @@ -322,6 +327,7 @@ |
| 26 | const gchar* displayName = pango_font_face_get_face_name(faces[currentFace]); |
| 27 | // std::cout << "Display Name: " << displayName << std::endl; |
| 28 | if (displayName == NULL || *displayName == '\0') { |
| 29 | + std::cerr << "font_factory::GetUIStyles: Missing displayName! " << std::endl; |
| 30 | continue; |
| 31 | } |
| 32 | |
| 33 | @@ -326,6 +332,10 @@ |
| 34 | Glib::ustring familyUIName = GetUIFamilyString(faceDescr); |
| 35 | Glib::ustring styleUIName = GetUIStyleString(faceDescr); |
| 36 | // std::cout << familyUIName << " " << styleUIName << " " << displayName << std::endl; |
| 37 | + if (familyUIName == NULL || styleUIName == NULL) { |
| 38 | + std::cerr << "font_factory::GetUIStyles: Missing familyUIName or styleUIName!" << std::endl; |
| 39 | + continue; |
| 40 | + } |
| 41 | // Disable synthesized (faux) font faces except for CSS generic faces |
| 42 | if (pango_font_face_is_synthesized(faces[currentFace]) ) { |
| 43 | if (familyUIName.compare( "sans-serif" ) != 0 && |
| 44 | === modified file 'src/libnrtype/font-lister.cpp' |
| 45 | --- src/libnrtype/font-lister.cpp 2016-07-14 11:17:21 +0000 |
| 46 | +++ src/libnrtype/font-lister.cpp 2016-09-01 12:02:12 +0000 |
| 47 | @@ -135,6 +135,8 @@ |
| 48 | if (!row[FontList.styles]) { |
| 49 | if (row[FontList.pango_family]) { |
| 50 | row[FontList.styles] = font_factory::Default()->GetUIStyles(row[FontList.pango_family]); |
| 51 | + } else { |
| 52 | + row[FontList.styles] = default_styles; |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | @@ -177,6 +179,7 @@ |
| 57 | (*treeModelIter)[FontList.family] = new_family; |
| 58 | (*treeModelIter)[FontList.styles] = styles; |
| 59 | (*treeModelIter)[FontList.onSystem] = false; |
| 60 | + (*treeModelIter)[FontList.pango_family] = NULL; |
| 61 | } |
| 62 | |
| 63 | void FontLister::update_font_list(SPDocument *document) |
| 64 | @@ -256,7 +259,8 @@ |
| 65 | Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend(); |
| 66 | (*treeModelIter)[FontList.family] = reinterpret_cast<const char *>(g_strdup((*i).c_str())); |
| 67 | (*treeModelIter)[FontList.styles] = styles; |
| 68 | - (*treeModelIter)[FontList.onSystem] = false; |
| 69 | + (*treeModelIter)[FontList.onSystem] = false; // false if document font |
| 70 | + (*treeModelIter)[FontList.pango_family] = NULL; // CHECK ME (set to pango_family if on system?) |
| 71 | |
| 72 | } |
| 73 | |
| 74 | @@ -993,7 +997,7 @@ |
| 75 | } |
| 76 | catch (...) |
| 77 | { |
| 78 | - //std::cout << " ERROR: can't find family: " << family << std::endl; |
| 79 | + std::cerr << "FontLister::get_best_style_match(): can't find family: " << family << std::endl; |
| 80 | return (target_style); |
| 81 | } |
| 82 | |
| 83 | @@ -1002,10 +1006,12 @@ |
| 84 | |
| 85 | //font_description_dump( target ); |
| 86 | |
| 87 | - if (!row[FontList.styles]) { |
| 88 | + GList *styles = default_styles; |
| 89 | + if (row[FontList.onSystem] && !row[FontList.styles]) { |
| 90 | row[FontList.styles] = font_factory::Default()->GetUIStyles(row[FontList.pango_family]); |
| 91 | + styles = row[FontList.styles]; |
| 92 | } |
| 93 | - GList *styles = row[FontList.styles]; |
| 94 | + |
| 95 | for (GList *l = styles; l; l = l->next) { |
| 96 | Glib::ustring fontspec = family + ", " + ((StyleNames *)l->data)->CssName; |
| 97 | PangoFontDescription *candidate = pango_font_description_from_string(fontspec.c_str()); |
| 98 | |