diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2016-10-06 04:15:41 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2016-10-20 16:57:23 +0200 |
commit | 7854d35cd8172b201f1f3ad247860f242e5cb06b (patch) | |
tree | 16e92375c3c657c0d641b9a947cbfbfafea85fcc /vcl/source | |
parent | 22a2fa4633cc36762f9300f05fb51e1dc4a705a8 (diff) |
Use HarfBuzz shape plan for a bit more control
This way we control exactly what shapers we use in what order, and as an
extra we can now tell which shaper HarfBuzz ends up using.
Change-Id: Idd303b2a557e16ac86ada0c2006d3e2a052ac489
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/gdi/CommonSalLayout.cxx | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 527d827dadf8..b8f18c4416a4 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -397,6 +397,7 @@ static int GetVerticalFlagsForScript(UScriptCode aScript) bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs) { + hb_face_t* pHbFace = hb_font_get_face(mpHbFont); hb_script_t aHbScript = HB_SCRIPT_INVALID; int nGlyphCapacity = 2 * (rArgs.mnEndCharPos - rArgs.mnMinCharPos); @@ -496,7 +497,18 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs) #if HB_VERSION_ATLEAST(0, 9, 42) hb_buffer_set_cluster_level(pHbBuffer, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS); #endif - hb_shape(mpHbFont, pHbBuffer, maFeatures.data(), maFeatures.size()); + // The shapers that we want HarfBuzz to use, in the order of + // preference. The coretext_aat shaper is available only on macOS, + // but there is no harm in always including it, HarfBuzz will + // ignore unavailable shapers. + const char* pHbShapers[] = { "coretext_aat", "graphite2", "ot", "fallback", nullptr }; + hb_segment_properties_t aHbProps; + hb_buffer_get_segment_properties(pHbBuffer, &aHbProps); + hb_shape_plan_t* pHbPlan = hb_shape_plan_create_cached(pHbFace, &aHbProps, maFeatures.data(), maFeatures.size(), pHbShapers); + bool ok = hb_shape_plan_execute(pHbPlan, mpHbFont, pHbBuffer, maFeatures.data(), maFeatures.size()); + assert(ok); + (void) ok; + SAL_INFO("vcl.harfbuzz", hb_shape_plan_get_shaper(pHbPlan) << " shaper used for " << mrFontSelData.GetFamilyName()); int nRunGlyphCount = hb_buffer_get_length(pHbBuffer); hb_glyph_info_t *pHbGlyphInfos = hb_buffer_get_glyph_infos(pHbBuffer, nullptr); @@ -529,7 +541,6 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs) nGlyphFlags |= GlyphItem::IS_IN_CLUSTER; bool bDiacritic = false; - hb_face_t* pHbFace = hb_font_get_face(mpHbFont); if (hb_ot_layout_has_glyph_classes(pHbFace)) { // the font has GDEF table |