[gimp] app: Use HarfBuzz directly instead of deprecated Pango functions
- From: Mukund Sivaraman <muks src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Use HarfBuzz directly instead of deprecated Pango functions
- Date: Fri, 2 May 2014 18:58:09 +0000 (UTC)
commit 33acc4b62b60107484ae5f6f9b00f939af6a6fa0
Author: Mukund Sivaraman <muks banu com>
Date: Sat May 3 00:20:18 2014 +0530
app: Use HarfBuzz directly instead of deprecated Pango functions
I have verified manually that the previews ("Aa") shown for English and
Tamil are correct (i.e., the modified function works).
app/text/gimpfont.c | 37 ++++++++++++++++++++++++++++++++++---
1 files changed, 34 insertions(+), 3 deletions(-)
---
diff --git a/app/text/gimpfont.c b/app/text/gimpfont.c
index 66c6e52..ea55a77 100644
--- a/app/text/gimpfont.c
+++ b/app/text/gimpfont.c
@@ -26,6 +26,10 @@
#include <pango/pangocairo.h>
+#include <hb.h>
+#include <hb-ot.h>
+#include <hb-ft.h>
+
#define PANGO_ENABLE_ENGINE 1 /* Argh */
#include <pango/pango-ot.h>
@@ -350,13 +354,30 @@ gimp_font_covers_string (PangoFcFont *font,
return TRUE;
}
+/* This function was picked up from Pango's pango-ot-info.c. Until there
+ * is a better way to get the tag, we use this.
+ */
+static hb_tag_t
+get_hb_table_type (PangoOTTableType table_type)
+{
+ switch (table_type)
+ {
+ case PANGO_OT_TABLE_GSUB:
+ return HB_OT_TAG_GSUB;
+ case PANGO_OT_TABLE_GPOS:
+ return HB_OT_TAG_GPOS;
+ default:
+ return HB_TAG_NONE;
+ }
+}
+
/* Guess a suitable short sample string for the font. */
static const gchar *
gimp_font_get_sample_string (PangoContext *context,
PangoFontDescription *font_desc)
{
PangoFont *font;
- PangoOTInfo *ot_info;
+ hb_face_t *hb_face;
FT_Face face;
TT_OS2 *os2;
PangoOTTableType tt;
@@ -642,7 +663,7 @@ gimp_font_get_sample_string (PangoContext *context,
face = pango_fc_font_lock_face (PANGO_FC_FONT (font));
g_return_val_if_fail (face != NULL, "Aa");
- ot_info = pango_ot_info_get (face);
+ hb_face = hb_ft_face_create (face, NULL);
/* First check what script(s), if any, the font has GSUB or GPOS
* OpenType layout tables for.
@@ -651,7 +672,15 @@ gimp_font_get_sample_string (PangoContext *context,
n_ot_alts < G_N_ELEMENTS (ot_alts) && tt <= PANGO_OT_TABLE_GPOS;
tt++)
{
- PangoOTTag *slist = pango_ot_info_list_scripts (ot_info, tt);
+ hb_tag_t tag;
+ unsigned int count;
+ PangoOTTag *slist;
+
+ tag = get_hb_table_type(tt);
+ count = hb_ot_layout_table_get_script_tags (hb_face, tag, 0, NULL, NULL);
+ slist = g_new (PangoOTTag, count + 1);
+ hb_ot_layout_table_get_script_tags (hb_face, tag, 0, &count, slist);
+ slist[count] = 0;
if (slist)
{
@@ -687,6 +716,8 @@ gimp_font_get_sample_string (PangoContext *context,
}
}
+ hb_face_destroy (hb_face);
+
DEBUGPRINT (("; OS/2: "));
/* Next check the OS/2 table for Unicode ranges the font claims
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]