[pango/private-vfuncs: 4/5] Add pango_font_get_languages
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/private-vfuncs: 4/5] Add pango_font_get_languages
- Date: Sat, 31 Jul 2021 18:54:24 +0000 (UTC)
commit 3555527ce39359e19594fc23c825e17f483f824e
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jul 31 13:05:31 2021 -0400
Add pango_font_get_languages
Start using private vfuncs for PangoFont, and use it
to replace the recently introduced pango_fc_font_get_languages
with a frontend api.
pango/fonts.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
pango/pango-font-private.h | 4 ++++
pango/pango-font.h | 3 +++
pango/pangofc-font.c | 19 +++++++++++++++++--
pango/pangofc-font.h | 3 ++-
5 files changed, 69 insertions(+), 4 deletions(-)
---
diff --git a/pango/fonts.c b/pango/fonts.c
index 79cf1251..27a973f8 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -1688,7 +1688,13 @@ typedef struct {
hb_font_t *hb_font;
} PangoFontPrivate;
-G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (PangoFont, pango_font, G_TYPE_OBJECT)
+#define PANGO_FONT_GET_CLASS_PRIVATE(font) ((PangoFontClassPrivate *) \
+ g_type_class_get_private ((GTypeClass *) PANGO_FONT_GET_CLASS (font), \
+ PANGO_TYPE_FONT))
+
+G_DEFINE_ABSTRACT_TYPE_WITH_CODE (PangoFont, pango_font, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (PangoFont)
+ g_type_add_class_private (g_define_type_id, sizeof
(PangoFontClassPrivate)))
static void
pango_font_finalize (GObject *object)
@@ -1701,12 +1707,22 @@ pango_font_finalize (GObject *object)
G_OBJECT_CLASS (pango_font_parent_class)->finalize (object);
}
+static PangoLanguage **
+pango_font_default_get_languages (PangoFont *font)
+{
+ return NULL;
+}
+
static void
pango_font_class_init (PangoFontClass *class G_GNUC_UNUSED)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = pango_font_finalize;
+
+ pclass = g_type_class_get_private ((GTypeClass *) class, PANGO_TYPE_FONT);
+
+ pclass->get_languages = pango_font_default_get_languages;
}
static void
@@ -2625,3 +2641,29 @@ pango_font_get_features (PangoFont *font,
if (PANGO_FONT_GET_CLASS (font)->get_features)
PANGO_FONT_GET_CLASS (font)->get_features (font, features, len, num_features);
}
+
+/**
+ * pango_font_get_languages:
+ * @font: a `PangoFont`
+ *
+ * Returns the languages that are supported by @font.
+ *
+ * If the font backend does not provide this information,
+ * %NULL is returned. For the fontconfig backend, this
+ * corresponds to the FC_LANG member of the FcPattern.
+ *
+ * The returned array is only valid as long as the font
+ * and its fontmap are valid.
+ *
+ * Returns: (transfer none) (nullable): a %NULL-terminated
+ * array of `PangoLanguage`*
+ *
+ * Since: 1.50
+ */
+PangoLanguage **
+pango_font_get_languages (PangoFont *font)
+{
+ PangoFontClassPrivate *pclass = PANGO_FONT_GET_CLASS_PRIVATE (font);
+
+ return pclass->get_languages (font);
+}
diff --git a/pango/pango-font-private.h b/pango/pango-font-private.h
index befa1b94..54de2c01 100644
--- a/pango/pango-font-private.h
+++ b/pango/pango-font-private.h
@@ -33,6 +33,10 @@ G_BEGIN_DECLS
PANGO_AVAILABLE_IN_ALL
PangoFontMetrics *pango_font_metrics_new (void);
+typedef struct {
+ PangoLanguage ** (* get_languages) (PangoFont *font);
+} PangoFontClassPrivate;
+
G_END_DECLS
#endif /* __PANGO_FONT_PRIVATE_H__ */
diff --git a/pango/pango-font.h b/pango/pango-font.h
index 13f8a222..498338b2 100644
--- a/pango/pango-font.h
+++ b/pango/pango-font.h
@@ -601,6 +601,9 @@ void pango_font_get_features (PangoFont *font,
PANGO_AVAILABLE_IN_1_44
hb_font_t * pango_font_get_hb_font (PangoFont *font);
+PANGO_AVAILABLE_IN_1_50
+PangoLanguage ** pango_font_get_languages (PangoFont *font);
+
/**
* PANGO_GLYPH_EMPTY:
*
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index cd063854..2546e663 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -21,6 +21,7 @@
#include "config.h"
+#include "pango-font-private.h"
#include "pangofc-font-private.h"
#include "pangofc-fontmap.h"
#include "pangofc-private.h"
@@ -69,6 +70,7 @@ static void pango_fc_font_get_features (PangoFont *font,
guint len,
guint *num_features);
static hb_font_t * pango_fc_font_create_hb_font (PangoFont *font);
+static PangoLanguage ** _pango_fc_font_get_languages (PangoFont *font);
#define PANGO_FC_FONT_LOCK_FACE(font) (PANGO_FC_FONT_GET_CLASS (font)->lock_face (font))
#define PANGO_FC_FONT_UNLOCK_FACE(font) (PANGO_FC_FONT_GET_CLASS (font)->unlock_face (font))
@@ -81,6 +83,7 @@ pango_fc_font_class_init (PangoFcFontClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
PangoFontClass *font_class = PANGO_FONT_CLASS (class);
+ PangoFontClassPrivate *pclass;
class->has_char = pango_fc_font_real_has_char;
class->get_glyph = pango_fc_font_real_get_glyph;
@@ -98,6 +101,10 @@ pango_fc_font_class_init (PangoFcFontClass *class)
font_class->create_hb_font = pango_fc_font_create_hb_font;
font_class->get_features = pango_fc_font_get_features;
+ pclass = g_type_class_get_private ((GTypeClass *) class, PANGO_TYPE_FONT);
+
+ pclass->get_languages = _pango_fc_font_get_languages;
+
/**
* PangoFcFont:pattern:
*
@@ -1046,18 +1053,26 @@ done:
* array of `PangoLanguage`*
*
* Since: 1.48
+ * Deprecated: 1.50: Use pango_font_get_language()
*/
PangoLanguage **
pango_fc_font_get_languages (PangoFcFont *font)
{
+ return pango_font_get_languages (PANGO_FONT (font));
+}
+
+static PangoLanguage **
+_pango_fc_font_get_languages (PangoFont *font)
+{
+ PangoFcFont * fcfont = PANGO_FC_FONT (font);
PangoFcFontMap *fontmap;
PangoLanguage **languages;
- fontmap = g_weak_ref_get ((GWeakRef *) &font->fontmap);
+ fontmap = g_weak_ref_get ((GWeakRef *) &fcfont->fontmap);
if (!fontmap)
return NULL;
- languages = _pango_fc_font_map_get_languages (fontmap, font);
+ languages = _pango_fc_font_map_get_languages (fontmap, fcfont);
g_object_unref (fontmap);
return languages;
diff --git a/pango/pangofc-font.h b/pango/pangofc-font.h
index b4aa399e..89b0cc79 100644
--- a/pango/pangofc-font.h
+++ b/pango/pangofc-font.h
@@ -95,7 +95,8 @@ gboolean pango_fc_font_has_char (PangoFcFont *font,
PANGO_AVAILABLE_IN_1_4
guint pango_fc_font_get_glyph (PangoFcFont *font,
gunichar wc);
-PANGO_AVAILABLE_IN_1_48
+
+PANGO_DEPRECATED_IN_1_50_FOR(pango_font_get_language)
PangoLanguage **
pango_fc_font_get_languages (PangoFcFont *font);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]