summaryrefslogtreecommitdiff
path: root/pango/pangocoretext-fontmap.c
diff options
context:
space:
mode:
authorKristian Rietveld <kris@lanedo.com>2012-05-13 18:23:11 +0200
committerKristian Rietveld <kris@lanedo.com>2012-05-13 18:23:54 +0200
commit216d03ba5023b247515e2adf5df658c0e4e90b3d (patch)
treeaf20aac3817eb9f8d43b742900eaf931c67542be /pango/pangocoretext-fontmap.c
parentaecbe27c1b08f517c0e05f03308d3ac55cef490c (diff)
downloadpango-216d03ba5023b247515e2adf5df658c0e4e90b3d.tar.gz
Use same font family name fallback in pango_core_text_font_map_init
Same fallback as already used in CoreText font descriptor to Pango font descriptor conversion.
Diffstat (limited to 'pango/pangocoretext-fontmap.c')
-rw-r--r--pango/pangocoretext-fontmap.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c
index 687c3404..e184b6b7 100644
--- a/pango/pangocoretext-fontmap.c
+++ b/pango/pangocoretext-fontmap.c
@@ -167,7 +167,8 @@ gchar_from_cf_string (CFStringRef str)
}
static char *
-ct_font_descriptor_get_family_name (CTFontDescriptorRef desc)
+ct_font_descriptor_get_family_name (CTFontDescriptorRef desc,
+ gboolean may_fail)
{
CFStringRef cf_str;
char *buffer;
@@ -183,6 +184,9 @@ ct_font_descriptor_get_family_name (CTFontDescriptorRef desc)
cf_str = CTFontDescriptorCopyAttribute (desc, kCTFontNameAttribute);
if (!cf_str)
{
+ if (may_fail)
+ return NULL;
+
/* This font is likely broken, return a default family name ... */
return g_strdup ("Sans");
}
@@ -343,7 +347,7 @@ _pango_core_text_font_description_from_ct_font_descriptor (CTFontDescriptorRef d
/* FIXME: Should we actually retrieve the family name from the list of
* families in a font map?
*/
- family_name = ct_font_descriptor_get_family_name (desc);
+ family_name = ct_font_descriptor_get_family_name (desc, FALSE);
pango_font_description_set_family (font_desc, family_name);
g_free (family_name);
@@ -1308,13 +1312,13 @@ pango_core_text_font_map_init (PangoCoreTextFontMap *ctfontmap)
SInt64 font_traits;
char *buffer;
char *family_name;
- CFStringRef str;
CFNumberRef number;
CFDictionaryRef dict;
CTFontDescriptorRef desc = CFArrayGetValueAtIndex (ctfaces, i);
- str = CTFontDescriptorCopyAttribute (desc, kCTFontFamilyNameAttribute);
- buffer = gchar_from_cf_string (str);
+ buffer = ct_font_descriptor_get_family_name (desc, TRUE);
+ if (!buffer)
+ continue;
family_name = g_utf8_casefold (buffer, -1);
@@ -1328,7 +1332,6 @@ pango_core_text_font_map_init (PangoCoreTextFontMap *ctfontmap)
family->family_name = g_strdup (buffer);
}
- CFRelease (str);
g_free (buffer);
g_free (family_name);