summaryrefslogtreecommitdiff
path: root/pango/fonts.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-11-01 00:03:12 +0000
committerMatthias Clasen <mclasen@redhat.com>2019-11-01 00:03:12 +0000
commitb32abe049f4c64db2a99261be0bad7ae26c0643a (patch)
tree77c512113c658d645568738684c7635c00a5bbf1 /pango/fonts.c
parent30cc5060cb76b490ebb13d2204cb044f2cb072f2 (diff)
parenta582dbbb60da8aff7574d576cc636799e89c72d8 (diff)
downloadpango-b32abe049f4c64db2a99261be0bad7ae26c0643a.tar.gz
Merge branch 'family-face-api' into 'master'
Family face api See merge request GNOME/pango!135
Diffstat (limited to 'pango/fonts.c')
-rw-r--r--pango/fonts.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index 4ffa0378..9e6325b7 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -1881,6 +1881,24 @@ pango_font_get_font_map (PangoFont *font)
}
/**
+ * pango_font_get_face:
+ * @font: a #PangoFont
+ *
+ * Gets the #PangoFontFace to which @font belongs.
+ *
+ * Returns: (transfer none): the #PangoFontFace
+ *
+ * Since: 1.46
+ */
+PangoFontFace *
+pango_font_get_face (PangoFont *font)
+{
+ PangoFontMap *map = pango_font_get_font_map (font);
+
+ return PANGO_FONT_MAP_GET_CLASS (map)->get_face (map,font);
+}
+
+/**
* pango_font_get_hb_font: (skip)
* @font: a #PangoFont
*
@@ -2160,9 +2178,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 +2234,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
@@ -2382,6 +2450,25 @@ pango_font_face_list_sizes (PangoFontFace *face,
}
/**
+ * pango_font_face_get_family:
+ * @face: a #PangoFontFace
+ *
+ * Gets the #PangoFontFamily that @face
+ * belongs to.
+ *
+ * Returns: (transfer none): the #PangoFontFamily
+ *
+ * Since: 1.46
+ */
+PangoFontFamily *
+pango_font_face_get_family (PangoFontFace *face)
+{
+ g_return_val_if_fail (PANGO_IS_FONT_FACE (face), NULL);
+
+ return PANGO_FONT_FACE_GET_CLASS (face)->get_family (face);
+}
+
+/**
* pango_font_has_char:
* @font: a #PangoFont
* @wc: a Unicode character