diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-07-12 23:59:44 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-07-18 12:47:53 -0700 |
commit | b3c6ed417f7f6bf98f7114dd075818d20489622c (patch) | |
tree | bdd7064af6a5933ce28631850b8c8a9b746a74f9 /pango | |
parent | 34d65ee29a689346f8066954d66b20a94d2f20f1 (diff) | |
download | pango-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')
-rw-r--r-- | pango/fonts.c | 46 | ||||
-rw-r--r-- | pango/pango-font-private.h | 6 | ||||
-rw-r--r-- | pango/pango-font.h | 3 |
3 files changed, 49 insertions, 6 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); diff --git a/pango/pango-font-private.h b/pango/pango-font-private.h index be399d7d..029bef99 100644 --- a/pango/pango-font-private.h +++ b/pango/pango-font-private.h @@ -179,11 +179,7 @@ struct _PangoFontClass hb_feature_t *features, guint len, guint *num_features); - - /*< private >*/ - - /* Padding for future expansion */ - void (*_pango_reserved1) (void); + hb_font_t * (*create_hb_font) (PangoFont *font); }; /* used for very rare and miserable situtations that we cannot even diff --git a/pango/pango-font.h b/pango/pango-font.h index 5e49d266..cec7efc6 100644 --- a/pango/pango-font.h +++ b/pango/pango-font.h @@ -26,6 +26,7 @@ #include <pango/pango-types.h> #include <glib-object.h> +#include <hb.h> G_BEGIN_DECLS @@ -492,6 +493,8 @@ void pango_font_get_features (PangoFont *font, hb_feature_t *features, guint len, guint *num_features); +PANGO_AVAILABLE_IN_1_44 +hb_font_t * pango_font_get_hb_font (PangoFont *font); /** |