summaryrefslogtreecommitdiff
path: root/pango/pangocoretext-fontmap.c
diff options
context:
space:
mode:
authorKristian Rietveld <kris@lanedo.com>2011-11-14 10:48:53 +0100
committerKristian Rietveld <kris@lanedo.com>2011-11-14 10:54:05 +0100
commitcce4c9f84350bb53371323ab96ccf9245e014f75 (patch)
tree4b3a67b40d3dd895b92dfde3d1a0589abc1f65a9 /pango/pangocoretext-fontmap.c
parentc21b1bfe1278de08673c495ba398fbdee874a778 (diff)
downloadpango-cce4c9f84350bb53371323ab96ccf9245e014f75.tar.gz
CoreText: stricter handling of FontSymbolic traits
It turns out that getting this value as "Int" is incorrect and resulted in font traits not being returned in some cases. Without traits, an italic trait is not set, which caused synthetic oblique fonts to be created when not necessary. Also use CTFontSymbolicTraits type in the PangoCoreTextFace structure and do a stricter bit mask check for certainty.
Diffstat (limited to 'pango/pangocoretext-fontmap.c')
-rw-r--r--pango/pangocoretext-fontmap.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c
index 542665e0..9f67acb8 100644
--- a/pango/pangocoretext-fontmap.c
+++ b/pango/pangocoretext-fontmap.c
@@ -78,7 +78,7 @@ struct _PangoCoreTextFace
char *style_name;
PangoWeight weight;
- int traits;
+ CTFontSymbolicTraits traits;
guint synthetic_italic : 1;
};
@@ -195,7 +195,7 @@ pango_core_text_face_is_oblique (PangoCoreTextFace *face)
static inline PangoCoreTextFace *
pango_core_text_face_from_ct_font_descriptor (CTFontDescriptorRef desc)
{
- int font_traits;
+ SInt64 font_traits;
char *buffer;
CFStringRef str;
CFNumberRef number;
@@ -250,8 +250,14 @@ pango_core_text_face_from_ct_font_descriptor (CTFontDescriptorRef desc)
else
face->weight = PANGO_WEIGHT_NORMAL;
+ /* This is interesting, the value stored is a CTFontSymbolicTraits which
+ * is defined as uint32_t. CFNumber does not have an obvious type which
+ * deals with unsigned values. Upon inspection with CFNumberGetType,
+ * it turns out this value is stored as SInt64, so we use that to
+ * obtain the value from the CFNumber.
+ */
number = (CFNumberRef)CFDictionaryGetValue (dict, kCTFontSymbolicTrait);
- if (CFNumberGetValue (number, kCFNumberIntType, &font_traits))
+ if (CFNumberGetValue (number, kCFNumberSInt64Type, &font_traits))
{
face->traits = font_traits;
}
@@ -327,8 +333,8 @@ pango_core_text_family_list_faces (PangoFontFamily *family,
faces = g_list_prepend (faces, face);
- if (face->traits & kCTFontItalicTrait
- || pango_core_text_face_is_oblique (face))
+ if ((face->traits & kCTFontItalicTrait) == kCTFontItalicTrait ||
+ pango_core_text_face_is_oblique (face))
g_hash_table_insert (italic_faces,
GINT_TO_POINTER ((gint)face->weight),
face);