diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-07-18 23:17:32 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-07-18 23:17:32 +0000 |
commit | fdd9e9e707e42131e7749d8674c59f57e0923a35 (patch) | |
tree | 736a19c4682b2de18cdc6f96feaa14cd3258cf7f /pango/fonts.c | |
parent | be4d29953196744ab87b7e27be21a60131b109d1 (diff) | |
parent | 2a08070eb8db3132bea4c3d2ecd49e40c293e1a5 (diff) | |
download | pango-fdd9e9e707e42131e7749d8674c59f57e0923a35.tar.gz |
Merge branch 'kill-ft-face' into 'master'
Use harfbuzz for font metrics and glyph lookup
See merge request GNOME/pango!58
Diffstat (limited to 'pango/fonts.c')
-rw-r--r-- | pango/fonts.c | 46 |
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); |