Package icyllis.modernui.graphics.text
Class MeasuredText
java.lang.Object
icyllis.modernui.graphics.text.MeasuredText
Text shaping result object for multi-style text, so there are multiple style runs
of positioned glyphs.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
For creating a MeasuredText.static class
static class
A logical run, subrange of bidi run.static class
-
Method Summary
Modifier and TypeMethodDescriptionfloat
getAdvance
(int pos) Returns the advance of the char at the given index of the text buffer.float
getAdvance
(int start, int end) Returns the advance of the chars in the given range of the text buffer.void
getExtent
(int start, int end, FontMetricsInt extent) Expands the font metrics with those of the chars in the given range of the text buffer.int
Note: The text buffer is not within the calculation range.getRuns()
Returns runs of text.char[]
Returns the text buffer.searchRun
(int pos) Binary search with ranges.toString()
-
Method Details
-
getTextBuf
Returns the text buffer. Elements may change if recycled at higher level, keep it synchronized with MeasuredText.- Returns:
- the backend buffer of the text
-
getRuns
Returns runs of text. Successive style runs may remain the same font paint under optimization consideration.- Returns:
- all text runs, may empty if text buf is empty
-
getExtent
Expands the font metrics with those of the chars in the given range of the text buffer.- Parameters:
start
- the start indexend
- the end indexextent
- receives the metrics
-
getAdvance
public float getAdvance(int pos) Returns the advance of the char at the given index of the text buffer.This follows grapheme cluster break. For example: there are 6 chars (uint_16), the first two are the first grapheme, the last four are the second one. Then mAdvances[0] is for the first grapheme, mAdvances[2] for the second one, other elements are zero. It's in the same order of
getTextBuf()
- Parameters:
pos
- the char index- Returns:
- advance
-
getAdvance
public float getAdvance(int start, int end) Returns the advance of the chars in the given range of the text buffer.- Parameters:
start
- the start indexend
- the end index- Returns:
- advance
- See Also:
-
searchRun
Binary search with ranges.- Parameters:
pos
- char index- Returns:
- the run
-
getMemoryUsage
public int getMemoryUsage()Note: The text buffer is not within the calculation range.- Returns:
- memory usage in bytes
-
toString
-