summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-12-21 07:49:45 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-12-21 07:49:45 -0500
commitc3866592cdc45877e2fa7e0181d4c83ead059842 (patch)
tree07a9ffe88f4b6aef92ae0173fd5ff543dedbaff0 /pango
parent092061db9d0bb94549e3ad44095fcaed49080c82 (diff)
downloadpango-c3866592cdc45877e2fa7e0181d4c83ead059842.tar.gz
Add a private api to get the font size
Add a private vfunc to get the (absolute) size of a font. This default implementation just pulls it out of the font description, but we can do implement this cheaper without copying the font description.
Diffstat (limited to 'pango')
-rw-r--r--pango/fonts.c14
-rw-r--r--pango/pango-font-private.h8
2 files changed, 21 insertions, 1 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index 35527e7a..2054dd31 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -1761,6 +1761,19 @@ pango_font_default_get_matrix (PangoFont *font,
*matrix = (PangoMatrix) PANGO_MATRIX_INIT;
}
+static int
+pango_font_default_get_absolute_size (PangoFont *font)
+{
+ PangoFontDescription *desc;
+ int size;
+
+ desc = pango_font_describe_with_absolute_size (font);
+ size = pango_font_description_get_size (desc);
+ pango_font_description_free (desc);
+
+ return size;
+}
+
static void
pango_font_class_init (PangoFontClass *class G_GNUC_UNUSED)
{
@@ -1777,6 +1790,7 @@ pango_font_class_init (PangoFontClass *class G_GNUC_UNUSED)
pclass->has_char = pango_font_default_has_char;
pclass->get_face = pango_font_default_get_face;
pclass->get_matrix = pango_font_default_get_matrix;
+ pclass->get_absolute_size = pango_font_default_get_absolute_size;
}
static void
diff --git a/pango/pango-font-private.h b/pango/pango-font-private.h
index 1e38371d..885e38c1 100644
--- a/pango/pango-font-private.h
+++ b/pango/pango-font-private.h
@@ -47,6 +47,7 @@ typedef struct {
PangoFontFace * (* get_face) (PangoFont *font);
void (* get_matrix) (PangoFont *font,
PangoMatrix *matrix);
+ int (* get_absolute_size) (PangoFont *font);
} PangoFontClassPrivate;
gboolean pango_font_is_hinted (PangoFont *font);
@@ -55,7 +56,12 @@ void pango_font_get_scale_factors (PangoFont *font,
double *y_scale);
void pango_font_get_matrix (PangoFont *font,
PangoMatrix *matrix);
-
+static inline int pango_font_get_absolute_size (PangoFont *font)
+{
+ GTypeClass *klass = (GTypeClass *) PANGO_FONT_GET_CLASS (font);
+ PangoFontClassPrivate *priv = g_type_class_get_private (klass, PANGO_TYPE_FONT);
+ return priv->get_absolute_size (font);
+}
G_END_DECLS