提交 3e0fc64d 编写于 作者: R Raph Levien

Allow clusters to start with zero-width characters

The logic in getRunAdvance() assumed that any zero-width character was
part of the preceding cluster, which is valid most of the time. However,
characters such as ZWNBSP (U+FEFF) renders as a zero width glyph
and is also a grapheme cluster boundary. This patch adds a clause to
handle that case.

Bug: 22121742
Change-Id: Iad79a7d988bded1ef05f0fd7905d20669ea22051
上级 91425f05
......@@ -41,7 +41,8 @@ static float getRunAdvance(Layout& layout, const uint16_t* buf, size_t layoutSta
clusterWidth = charAdvance;
}
}
if (offset < start + count && layout.getCharAdvance(offset - layoutStart) == 0.0f) {
if (offset < start + count && layout.getCharAdvance(offset - layoutStart) == 0.0f &&
!GraphemeBreak::isGraphemeBreak(buf, start, count, offset)) {
// In the middle of a cluster, distribute width of cluster so that each grapheme cluster
// gets an equal share.
// TODO: get caret information out of font when that's available
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册