From faadb4243eef234e41d8ab21a7e80a5794d76579 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Sat, 7 Jun 2014 08:14:07 -0700 Subject: [PATCH] Provisionally enable "palt" OpenType feature We want to test configurations where the Noto Japanese font will have its "palt" feature (to select tighter spacing in kana) will be enabled for framework but not WebView or Chrome rendering of Japanese text. This patch simply hardcodes this feature on. This is also a first step towards more general setting of OpenType features. The hardcoded feature list will grow into one set by parameters which will eventually be plumbed up to Java. Change-Id: Ie284e0487a1434155c8ac1cb68ddc4fc4b3c018a --- engine/src/flutter/libs/minikin/Layout.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/libs/minikin/Layout.cpp b/engine/src/flutter/libs/minikin/Layout.cpp index 3cab6735774..2fdf853696d 100644 --- a/engine/src/flutter/libs/minikin/Layout.cpp +++ b/engine/src/flutter/libs/minikin/Layout.cpp @@ -618,6 +618,12 @@ void Layout::doLayoutWord(const uint16_t* buf, size_t start, size_t count, size_ cache.mCache.put(key, value); } +static void addFeatures(vector* features) { + // hardcoded features, to be repaced with more flexible configuration + static hb_feature_t palt = { HB_TAG('p', 'a', 'l', 't'), 1, 0, ~0u }; + features->push_back(palt); +} + void Layout::doLayoutRun(const uint16_t* buf, size_t start, size_t count, size_t bufSize, bool isRtl, LayoutContext* ctx) { hb_buffer_t* buffer = LayoutEngine::getInstance().hbBuffer; @@ -627,6 +633,9 @@ void Layout::doLayoutRun(const uint16_t* buf, size_t start, size_t count, size_t std::reverse(items.begin(), items.end()); } + vector features; + addFeatures(&features); + float x = mAdvance; float y = 0; for (size_t run_ix = 0; run_ix < items.size(); run_ix++) { @@ -663,7 +672,7 @@ void Layout::doLayoutRun(const uint16_t* buf, size_t start, size_t count, size_t hb_buffer_set_language(buffer, hb_language_from_string(lang.c_str(), -1)); } hb_buffer_add_utf16(buffer, buf, bufSize, srunstart + start, srunend - srunstart); - hb_shape(hbFont, buffer, NULL, 0); + hb_shape(hbFont, buffer, features.empty() ? NULL : &features[0], features.size()); unsigned int numGlyphs; hb_glyph_info_t* info = hb_buffer_get_glyph_infos(buffer, &numGlyphs); hb_glyph_position_t* positions = hb_buffer_get_glyph_positions(buffer, NULL);