Represents a font. A font is a special-purpose cut-out of an image that divides that image into
characters of different widths. Each font can represent a limited set of characters out of the
character space. Artenus fonts are normal SVG graphics with a comment block describing extra
information. Below is an example of the comment block:
<!-- ARTENUS_FONT 80,-5,0 A 0, 67 B 67, 124 C 124,198 D 0, 80 -->The above block introduces a font height of 80 pixels, horizontal spacing of -5, and vertical spacing of 0. There are four letters defined in the font:
- A starts from x=0 to x=67 in the first line of the graphics (y=0 to y=79).
- B starts from x=0 to x=67 in the first line of the graphics (y=0 to y=79).
- C starts from x=0 to x=67 in the first line of the graphics (y=0 to y=79).
- D starts from x=0 to x=67 in the second line of the graphics (y=80 to y=159). Whenever the first x value is less than the previous letter's second x, the interpreter jumps to the next line. Thus you don't need to specify y values at all.
public final class Font extends Texture
Field Summary
Fields inherited from com.annahid.libs.artenus.graphics.Texture
Method Summary
Modifier and Type | Method and Description |
---|---|
public void | draw(RenderingContext context, TextureShaderProgram program, char[] ca, float sx, float sy, float h, float rot, boolean rtl) Draws a text on the OpenGL context using the information provided. |
public final float | getTextWidth(String text, float h) Calculates the width of a text if drawn with this Font, based of the font size
specified. |
public final float | getTextWidth(char[] ca, float h) Calculates the width of a text if drawn with this Font, based of the font size
specified. |
public static String | processText(String text) Processes a text and conforms it to easily support accent-based characters in the framework
without the need to include accented letters in the actual font. |
Methods inherited from com.annahid.libs.artenus.graphics.Texture
Methods inherited from java.lang.Object
clone
, equals
, finalize
, getClass
, hashCode
, notify
, notifyAll
, toString
, wait
, wait
, wait
Method Detail
draw | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
public void draw( RenderingContext context, TextureShaderProgram program, char[] ca, float sx, float sy, float h, float rot, boolean rtl ) Draws a text on the OpenGL context using the information provided. This method is internally
called by TextSprite to draw the text. Parameters:
|
getTextWidth | ||||
---|---|---|---|---|
public final float getTextWidth( String text, float h ) Calculates the width of a text if drawn with this Font, based of the font size
specified. Parameters:
Returns:
The width of the text |
getTextWidth | ||||
---|---|---|---|---|
public final float getTextWidth( char[] ca, float h ) Calculates the width of a text if drawn with this Font, based of the font size
specified. This method is faster that getTextWidth(String, float) .Parameters:
Returns:
The width of the text |
processText | ||
---|---|---|
public static String processText( String text ) Processes a text and conforms it to easily support accent-based characters in the framework
without the need to include accented letters in the actual font. You can use this method to
get the framework representation of latin strings with accented letters. Parameters:
Returns:
The processed text |