Drag[en]gine Script Module DragonScript  1.21
Dragengine.Gui.Font Class Reference

Immutable font resources. More...

Inheritance diagram for Dragengine.Gui.Font:

Public Member Functions

Management
String getFilename ()
 Normalized filename the font has been loaded from. More...
 
Point getTextSize (String text)
 Size of text in pixels using this font. More...
 
float getCharWidth (int char)
 Width of character in pixels using this font. More...
 
float getCharAdvance (int char)
 Advance of character in pixels using this font. More...
 
float getCharBearing (int char)
 Bearing of character in pixels using this font. More...
 
bool hasGlyph (int character)
 Font has glyph. More...
 
int getSize ()
 Font size in pixels. More...
 
float getMaxWidth ()
 Largest width in pixels of all characters supported by this font. More...
 
bool equals (Object other)
 Font is equal to another object. More...
 
int hashCode ()
 Hash code for use as dictionary keys. More...
 

Constructors

Font new (String filename, int fontSize)
 Load font from file. More...
 
Font new (Font font, int fontSize)
 Use font with different size. More...
 
static void loadAsynchron (String filename, ResourceListener listener)
 Load font from file asynchronously. More...
 

Detailed Description

Immutable font resources.

This is a native class. It can not be subclassed.

Member Function Documentation

◆ equals()

bool Dragengine.Gui.Font.equals ( Object  other)

Font is equal to another object.

Implements Object.equals(Object).

Returns
true if other is of type Font and both point to the same engine font resource.

◆ getCharAdvance()

float Dragengine.Gui.Font.getCharAdvance ( int char  )

Advance of character in pixels using this font.

◆ getCharBearing()

float Dragengine.Gui.Font.getCharBearing ( int char  )

Bearing of character in pixels using this font.

◆ getCharWidth()

float Dragengine.Gui.Font.getCharWidth ( int char  )

Width of character in pixels using this font.

◆ getFilename()

String Dragengine.Gui.Font.getFilename ( )

Normalized filename the font has been loaded from.

◆ getMaxWidth()

float Dragengine.Gui.Font.getMaxWidth ( )

Largest width in pixels of all characters supported by this font.

◆ getSize()

int Dragengine.Gui.Font.getSize ( )

Font size in pixels.

This is also the line height of the font.

◆ getTextSize()

Point Dragengine.Gui.Font.getTextSize ( String  text)

Size of text in pixels using this font.

◆ hasGlyph()

bool Dragengine.Gui.Font.hasGlyph ( int  character)

Font has glyph.

Version
1.16

◆ hashCode()

int Dragengine.Gui.Font.hashCode ( )

Hash code for use as dictionary keys.

Implements Object.hashCode().

◆ loadAsynchron()

static void Dragengine.Gui.Font.loadAsynchron ( String  filename,
ResourceListener  listener 
)
static

Load font from file asynchronously.

Registers a request in the game engine to load an font. Once finished or if the file is already loaded the listener is used to deliver the loaded font or null if the loading failed.

◆ new() [1/2]

Font Dragengine.Gui.Font.new ( Font  font,
int  fontSize 
)

Use font with different size.

◆ new() [2/2]

Font Dragengine.Gui.Font.new ( String  filename,
int  fontSize 
)

Load font from file.

If the font file has been already loaded it is assigned to this object. If the font is not loaded yet the engine loads the font. This call blocks until the font is fully loaded and ready to be used. For asynchronous loading use loadAsynchron(). Multiple objects can point to the same loaded font resource. Once no object instance uses an font file anymore it is released from memory.


The documentation for this class was generated from the following file: