浏览代码

Refactor.

/main
Yuncong Zhang 5 年前
当前提交
dbda2e5e
共有 1 个文件被更改,包括 14 次插入25 次删除
  1. 39
      Runtime/ui/txt/paragraph.cs

39
Runtime/ui/txt/paragraph.cs


for (int lineStyleRunIndex = 0; lineStyleRunIndex < lineStyleRuns.Count; ++lineStyleRunIndex) {
glyphPositions.Clear();
var run = lineStyleRuns[lineStyleRunIndex];
var isLastLineStyleRun = lineStyleRunIndex == lineStyleRuns.Count - 1;
lineStyleRunIndex,
lineStyleRuns.Count,
isLastLineStyleRun,
lineNumber,
justifyLine,
wordGapWidth,

void _generatePaintRecordFromLineStyleRun(
LineStyleRun run,
Layout layout, TextBlobBuilder builder,
int lineStyleRunIndex,
int lineRunsCount,
bool isLastLineStyleRun,
int lineNumber,
bool justifyLine,
float wordGapWidth,

int textCount = textEnd - textStart;
bool hardBreak = this._lineRanges[lineNumber].hardBreak;
if (this._shouldConsiderEllipsis(hardBreak, lineStyleRunIndex, lineRunsCount, lineNumber, lineLimit)) {
if (this._shouldConsiderEllipsis(hardBreak, isLastLineStyleRun, lineNumber, lineLimit)) {
this._handleOverflowEllipsis(ref text, ref textStart, ref textCount, run.style, runXOffset);
if (this._paragraphStyle.maxLines == null) {
lineLimit = lineNumber + 1;

return;
}
float wordStartPosition = float.NaN;
builder.allocRunPos(run.style, text, textStart, textCount);
// bounds relative to first character
builder.setBounds(layout.getBounds().translate(-layout.getX(0), 0));

builder, layout,
glyphPositions,
words,
run,
run.start,
ref wordStartPosition,
ref maxWordWidth);
if (glyphPositions.Count == 0) {

lineGlyphPositions.AddRange(glyphPositions);
}
bool _shouldConsiderEllipsis(bool hardBreak, int lineStyleRunIndex, int lineRunsCount, int lineNumber, int lineLimit) {
bool _shouldConsiderEllipsis(bool hardBreak, bool isLastLineStyleRun, int lineNumber, int lineLimit) {
&& lineStyleRunIndex == lineRunsCount - 1 &&
(lineNumber == lineLimit - 1 || this._paragraphStyle.maxLines == null);
&& isLastLineStyleRun && (lineNumber == lineLimit - 1 || this._paragraphStyle.maxLines == null);
}
void _handleOverflowEllipsis(ref string text, ref int textStart, ref int textCount, TextStyle style, float runXOffset) {

TextBlobBuilder builder, Layout layout,
List<GlyphPosition> glyphPositions,
List<Range<int>> words,
LineStyleRun run,
int runStart,
ref float wordStartPosition,
float wordStartPosition = float.NaN;
builder.positions[glyphIndex] = new Vector2d(
glyphXOffset, layout.getY(glyphIndex)
);
builder.positions[glyphIndex] = new Vector2d(glyphXOffset, layout.getY(glyphIndex));
if (wordIndex < words.Count && words[wordIndex].start == run.start + glyphIndex) {
if (wordIndex < words.Count && words[wordIndex].start == runStart + glyphIndex) {
if (wordIndex < words.Count && words[wordIndex].end == run.start + glyphIndex + 1) {
if (wordIndex < words.Count && words[wordIndex].end == runStart + glyphIndex + 1) {
if (justifyLine) {
justifyXOffset += wordGapWidth;
}

}
}
void _generatePaintRecord(
List<PaintRecord> paintRecords,
TextStyle style,
TextBlob textBlob,
float runXOffset,
float advance) {
void _generatePaintRecord(List<PaintRecord> paintRecords, TextStyle style, TextBlob textBlob,
float runXOffset, float advance) {
var font = FontManager.instance.getOrCreate(style.fontFamily,
style.fontWeight, style.fontStyle).font;
var metrics = FontMetrics.fromFont(font, style.UnityFontSize);

正在加载...
取消
保存