From 2d576f79f748ca4c9bb54634f0fd44fa207a2248 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 29 Jan 2014 17:46:47 +0200 Subject: Make HarBuzz-NG the default shaper on Mac Since we dropped all platform-related shapers during the QPA refactoring, thus making HarfBuzz the only shaper on all platforms, we can not deal with AAT-capable fonts anymore. HarBuzz-NG now supports it's own shaper backend infrastructure, so the decision was to enable HB's CoreText shaper backend on Mac and simply make HB-NG the default shaper there. Task-number: QTBUG-36056 Change-Id: If22e24fd5cc00c25952934332a2f4123f38135a4 Reviewed-by: Lars Knoll Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/3rdparty/harfbuzz-ng/src/hb-coretext.cc | 36 +++++++++++++++++++++++--- src/3rdparty/harfbuzz-ng/src/hb-coretext.h | 4 +++ src/3rdparty/harfbuzz-ng/src/hb-shaper-list.hh | 8 +++--- 3 files changed, 41 insertions(+), 7 deletions(-) (limited to 'src/3rdparty/harfbuzz-ng/src') diff --git a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc b/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc index 87dd779751..ef6798d380 100644 --- a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc +++ b/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc @@ -31,6 +31,9 @@ #include "hb-coretext.h" +#include "hb-face-private.hh" +#include + #ifndef HB_DEBUG_CORETEXT #define HB_DEBUG_CORETEXT (HB_DEBUG+0) @@ -61,10 +64,34 @@ release_data (void *info, const void *data, size_t size) hb_coretext_shaper_face_data_t * _hb_coretext_shaper_face_data_create (hb_face_t *face) { + hb_blob_t *mort_blob = face->reference_table (HB_CORETEXT_TAG_MORT); + /* Umm, we just reference the table to check whether it exists. + * Maybe add better API for this? */ + if (!hb_blob_get_length (mort_blob)) + { + hb_blob_destroy (mort_blob); + mort_blob = face->reference_table (HB_CORETEXT_TAG_MORX); + if (!hb_blob_get_length (mort_blob)) + { + hb_blob_destroy (mort_blob); + return NULL; + } + } + hb_blob_destroy (mort_blob); + hb_coretext_shaper_face_data_t *data = (hb_coretext_shaper_face_data_t *) calloc (1, sizeof (hb_coretext_shaper_face_data_t)); if (unlikely (!data)) return NULL; + QFontEngine *fe = (QFontEngine *) face->user_data; + if (fe->type () == QFontEngine::Mac) + { + data->cg_font = (CGFontRef) fe->userData ().value (); + if (likely (data->cg_font)) + CFRetain (data->cg_font); + } + else + { hb_blob_t *blob = hb_face_reference_blob (face); unsigned int blob_length; const char *blob_data = hb_blob_get_data (blob, &blob_length); @@ -74,6 +101,7 @@ _hb_coretext_shaper_face_data_create (hb_face_t *face) CGDataProviderRef provider = CGDataProviderCreateWithData (blob, blob_data, blob_length, &release_data); data->cg_font = CGFontCreateWithDataProvider (provider); CGDataProviderRelease (provider); + } if (unlikely (!data->cg_font)) { DEBUG_MSG (CORETEXT, face, "Face CGFontCreateWithDataProvider() failed"); @@ -120,7 +148,7 @@ _hb_coretext_shaper_font_data_create (hb_font_t *font) hb_face_t *face = font->face; hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); - data->ct_font = CTFontCreateWithGraphicsFont (face_data->cg_font, font->y_scale, NULL, NULL); + data->ct_font = CTFontCreateWithGraphicsFont (face_data->cg_font, font->y_scale / 64, NULL, NULL); if (unlikely (!data->ct_font)) { DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed"); free (data); @@ -691,7 +719,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan, * hb-uniscribe.cc for example. */ info->cluster = j; - info->mask = advance; + info->mask = advance * 64; info->var1.u32 = 0; info->var2.u32 = 0; @@ -747,9 +775,9 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan, info->cluster = string_indices[j]; /* Currently, we do all x-positioning by setting the advance, we never use x-offset. */ - info->mask = advance; + info->mask = advance * 64; info->var1.u32 = 0; - info->var2.u32 = positions[j].y; + info->var2.u32 = positions[j].y * 64; buffer->len++; } diff --git a/src/3rdparty/harfbuzz-ng/src/hb-coretext.h b/src/3rdparty/harfbuzz-ng/src/hb-coretext.h index c4954fa1b2..bcf1de7141 100644 --- a/src/3rdparty/harfbuzz-ng/src/hb-coretext.h +++ b/src/3rdparty/harfbuzz-ng/src/hb-coretext.h @@ -34,6 +34,10 @@ HB_BEGIN_DECLS +#define HB_CORETEXT_TAG_MORT HB_TAG('m','o','r','t') +#define HB_CORETEXT_TAG_MORX HB_TAG('m','o','r','x') + + CGFontRef hb_coretext_face_get_cg_font (hb_face_t *face); diff --git a/src/3rdparty/harfbuzz-ng/src/hb-shaper-list.hh b/src/3rdparty/harfbuzz-ng/src/hb-shaper-list.hh index da6d8e0be9..5713e057a0 100644 --- a/src/3rdparty/harfbuzz-ng/src/hb-shaper-list.hh +++ b/src/3rdparty/harfbuzz-ng/src/hb-shaper-list.hh @@ -35,6 +35,11 @@ HB_SHAPER_IMPLEMENT (graphite2) #endif +#ifdef HAVE_CORETEXT +/* Only picks up fonts that have a "mort" or "morx" table. */ +HB_SHAPER_IMPLEMENT (coretext) +#endif + #ifdef HAVE_OT HB_SHAPER_IMPLEMENT (ot) /* <--- This is our main OpenType shaper. */ #endif @@ -48,9 +53,6 @@ HB_SHAPER_IMPLEMENT (icu_le) #ifdef HAVE_UNISCRIBE HB_SHAPER_IMPLEMENT (uniscribe) #endif -#ifdef HAVE_CORETEXT -HB_SHAPER_IMPLEMENT (coretext) -#endif #ifdef HAVE_FALLBACK HB_SHAPER_IMPLEMENT (fallback) /* <--- This should be last. */ -- cgit v1.2.3