Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class ScreenMeasurer
- Object
- ScreenMeasurer
ImplementsMeasurer
Measures text with the platform fonts DocumentView draws it in.
The view’s default. A layout measured with one font and drawn with another puts every
run where the first font would have ended the previous one, so wider glyphs run into the
next word. PdfMeasurer measures the PDF’s fonts; use it on a view only when its pages
must break exactly where the exported PDF’s do.
Widths are measured at PIXELS_PER_POINT pixels per point and scaled back, so they do
not depend on the size the view happens to draw at.
Constructors
public ScreenMeasurer() |
Methods
public Font font(TextStyle style, int px) | The platform font a style is drawn in, at a pixel size. |
public float width(String text, TextStyle style) | The advance width of text drawn in a style. |
public float ascent(TextStyle style) | The distance from the top of a line of this style to its baseline. |
public float descent(TextStyle style) | The distance from the baseline to the bottom of a line of this style. |
Inherited methods
Constructor details
ScreenMeasurer
public ScreenMeasurer()Method details
font
public Font font(TextStyle style, int px)The platform font a style is drawn in, at a pixel size.
Parameters
styleTextStyle- the style
pxint- the size in pixels
Returns
the font
width
public float width(String text, TextStyle style)The advance width of text drawn in a style.
Parameters
textString- the text, never containing a line break
styleTextStyle- the style
Returns
the width in points
ascent
public float ascent(TextStyle style)The distance from the top of a line of this style to its baseline.
Parameters
styleTextStyle- the style
Returns
the ascent in points
descent
public float descent(TextStyle style)The distance from the baseline to the bottom of a line of this style.
Parameters
styleTextStyle- the style
Returns
the descent in points, positive