summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-08-13 23:15:00 -0400
committerMatthias Clasen <mclasen@redhat.com>2019-10-31 19:52:36 -0400
commita582dbbb60da8aff7574d576cc636799e89c72d8 (patch)
tree9091d5652eafbf00bd15a8cd62d3027a9880740f /pango
parent40a805478dfa8988315fd8b7f8515af65c3f90c7 (diff)
downloadpango-a582dbbb60da8aff7574d576cc636799e89c72d8.tar.gz
Add pango_font_get_face
Since we've run out of slots in PangoFontClass, this is implemented with a vfunc in PangoFontMapClass.
Diffstat (limited to 'pango')
-rw-r--r--pango/fonts.c18
-rw-r--r--pango/pango-font.h3
-rw-r--r--pango/pango-fontmap-private.h1
-rw-r--r--pango/pango-fontmap.c1
-rw-r--r--pango/pango-fontmap.h6
-rw-r--r--pango/pangocoretext-fontmap.c10
-rw-r--r--pango/pangofc-fontmap.c24
-rw-r--r--pango/pangowin32-fontmap.c11
8 files changed, 67 insertions, 7 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index 5c685f77..9e6325b7 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -1881,6 +1881,24 @@ pango_font_get_font_map (PangoFont *font)
}
/**
+ * pango_font_get_face:
+ * @font: a #PangoFont
+ *
+ * Gets the #PangoFontFace to which @font belongs.
+ *
+ * Returns: (transfer none): the #PangoFontFace
+ *
+ * Since: 1.46
+ */
+PangoFontFace *
+pango_font_get_face (PangoFont *font)
+{
+ PangoFontMap *map = pango_font_get_font_map (font);
+
+ return PANGO_FONT_MAP_GET_CLASS (map)->get_face (map,font);
+}
+
+/**
* pango_font_get_hb_font: (skip)
* @font: a #PangoFont
*
diff --git a/pango/pango-font.h b/pango/pango-font.h
index a456a75c..ba1ea3ae 100644
--- a/pango/pango-font.h
+++ b/pango/pango-font.h
@@ -647,6 +647,9 @@ void pango_font_get_glyph_extents (PangoFont *font,
PANGO_AVAILABLE_IN_1_10
PangoFontMap *pango_font_get_font_map (PangoFont *font);
+PANGO_AVAILABLE_IN_1_46
+PangoFontFace * pango_font_get_face (PangoFont *font);
+
PANGO_AVAILABLE_IN_1_44
gboolean pango_font_has_char (PangoFont *font,
gunichar wc);
diff --git a/pango/pango-fontmap-private.h b/pango/pango-fontmap-private.h
index 3452fbca..935fd713 100644
--- a/pango/pango-fontmap-private.h
+++ b/pango/pango-fontmap-private.h
@@ -31,7 +31,6 @@ G_BEGIN_DECLS
PANGO_DEPRECATED_IN_1_38
const char *pango_font_map_get_shape_engine_type (PangoFontMap *fontmap);
-
G_END_DECLS
#endif /* __PANGO_FONTMAP_PRIVATE_H__ */
diff --git a/pango/pango-fontmap.c b/pango/pango-fontmap.c
index 20dbc3cf..54ac5d0d 100644
--- a/pango/pango-fontmap.c
+++ b/pango/pango-fontmap.c
@@ -390,4 +390,3 @@ pango_font_map_get_family (PangoFontMap *fontmap,
return PANGO_FONT_MAP_GET_CLASS (fontmap)->get_family (fontmap, name);
}
-
diff --git a/pango/pango-fontmap.h b/pango/pango-fontmap.h
index 42ffc2ff..f30780ee 100644
--- a/pango/pango-fontmap.h
+++ b/pango/pango-fontmap.h
@@ -117,10 +117,8 @@ struct _PangoFontMapClass
PangoFontFamily * (*get_family) (PangoFontMap *fontmap,
const char *name);
- /*< private >*/
-
- /* Padding for future expansion */
- void (*_pango_reserved1) (void);
+ PangoFontFace * (*get_face) (PangoFontMap *fontmap,
+ PangoFont *font);
};
PANGO_AVAILABLE_IN_ALL
diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c
index b3d9d71c..5a81e388 100644
--- a/pango/pangocoretext-fontmap.c
+++ b/pango/pangocoretext-fontmap.c
@@ -1511,6 +1511,15 @@ pango_core_text_font_map_init (PangoCoreTextFontMap *ctfontmap)
}
}
+static PangoFontFace *
+pango_core_text_font_map_get_face (PangoFontMap *fontmap,
+ PangoFont *font)
+{
+ PangoCoreTextFont *cfont = PANGO_CORE_TEXT_FONT (font);
+
+ return PANGO_FONT_FACE (_pango_core_text_font_get_face (cfont));
+}
+
static void
pango_core_text_font_map_class_init (PangoCoreTextFontMapClass *class)
{
@@ -1525,6 +1534,7 @@ pango_core_text_font_map_class_init (PangoCoreTextFontMapClass *class)
fontmap_class->shape_engine_type = PANGO_RENDER_TYPE_CORE_TEXT;
fontmap_class->get_serial = pango_core_text_font_map_get_serial;
fontmap_class->changed = pango_core_text_font_map_changed;
+ fontmap_class->get_face = pango_core_text_font_map_get_face;
}
/*
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index dd066cd3..03d508dd 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -228,6 +228,9 @@ static PangoFont *pango_fc_font_map_new_font (PangoFcFontMap *fontmap,
PangoFcFontsetKey *fontset_key,
FcPattern *match);
+static PangoFontFace *pango_fc_font_map_get_face (PangoFontMap *fontmap,
+ PangoFont *font);
+
static guint pango_fc_font_face_data_hash (PangoFcFontFaceData *key);
static gboolean pango_fc_font_face_data_equal (PangoFcFontFaceData *key1,
PangoFcFontFaceData *key2);
@@ -1193,6 +1196,7 @@ pango_fc_font_map_class_init (PangoFcFontMapClass *class)
fontmap_class->load_fontset = pango_fc_font_map_load_fontset;
fontmap_class->list_families = pango_fc_font_map_list_families;
fontmap_class->get_family = pango_fc_font_map_get_family;
+ fontmap_class->get_face = pango_fc_font_map_get_face;
fontmap_class->shape_engine_type = PANGO_RENDER_TYPE_FC;
}
@@ -1709,6 +1713,26 @@ pango_fc_font_map_new_font (PangoFcFontMap *fcfontmap,
return (PangoFont *)fcfont;
}
+static PangoFontFace *
+pango_fc_font_map_get_face (PangoFontMap *fontmap,
+ PangoFont *font)
+{
+ PangoFcFont *fcfont = PANGO_FC_FONT (font);
+ FcResult res;
+ const char *s;
+ PangoFontFamily *family;
+
+ res = FcPatternGetString (fcfont->font_pattern, FC_FAMILY, 0, (FcChar8 **) &s);
+ g_assert (res == FcResultMatch);
+
+ family = pango_font_map_get_family (fontmap, s);
+
+ res = FcPatternGetString (fcfont->font_pattern, FC_STYLE, 0, (FcChar8 **)(void*)&s);
+ g_assert (res == FcResultMatch);
+
+ return pango_font_family_get_face (family, s);
+}
+
static void
pango_fc_default_substitute (PangoFcFontMap *fontmap,
PangoFcFontsetKey *fontsetkey,
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c
index ccdd69bd..905fdee2 100644
--- a/pango/pangowin32-fontmap.c
+++ b/pango/pangowin32-fontmap.c
@@ -764,7 +764,6 @@ pango_win32_font_map_fontset_add_fonts (PangoFontMap *fontmap,
PangoWin32FontMap *win32fontmap = PANGO_WIN32_FONT_MAP (fontmap);
lookup_aliases (win32fontmap->aliases, family, &aliases, &n_aliases);
-
if (n_aliases)
{
for (j = 0; j < n_aliases; j++)
@@ -784,6 +783,15 @@ pango_win32_font_map_fontset_add_fonts (PangoFontMap *fontmap,
}
}
+static PangoFontFace *
+pango_win32_font_map_get_face (PangoFontMap *fontmap,
+ PangoFont *font)
+{
+ PangoWin32Font *win32font = PANGO_WIN32_FONT (font);
+
+ return PANGO_FONT_FACE (win32font->win32face);
+}
+
static void
_pango_win32_font_map_class_init (PangoWin32FontMapClass *class)
{
@@ -797,6 +805,7 @@ _pango_win32_font_map_class_init (PangoWin32FontMapClass *class)
fontmap_class->load_fontset = pango_win32_font_map_load_fontset;
fontmap_class->list_families = pango_win32_font_map_list_families;
fontmap_class->shape_engine_type = PANGO_RENDER_TYPE_WIN32;
+ fontmap_class->get_face = pango_win32_font_map_get_face;
pango_win32_get_dc ();
}