Skip to content

Instantly share code, notes, and snippets.

@chearon
Last active October 11, 2017 19:13
Show Gist options
  • Save chearon/3a2083b2683c687ef4094c71c426155a to your computer and use it in GitHub Desktop.
Save chearon/3a2083b2683c687ef4094c71c426155a to your computer and use it in GitHub Desktop.
From 95101a024258be3b058763fa00b526168e21df28 Mon Sep 17 00:00:00 2001
From: Caleb Hearon <caleb@chearon.net>
Date: Wed, 11 Oct 2017 14:24:49 -0400
Subject: [PATCH] fix bug #762873 - commas in family names for ct
---
pango/pangocoretext-fontmap.c | 58 +++++++++++++++++++++++++++----------------
1 file changed, 36 insertions(+), 22 deletions(-)
diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c
index 4d101847..9d80fb76 100644
--- a/pango/pangocoretext-fontmap.c
+++ b/pango/pangocoretext-fontmap.c
@@ -1542,45 +1542,59 @@ pango_core_text_fontset_new (PangoCoreTextFontsetKey *key,
PangoCoreTextFamily *font_family;
PangoCoreTextFontset *fontset;
PangoCoreTextFont *best_font = NULL;
+ gchar **family_names;
const gchar *family;
gchar *name;
+ GPtrArray *fonts;
+ fonts = g_ptr_array_new ();
family = pango_font_description_get_family (description);
- family = family ? family : "";
- name = g_utf8_casefold (family, -1);
- font_family = g_hash_table_lookup (key->fontmap->families, name);
- g_free (name);
+ family_names = g_strsplit (family ? family : "", ",", -1);
- if (font_family)
+ for (int i = 0; family_names[i]; ++i)
{
- PangoCoreTextFace *best_face;
+ name = g_utf8_casefold (family_names[i], -1);
+ font_family = g_hash_table_lookup (key->fontmap->families, name);
+ g_free (name);
- /* Force a listing of the available faces */
- pango_font_family_list_faces ((PangoFontFamily *)font_family, NULL, NULL);
+ if (font_family)
+ {
+ PangoCoreTextFace *family_face;
+ PangoCoreTextFont *font;
- if (!find_best_match (font_family, description, &best_face))
- return NULL;
+ /* Force a listing of the available faces */
+ pango_font_family_list_faces ((PangoFontFamily *)font_family, NULL, NULL);
- best_font =
- pango_core_text_font_map_new_font (key->fontmap,
- key,
- best_face->ctfontdescriptor,
- best_face->synthetic_italic);
+ if (find_best_match (font_family, description, &family_face))
+ {
+ font = pango_core_text_font_map_new_font (key->fontmap,
+ key,
+ family_face->ctfontdescriptor,
+ family_face->synthetic_italic);
+ if (font)
+ {
+ g_ptr_array_add (fonts, font);
+ if (best_font == NULL) best_font = font;
+ }
+ }
+ }
}
- else
- return NULL;
+
+ g_strfreev (family_names);
if (!best_font)
- return NULL;
+ {
+ g_ptr_array_free (fonts, false);
+ return NULL;
+ }
/* Create a font set with best font */
fontset = g_object_new (PANGO_TYPE_CORE_TEXT_FONTSET, NULL);
fontset->key = pango_core_text_fontset_key_copy (key);
fontset->orig_description = pango_font_description_copy (description);
- fontset->fonts = g_ptr_array_new ();
- g_ptr_array_add (fontset->fonts, best_font);
+ fontset->fonts = fonts;
fontset->coverages = g_ptr_array_new ();
/* Add the cascade list for this language */
@@ -1616,8 +1630,8 @@ pango_core_text_fontset_new (PangoCoreTextFontsetKey *key,
#endif
/* length of cascade list + 1 for the "real" font at the front */
- g_ptr_array_set_size (fontset->fonts, CFArrayGetCount (fontset->cascade_list) + 1);
- g_ptr_array_set_size (fontset->coverages, CFArrayGetCount (fontset->cascade_list) + 1);
+ g_ptr_array_set_size (fontset->fonts, CFArrayGetCount (fontset->cascade_list) + fonts->len);
+ g_ptr_array_set_size (fontset->coverages, CFArrayGetCount (fontset->cascade_list) + fonts->len);
return fontset;
}
--
2.13.5 (Apple Git-94)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment