diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-08-13 22:36:01 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-10-31 19:52:36 -0400 |
commit | 044d31030af43722e79c582fc3c4d3e4ace9d9a3 (patch) | |
tree | 77fb9731cdad54cefb60ff8409a712067ea6176e /pango/pangofc-fontmap.c | |
parent | e1b05c6e7327e83eccffd64b4bf515220a5183ca (diff) | |
download | pango-044d31030af43722e79c582fc3c4d3e4ace9d9a3.tar.gz |
Add pango_font_family_get_face
This lets us get a face by name.
Diffstat (limited to 'pango/pangofc-fontmap.c')
-rw-r--r-- | pango/pangofc-fontmap.c | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index 8b49bdce..aa8012f8 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -2583,20 +2583,10 @@ create_face (PangoFcFamily *fcfamily, } static void -pango_fc_family_list_faces (PangoFontFamily *family, - PangoFontFace ***faces, - int *n_faces) +ensure_faces (PangoFcFamily *fcfamily) { - PangoFcFamily *fcfamily = PANGO_FC_FAMILY (family); PangoFcFontMap *fcfontmap = fcfamily->fontmap; - PangoFcFontMapPrivate *priv; - - *faces = NULL; - *n_faces = 0; - if (G_UNLIKELY (!fcfontmap)) - return; - - priv = fcfontmap->priv; + PangoFcFontMapPrivate *priv = fcfontmap->priv; if (fcfamily->n_faces < 0) { @@ -2705,6 +2695,22 @@ pango_fc_family_list_faces (PangoFontFamily *family, fcfamily->faces = faces; } } +} + +static void +pango_fc_family_list_faces (PangoFontFamily *family, + PangoFontFace ***faces, + int *n_faces) +{ + PangoFcFamily *fcfamily = PANGO_FC_FAMILY (family); + + *faces = NULL; + *n_faces = 0; + + if (G_UNLIKELY (!fcfamily->fontmap)) + return; + + ensure_faces (fcfamily); if (n_faces) *n_faces = fcfamily->n_faces; @@ -2713,6 +2719,26 @@ pango_fc_family_list_faces (PangoFontFamily *family, *faces = g_memdup (fcfamily->faces, fcfamily->n_faces * sizeof (PangoFontFace *)); } +static PangoFontFace * +pango_fc_family_get_face (PangoFontFamily *family, + const char *name) +{ + PangoFcFamily *fcfamily = PANGO_FC_FAMILY (family); + int i; + + ensure_faces (fcfamily); + + for (i = 0; i < fcfamily->n_faces; i++) + { + PangoFontFace *face = PANGO_FONT_FACE (fcfamily->faces[i]); + + if (strcmp (name, pango_font_face_get_face_name (face)) == 0) + return face; + } + + return NULL; +} + static const char * pango_fc_family_get_name (PangoFontFamily *family) { @@ -2766,6 +2792,7 @@ pango_fc_family_class_init (PangoFcFamilyClass *class) object_class->finalize = pango_fc_family_finalize; class->list_faces = pango_fc_family_list_faces; + class->get_face = pango_fc_family_get_face; class->get_name = pango_fc_family_get_name; class->is_monospace = pango_fc_family_is_monospace; class->is_variable = pango_fc_family_is_variable; |