summaryrefslogtreecommitdiff
path: root/pango/fonts.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-07-12 23:59:44 -0400
committerMatthias Clasen <mclasen@redhat.com>2019-07-18 12:47:53 -0700
commitb3c6ed417f7f6bf98f7114dd075818d20489622c (patch)
treebdd7064af6a5933ce28631850b8c8a9b746a74f9 /pango/fonts.c
parent34d65ee29a689346f8066954d66b20a94d2f20f1 (diff)
downloadpango-b3c6ed417f7f6bf98f7114dd075818d20489622c.tar.gz
Add api to get a hb_font_t
Add pango_font_get_hb_font, which will make it easier access harfbuzz features.
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);