diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-01-04 05:46:28 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-01-04 05:46:28 +0000 |
commit | a92bd036e33c8ace7a980fbf0698b23396345bd8 (patch) | |
tree | c7a02e26aadce9a1f6a21bc91c77ce4c38a59f11 /pango | |
parent | 749d7af9a9757fda86eb90480efbea110904ab04 (diff) | |
parent | c210059e5488ef0faa74d2a70b275677687ee7c9 (diff) | |
download | pango-a92bd036e33c8ace7a980fbf0698b23396345bd8.tar.gz |
Merge branch 'macos-tests' into 'master'
ci: Run tests on MacOS
Closes #524
See merge request GNOME/pango!268
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pangocoretext-fontmap.c | 51 | ||||
-rw-r--r-- | pango/pangocoretext-private.h | 3 | ||||
-rw-r--r-- | pango/pangocoretext.c | 2 |
3 files changed, 55 insertions, 1 deletions
diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c index 5a81e388..78003e6c 100644 --- a/pango/pangocoretext-fontmap.c +++ b/pango/pangocoretext-fontmap.c @@ -1859,3 +1859,54 @@ pango_core_text_fontset_foreach (PangoFontset *fontset, } } +PangoCoreTextFace * +pango_core_text_font_map_find_face (PangoCoreTextFontMap *map, + const PangoCoreTextFontKey *key) +{ + CTFontDescriptorRef desc; + gboolean synthetic_italic; + char *family; + char *family_name; + char *style_name; + PangoWeight weight; + CTFontSymbolicTraits traits; + PangoCoreTextFamily *font_family; + PangoCoreTextFace *result = NULL; + + desc = pango_core_text_font_key_get_ctfontdescriptor (key); + synthetic_italic = pango_core_text_font_key_get_synthetic_italic (key); + + family_name = ct_font_descriptor_get_family_name (desc, FALSE); + style_name = ct_font_descriptor_get_style_name (desc); + weight = ct_font_descriptor_get_weight (desc); + traits = ct_font_descriptor_get_traits (desc); + + family = g_utf8_casefold (family_name, -1); + + font_family = g_hash_table_lookup (map->families, family); + + if (font_family) + { + pango_font_family_list_faces ((PangoFontFamily *)font_family, NULL, NULL); + + for (int i = 0; i < font_family->n_faces; i++) + { + PangoCoreTextFace *face = (PangoCoreTextFace *)font_family->faces[i]; + + if (face->weight == weight && + face->traits == traits && + face->synthetic_italic == synthetic_italic && + strcmp (face->style_name, style_name) == 0) + { + result = face; + break; + } + } + } + + g_free (family); + g_free (family_name); + g_free (style_name); + + return result; +} diff --git a/pango/pangocoretext-private.h b/pango/pangocoretext-private.h index 9cade31a..d95ec642 100644 --- a/pango/pangocoretext-private.h +++ b/pango/pangocoretext-private.h @@ -152,6 +152,9 @@ PangoGravity pango_core_text_font_key_get_gravity (const Pango _PANGO_EXTERN CTFontDescriptorRef pango_core_text_font_key_get_ctfontdescriptor (const PangoCoreTextFontKey *key); +PangoCoreTextFace * pango_core_text_font_map_find_face (PangoCoreTextFontMap *map, + const PangoCoreTextFontKey *key); + G_END_DECLS #endif /* __PANGOCORETEXT_PRIVATE_H__ */ diff --git a/pango/pangocoretext.c b/pango/pangocoretext.c index 44d2805a..e14ab16c 100644 --- a/pango/pangocoretext.c +++ b/pango/pangocoretext.c @@ -238,7 +238,7 @@ _pango_core_text_font_get_face (PangoCoreTextFont *font) { PangoCoreTextFontPrivate *priv = font->priv; - return priv->face; + return pango_core_text_font_map_find_face (PANGO_CORE_TEXT_FONT_MAP (priv->fontmap), priv->key); } gpointer |