浏览代码

Fix tab causing text overflow bug.

/main
Yuncong Zhang 5 年前
当前提交
39646db9
共有 2 个文件被更改,包括 15 次插入40 次删除
  1. 47
      Runtime/ui/txt/layout.cs
  2. 8
      Runtime/ui/txt/paragraph.cs

47
Runtime/ui/txt/layout.cs


float letterSpaceHalfRight = letterSpace - letterSpaceHalfLeft;
for (int i = 0; i < wordCount; i++) {
initAdvance = x;
if (advances != null) {
advances[i + layoutOffset] = letterSpaceHalfLeft + wordSpacing;
}
advances[i + layoutOffset] = letterSpaceHalfLeft + wordSpacing;
if (advances != null) {
advances[i - 1 + layoutOffset] += letterSpaceHalfRight;
advances[i + layoutOffset] = letterSpaceHalfLeft;
}
advances[i - 1 + layoutOffset] += letterSpaceHalfRight;
advances[i + layoutOffset] = letterSpaceHalfLeft;
x += letterSpace;
}

}
if (positions != null) {
positions[i + layoutOffset] = x;
}
positions[i + layoutOffset] = x;
float advance;
if (ch == '\t') {

}
x += advance;
if (advances != null) {
advances[i + layoutOffset] += advance;
}
advances[i + layoutOffset] += advance;
if (advances != null) {
advances[i + layoutOffset] += letterSpaceHalfRight;
}
advances[i + layoutOffset] += letterSpaceHalfRight;
x += letterSpaceHalfRight;
}
}

float letterSpaceHalfRight = letterSpace - letterSpaceHalfLeft;
x += letterSpaceHalfLeft;
if (advances != null) {
advances[i] = letterSpaceHalfLeft;
}
advances[i] = letterSpaceHalfLeft;
var minX = x;

_updateBounds(minX, maxX, minY, maxY, ref bounds);
if (positions != null) {
positions[i] = x;
}
positions[i] = x;
if (advances != null) {
advances[i] += advance;
advances[i] += letterSpaceHalfRight;
}
advances[i] += advance;
advances[i] += letterSpaceHalfRight;
if (advances != null) {
advances[i] = 0;
}
if (positions != null) {
positions[i] = x;
}
advances[i] = 0;
positions[i] = x;
}
}

8
Runtime/ui/txt/paragraph.cs


var offset = position.offset;
if (position.affinity == TextAffinity.upstream && offset > 0) {
offset = _isUtf16Surrogate(this._text[offset - 1]) ? offset - 2 : offset - 1;
offset = char.IsSurrogate(this._text[offset - 1]) ? offset - 2 : offset - 1;
for (int lineIndex = 0; lineIndex < this.getLineCount(); ++lineIndex) {
for (int lineIndex = 0; lineIndex < lineCount; ++lineIndex) {
var line = this._lineRanges[lineIndex];
if ((offset >= line.start && offset < line.endIncludingNewLine)) {
return lineIndex;

}
return 0;
}
static bool _isUtf16Surrogate(int value) {
return (value & 0xF800) == 0xD800;
}
}

正在加载...
取消
保存