浏览代码

Skip RequestCharactersInTexture in doLayout.

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

10
Runtime/ui/txt/layout.cs


advances, positions, advanceOffset, advance);
}
else {
font.RequestCharactersInTextureSafe(buff.text, style.UnityFontSize, style.UnityFontStyle);
// According to the logic of Paragraph.layout, it is assured that all the characters are requested
// in the texture before (in computing line breaks), so skip it here for optimization
// The only exception is the ellipsis, which is dealt with somewhere else.
// font.RequestCharactersInTextureSafe(buff.text, style.UnityFontSize, style.UnityFontStyle);
int wordstart = start == buff.size
? start

}
return x;
}
public static void requireEllipsisInTexture(string text, TextStyle style) {
Font font = FontManager.instance.getOrCreate(style.fontFamily, style.fontWeight, style.fontStyle).font;
font.RequestCharactersInTextureSafe(text, style.UnityFontSize, style.UnityFontStyle);
}
public void setTabStops(TabStops tabStops) {

6
Runtime/ui/txt/paragraph.cs


if (!string.IsNullOrEmpty(ellipsis) && !this._width.isInfinite() && !lineRange.hardBreak
&& i == lineRuns.Count - 1 &&
(lineNumber == lineLimit - 1 || this._paragraphStyle.maxLines == null)) {
// By now, all characters have been "RequestCharactersInTexture"d by computeLineBreaks
// except the ellipsis, so Layout.doLayout skips calling RequestCharactersInTexture for
// performance, and the ellipsis is handled here
Layout.requireEllipsisInTexture(ellipsis, run.style);
float ellipsisWidth = Layout.measureText(runXOffset, ellipsisTextBuff, 0,
ellipsis.Length, run.style, null, 0, this._tabStops);
textAdvances.reset(textCount);

正在加载...
取消
保存