|
|
|
|
|
|
int textCount = textEnd - textStart; |
|
|
|
// Keep track of the pointer to _glyphPositions in the start of this run
|
|
|
|
int glyphPositionStyleRunStart = pGlyphPositions; |
|
|
|
Font font = FontManager.instance.getOrCreate( |
|
|
|
style.fontFamily, |
|
|
|
style.fontWeight, |
|
|
|
style.fontStyle).font; |
|
|
|
|
|
|
|
// Ellipsize the text if ellipsis string is set, and this is the last lineStyleRun of
|
|
|
|
// the current line, and this is the last line or max line is not set
|
|
|
|
|
|
|
font.RequestCharactersInTextureSafe(ellipsis, style.UnityFontSize, style.UnityFontStyle); |
|
|
|
float ellipsisWidth = Layout.measureText(ellipsis, style); |
|
|
|
|
|
|
|
// Find the minimum number of characters to truncate, so that the truncated text
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Create paint record
|
|
|
|
var font = FontManager.instance.getOrCreate(style.fontFamily, |
|
|
|
style.fontWeight, style.fontStyle).font; |
|
|
|
var metrics = FontMetrics.fromFont(font, style.UnityFontSize); |
|
|
|
PaintRecord paintRecord = new PaintRecord(style, runXOffset, 0, builder.make(), |
|
|
|
metrics, advance); |
|
|
|
|
|
|
return nextLineStart - lineStart; |
|
|
|
} |
|
|
|
|
|
|
|
internal void setText(string text, StyledRuns runs, bool skipRequestCharacters = false) { |
|
|
|
if (text == null || text.isEmpty()) { |
|
|
|
this.clear(); |
|
|
|
this._text = text; |
|
|
|
this._runs = runs; |
|
|
|
this._needsLayout = false; |
|
|
|
return; |
|
|
|
} |
|
|
|
internal void setText(string text, StyledRuns runs) { |
|
|
|
if (!skipRequestCharacters) { |
|
|
|
for (int i = 0; i < runs.size; i++) { |
|
|
|
var run = runs.getRun(i); |
|
|
|
var style = run.style; |
|
|
|
var font = FontManager.instance.getOrCreate(style.fontFamily, style.fontWeight, style.fontStyle).font; |
|
|
|
font.RequestCharactersInTextureSafe(text.Substring(run.start, run.end - run.start), |
|
|
|
style.UnityFontSize, style.UnityFontStyle); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void setParagraphStyle(ParagraphStyle style) { |
|
|
|