mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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
This commit is contained in:
parent
13b22fd243
commit
faadb4243e
@ -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<hb_feature_t>* 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<hb_feature_t> 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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user