[gimp] app: undeprecate some Pango/Harfbuzz calls.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: undeprecate some Pango/Harfbuzz calls.
- Date: Sun, 15 Nov 2020 16:15:54 +0000 (UTC)
commit 7a50b0940ea8f4ea38b631cc278ca889a9689b91
Author: Jehan <jehan girinstud io>
Date: Sun Nov 15 15:45:20 2020 +0100
app: undeprecate some Pango/Harfbuzz calls.
pango_fc_font_lock_face() is deprecated since Pango 1.44.
This may hopefully also fix #5922 as I completely changed the code where
the CRITICAL happened. Yet I left g_return_val_if_fail() to check if the
Harfbuzz font and FreeType face variables are not NULL (because looking
at the code, it looks like these functions returning NULL actually means
there is a bug in the code).
Nevertheless if it turned out that there are non-bug cases where these
could return NULL (for instance a broken font file?), then probably we
should not use g_return_val_if_fail(), but instead address the data
issue in a nicer way.
Bumping harfbuzz dependency to 1.0.5 for hb_ft_font_set_funcs(). Without
configuring the Harfbuzz font with it, hb_ft_font_get_face() always
returns NULL.
Note that it looks like hb_ft_font_lock_face() would actually be better,
but this requires harfbuzz 2.6.5 from last April which is quite recent.
So let's just use the get_face() variant for now.
app/text/gimpfont.c | 26 +++++++++++++++++++++++---
configure.ac | 2 +-
2 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/app/text/gimpfont.c b/app/text/gimpfont.c
index 5d39391bd4..cb4db309fc 100644
--- a/app/text/gimpfont.c
+++ b/app/text/gimpfont.c
@@ -389,6 +389,7 @@ gimp_font_get_sample_string (PangoContext *context,
{
PangoFont *font;
hb_face_t *hb_face;
+ hb_font_t *hb_font;
FT_Face face;
TT_OS2 *os2;
PangoOTTableType tt;
@@ -672,8 +673,28 @@ gimp_font_get_sample_string (PangoContext *context,
g_return_val_if_fail (PANGO_IS_FC_FONT (font), "Aa");
- face = pango_fc_font_lock_face (PANGO_FC_FONT (font));
+ hb_font = pango_font_get_hb_font (font);
+ g_return_val_if_fail (hb_font != NULL, "Aa");
+
+ /* These are needed to set hb_font to the right internal format, which
+ * can only work if the font is not immutable. Hence we make a copy.
+ */
+ hb_font = hb_font_create_sub_font (hb_font);
+ hb_ft_font_set_funcs (hb_font);
+ /* TODO: use hb_ft_font_lock_face/hb_ft_font_unlock_face() when we
+ * bump to harfbuzz >= 2.6.5.
+ */
+ face = hb_ft_font_get_face (hb_font);
+
+ /* Are there actual cases where this function could return NULL while
+ * it's not a bug in the code?
+ * For instance if the font file is broken, we don't want to return a
+ * CRITICAL, but properly address the issue (removing the font with a
+ * warning or whatnot).
+ * See #5922.
+ */
g_return_val_if_fail (face != NULL, "Aa");
+
hb_face = hb_ft_face_create (face, NULL);
/* First check what script(s), if any, the font has GSUB or GPOS
@@ -753,8 +774,7 @@ gimp_font_get_sample_string (PangoContext *context,
}
}
- pango_fc_font_unlock_face (PANGO_FC_FONT (font));
-
+ hb_font_destroy (hb_font);
g_object_unref (font);
if (n_ot_alts > 2)
diff --git a/configure.ac b/configure.ac
index 63b85be07a..ae780a72c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,7 +68,7 @@ m4_define([glib_required_version], [2.56.2])
m4_define([gtk_mac_integration_required_version], [2.0.0])
m4_define([gtk_required_version], [3.22.29])
m4_define([gtkdoc_required_version], [1.0])
-m4_define([harfbuzz_required_version], [0.9.19])
+m4_define([harfbuzz_required_version], [1.0.5])
m4_define([intltool_required_version], [0.40.1])
m4_define([introspection_required_version], [1.32.0])
m4_define([json_glib_required_version], [1.2.6])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]