浏览代码

Change text buffs to string.

/main
Yuncong Zhang 5 年前
当前提交
8e452f4d
共有 2 个文件被更改,包括 11 次插入10 次删除
  1. 13
      Runtime/ui/txt/layout.cs
  2. 8
      Runtime/ui/txt/layout_utils.cs

13
Runtime/ui/txt/layout.cs


// : LayoutUtils.getPrevWordBreakForCache(buff, start + 1);
int wordend;
for (int iter = start; iter < start + count; iter = wordend) {
wordend = LayoutUtils.getNextWordBreak(buff, iter, start + count);
advance = _layoutWord(offset, iter - start, buff, iter, wordend - iter,
style, font, advances, positions, advanceOffset, advance, tabStops);
wordend = LayoutUtils.getNextWordBreak(buff.text, buff.offset + iter, start + count);
advance = _layoutWord(offset, iter - start, buff.text, iter + buff.offset,
wordend - iter, style, font, advances, positions, advanceOffset, advance,
tabStops);
}
}

static float _layoutWord(float offset, int layoutOffset,
TextBuff buff, int start, int wordCount, TextStyle style, Font font, float[] advances,
string text, int start, int wordCount, TextStyle style, Font font, float[] advances,
wordCount == 1 && LayoutUtils.isWordSpace(buff.charAt(start)) ? style.wordSpacing : 0;
wordCount == 1 && LayoutUtils.isWordSpace(text[start]) ? style.wordSpacing : 0;
float x = initAdvance;
float letterSpace = style.letterSpacing;

for (int i = 0; i < wordCount; i++) {
var ch = buff.charAt(start + i);
var ch = text[start + i];
if (i == 0) {
x += letterSpaceHalfLeft + wordSpacing;
if (advances != null) {

8
Runtime/ui/txt/layout_utils.cs


}
public static int getNextWordBreak(TextBuff buff, int offset, int maxOffset) {
int len = buff.size;
public static int getNextWordBreak(string text, int offset, int maxOffset) {
int len = text.Length;
if (len > maxOffset) {
len = maxOffset + 1;
}

}
if (isWordBreakAfter(buff.charAt(offset))) {
if (isWordBreakAfter(text[offset])) {
if (isWordBreakBefore(buff.charAt(i))) {
if (isWordBreakBefore(text[i])) {
return i;
}
}

正在加载...
取消
保存