[pango/kill-ft-face: 6/17] Add api to get a hb_font_t
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/kill-ft-face: 6/17] Add api to get a hb_font_t
- Date: Sun, 14 Jul 2019 03:52:28 +0000 (UTC)
commit 0e8080639c874e0c3e22156ba93602a6c2d2fc94
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jul 12 23:59:44 2019 -0400
Add api to get a hb_font_t
Add pango_font_get_hb_font, which will make it easier
access harfbuzz features.
docs/pango-sections.txt | 1 +
pango/fonts.c | 50 +++++++++++++++++++++++++++++++++++++++++++++-
pango/pango-font-private.h | 6 +-----
pango/pango-font.h | 3 +++
4 files changed, 54 insertions(+), 6 deletions(-)
---
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt
index 9bf20619..bd2d7a13 100644
--- a/docs/pango-sections.txt
+++ b/docs/pango-sections.txt
@@ -248,6 +248,7 @@ pango_font_get_glyph_extents
pango_font_get_metrics
pango_font_get_font_map
pango_font_get_features
+pango_font_get_hb_font
<SUBSECTION>
PangoFontFamily
PANGO_TYPE_FONT_FAMILY
diff --git a/pango/fonts.c b/pango/fonts.c
index 209b6042..923763ea 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,36 @@ 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);
+
+ if (G_UNLIKELY (!font))
+ return NULL;
+
+ if (priv->hb_font)
+ return priv->hb_font;
+ else if (PANGO_FONT_GET_CLASS (font)->create_hb_font)
+ {
+ priv->hb_font = PANGO_FONT_GET_CLASS (font)->create_hb_font (font);
+ return priv->hb_font;
+ }
+
+ return NULL;
+}
+
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);
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]