summaryrefslogtreecommitdiff
path: root/pango/fonts.c
diff options
context:
space:
mode:
Diffstat (limited to 'pango/fonts.c')
-rw-r--r--pango/fonts.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index fafd6a2d..4ba9d3fe 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -1617,11 +1617,29 @@ pango_parse_stretch (const char *str,
* PangoFont
*/
-G_DEFINE_ABSTRACT_TYPE (PangoFont, pango_font, G_TYPE_OBJECT)
+typedef struct {
+ hb_font_t *hb_font;
+} PangoFontPrivate;
+
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (PangoFont, pango_font, G_TYPE_OBJECT)
+
+static void
+pango_font_finalize (GObject *object)
+{
+ PangoFont *font = PANGO_FONT (object);
+ PangoFontPrivate *priv = pango_font_get_instance_private (font);
+
+ hb_font_destroy (priv->hb_font);
+
+ G_OBJECT_CLASS (pango_font_parent_class)->finalize (object);
+}
static void
pango_font_class_init (PangoFontClass *class G_GNUC_UNUSED)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ object_class->finalize = pango_font_finalize;
}
static void
@@ -1838,6 +1856,32 @@ pango_font_get_font_map (PangoFont *font)
return NULL;
}
+/**
+ * pango_font_get_hb_font:
+ * @font: a #PangoFont
+ *
+ * Get a hb_font_t object backing this font.
+ *
+ * Returns: (transfer none) (nullable): the hb_font_t object backing the
+ * font, or %NULL if the font does not have one
+ *
+ * Since: 1.44
+ */
+hb_font_t *
+pango_font_get_hb_font (PangoFont *font)
+{
+ PangoFontPrivate *priv = pango_font_get_instance_private (font);
+
+ g_return_val_if_fail (PANGO_IS_FONT (font), NULL);
+
+ if (priv->hb_font)
+ return priv->hb_font;
+
+ priv->hb_font = PANGO_FONT_GET_CLASS (font)->create_hb_font (font);
+
+ return priv->hb_font;
+}
+
G_DEFINE_BOXED_TYPE (PangoFontMetrics, pango_font_metrics,
pango_font_metrics_ref,
pango_font_metrics_unref);