summaryrefslogtreecommitdiff
path: root/pango/pango-fontmap.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-08-13 22:18:32 -0400
committerMatthias Clasen <mclasen@redhat.com>2019-10-31 19:52:03 -0400
commite1b05c6e7327e83eccffd64b4bf515220a5183ca (patch)
tree15f12ee1934d2f7126f2a207ac8163c25239ed77 /pango/pango-fontmap.c
parent5ed6d2589f8c553bfdfff080b8bea5c90bfefad6 (diff)
downloadpango-e1b05c6e7327e83eccffd64b4bf515220a5183ca.tar.gz
Add pango_font_map_get_family
This lets us get a PangoFontFamily by name.
Diffstat (limited to 'pango/pango-fontmap.c')
-rw-r--r--pango/pango-fontmap.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/pango/pango-fontmap.c b/pango/pango-fontmap.c
index 46054ec1..20dbc3cf 100644
--- a/pango/pango-fontmap.c
+++ b/pango/pango-fontmap.c
@@ -31,12 +31,16 @@ static PangoFontset *pango_font_map_real_load_fontset (PangoFontMap
PangoLanguage *language);
+static PangoFontFamily *pango_font_map_real_get_family (PangoFontMap *fontmap,
+ const char *name);
+
G_DEFINE_ABSTRACT_TYPE (PangoFontMap, pango_font_map, G_TYPE_OBJECT)
static void
pango_font_map_class_init (PangoFontMapClass *class)
{
class->load_fontset = pango_font_map_real_load_fontset;
+ class->get_family = pango_font_map_real_get_family;
}
static void
@@ -339,3 +343,51 @@ pango_font_map_changed (PangoFontMap *fontmap)
if (PANGO_FONT_MAP_GET_CLASS (fontmap)->changed)
PANGO_FONT_MAP_GET_CLASS (fontmap)->changed (fontmap);
}
+
+static PangoFontFamily *
+pango_font_map_real_get_family (PangoFontMap *fontmap,
+ const char *name)
+{
+ PangoFontFamily **families;
+ int n_families;
+ PangoFontFamily *family;
+ int i;
+
+ pango_font_map_list_families (fontmap, &families, &n_families);
+
+ family = NULL;
+
+ for (i = 0; i < n_families; i++)
+ {
+ if (strcmp (name, pango_font_family_get_name (families[i])) == 0)
+ {
+ family = families[i];
+ break;
+ }
+ }
+
+ g_free (families);
+
+ return family;
+}
+
+/**
+ * pango_font_map_get_family:
+ * @fontmap: a #PangoFontMap
+ * @name: a family name
+ *
+ * Gets a font family by name.
+ *
+ * Returns: (transfer none): the #PangoFontFamily
+ *
+ * Since: 1.46
+ */
+PangoFontFamily *
+pango_font_map_get_family (PangoFontMap *fontmap,
+ const char *name)
+{
+ g_return_val_if_fail (PANGO_IS_FONT_MAP (fontmap), NULL);
+
+ return PANGO_FONT_MAP_GET_CLASS (fontmap)->get_family (fontmap, name);
+}
+