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/fonts.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/fonts.c')
-rw-r--r-- | pango/fonts.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/pango/fonts.c b/pango/fonts.c index 4ffa0378..eaff2378 100644 --- a/pango/fonts.c +++ b/pango/fonts.c @@ -2160,9 +2160,13 @@ pango_font_metrics_get_strikethrough_thickness (PangoFontMetrics *metrics) G_DEFINE_ABSTRACT_TYPE (PangoFontFamily, pango_font_family, G_TYPE_OBJECT) +static PangoFontFace *pango_font_family_real_get_face (PangoFontFamily *family, + const char *name); + static void pango_font_family_class_init (PangoFontFamilyClass *class G_GNUC_UNUSED) { + class->get_face = pango_font_family_real_get_face; } static void @@ -2212,6 +2216,52 @@ pango_font_family_list_faces (PangoFontFamily *family, PANGO_FONT_FAMILY_GET_CLASS (family)->list_faces (family, faces, n_faces); } +static PangoFontFace * +pango_font_family_real_get_face (PangoFontFamily *family, + const char *name) +{ + PangoFontFace **faces; + int n_faces; + PangoFontFace *face; + int i; + + pango_font_family_list_faces (family, &faces, &n_faces); + + face = NULL; + for (i = 0; i < n_faces; i++) + { + if (strcmp (name, pango_font_face_get_face_name (faces[i])) == 0) + { + face = faces[i]; + break; + } + } + + g_free (faces); + + return face; +} + +/** + * pango_font_family_get_face: + * @family: a #PangoFontFamily + * @name: the name of a face + * + * Gets the #PangoFontFace of @family with the given name. + * + * Returns: (transfer none): the #PangoFontFace + * + * Since: 1.46 + */ +PangoFontFace * +pango_font_family_get_face (PangoFontFamily *family, + const char *name) +{ + g_return_val_if_fail (PANGO_IS_FONT_FAMILY (family), NULL); + + return PANGO_FONT_FAMILY_GET_CLASS (family)->get_face (family, name); +} + /** * pango_font_family_is_monospace: * @family: a #PangoFontFamily |