ITextRenderer
interface ITextRenderer
Known subtypes: GlyphTextRenderer
Package: dev.joid.lib.font · Module: core · Source: ITextRenderer.java
Measures and draws the strings of one kind of font.
Description
Section titled “Description”DrawText and TextInfo reach it through IFont.getTextRenderer.
Implement it for a font that is not made of glyphs; for a font of glyphs, extend GlyphTextRenderer, which lays out, kerns and styles the text for you.
Positions and sizes are in design pixels.
Learn more
Section titled “Learn more”Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
FontBounds | drawText(double x, double y, String text, TextInfo info) abstract | Draws text on one line with its top-left corner at x, y, and returns its bounds. |
FontBounds | drawText(double x, double y, String text, TextInfo info, double runX, double runY, double runWidth, double runHeight) default | Draws text as a part of a longer run whose box is runX, runY, runWidth, runHeight, so that a gradient spreads over the whole run. |
double | getLineHeight(TextInfo info) abstract | Returns the height of one line with info. |
double | getWidth(String text, TextInfo info) abstract | Returns the width of text on one line with info, markup tags excluded. |
double | getHeight(String text, TextInfo info) abstract | Returns the height of text with info. |
double | getBaseline(TextInfo info) default | Returns the distance from the top of a line to its baseline with info; the elements of a Text align on it. |
Method details
Section titled “Method details”drawText
Section titled “drawText”FontBounds drawText(double x, double y, String text, TextInfo info) abstract
Draws text on one line with its top-left corner at x, y, and returns its bounds.
JOID calls it on the render thread, during a frame.
FontBounds drawText(double x, double y, String text, TextInfo info, double runX, double runY, double runWidth, double runHeight) default
Draws text as a part of a longer run whose box is runX, runY, runWidth, runHeight, so that a gradient spreads over the whole run.
By default it ignores the run and calls drawText(x, y, text, info).
getLineHeight
Section titled “getLineHeight”double getLineHeight(TextInfo info) abstract
Returns the height of one line with info.
getWidth
Section titled “getWidth”double getWidth(String text, TextInfo info) abstract
Returns the width of text on one line with info, markup tags excluded.
getHeight
Section titled “getHeight”double getHeight(String text, TextInfo info) abstract
Returns the height of text with info.
getBaseline
Section titled “getBaseline”double getBaseline(TextInfo info) default
Returns the distance from the top of a line to its baseline with info; the elements of a Text align on it.
By default, the line height: the baseline sits at the bottom of the line.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
