public class WebFontMetricsHelper extends java.lang.Object implements FontMetricsHelper
Modifier and Type | Field and Description |
---|---|
private int |
font
The font identification, in the js font-table.
|
private java.lang.Integer |
height
The font's height.
|
private GuiWebSocket |
websock
The web socket used to retrieve metrics.
|
private int[] |
widths
The font's widths for the first 256 ASCII chars.
|
Constructor and Description |
---|
WebFontMetricsHelper(int font,
GuiWebSocket websock)
Create a new helper for the given font.
|
Modifier and Type | Method and Description |
---|---|
int |
charWidth(char ch)
Report the advance width of the given character.
|
int |
getHeight()
Report the height of a line of text.
|
int[] |
getWidths()
Report the advance widths of the first 256 characters in the font.
|
private void |
resolveWidths()
Resolve the
widths for this font. |
int |
stringWidth(java.lang.String text)
Report the advance width of the given text.
|
int[] |
stringWidths(java.lang.String text)
Get the intermediate widths of this text (for each substring starting from index 0, ending
on indices 1 ..
|
private final int font
private final GuiWebSocket websock
private int[] widths
private java.lang.Integer height
public WebFontMetricsHelper(int font, GuiWebSocket websock)
font
- The font identification, in the js font-table.websock
- The web socket used to retrieve metrics.public int charWidth(char ch)
charWidth
in interface FontMetricsHelper
ch
- The character to size.public int[] getWidths()
getWidths
in interface FontMetricsHelper
public int stringWidth(java.lang.String text)
stringWidth
in interface FontMetricsHelper
text
- The string to size.public int[] stringWidths(java.lang.String text)
stringWidths
in interface FontMetricsHelper
text
- The text.public int getHeight()
getHeight
in interface FontMetricsHelper
private void resolveWidths()
widths
for this font.