Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
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.
Point getTextSize (String text)
 Size of text in pixels using this font.
Point getTextSize (String text, float dilation)
 Size of text in pixels using this font.
float getCharWidth (int char)
 Width of character in pixels using this font.
float getCharAdvance (int char)
 Advance of character in pixels using this font.
float getCharBearing (int char)
 Bearing of character in pixels using this font.
bool hasGlyph (int character)
 Font has glyph.
int getSize ()
 Font size in pixels.
float getMaxWidth ()
 Largest width in pixels of all characters supported by this font.
float getBaseLine ()
 Base line in pixels from top.
float getAvgCharWidth ()
 Average character width in pixels using this font.
bool equals (Object other)
 Font is equal to another object.
int hashCode ()
 Hash code for use as dictionary keys.

Constructors

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

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.

References getBaseLine().

Referenced by hashCode().

◆ getAvgCharWidth()

float Dragengine.Gui.Font.getAvgCharWidth ( )

Average character width in pixels using this font.

References getMaxWidth(), and getSize().

Referenced by hashCode().

◆ getBaseLine()

float Dragengine.Gui.Font.getBaseLine ( )

Base line in pixels from top.

Version
1.29

Referenced by equals().

◆ getCharAdvance()

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

Advance of character in pixels using this font.

References getTextSize().

Referenced by hasGlyph().

◆ getCharBearing()

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

Bearing of character in pixels using this font.

References getCharWidth().

Referenced by getSize().

◆ getCharWidth()

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

Width of character in pixels using this font.

Referenced by getCharBearing().

◆ getFilename()

String Dragengine.Gui.Font.getFilename ( )

Normalized filename the font has been loaded from.

Referenced by getTextSize().

◆ getMaxWidth()

float Dragengine.Gui.Font.getMaxWidth ( )

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

References hasGlyph().

Referenced by getAvgCharWidth().

◆ getSize()

int Dragengine.Gui.Font.getSize ( )

Font size in pixels.

This is also the line height of the font.

References getCharBearing().

Referenced by getAvgCharWidth().

◆ getTextSize() [1/2]

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

Size of text in pixels using this font.

References getFilename(), and getTextSize().

Referenced by getCharAdvance(), and getTextSize().

◆ getTextSize() [2/2]

Point Dragengine.Gui.Font.getTextSize ( String text,
float dilation )

Size of text in pixels using this font.

Same as getTextSize(String) but includes dilation as percentage of the font size. Dilation can be all kinds of dilations like explicit dilation, text borders or similar effects that result in enlarging a font.

◆ hasGlyph()

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

Font has glyph.

Version
1.16

References getCharAdvance().

Referenced by getMaxWidth().

◆ hashCode()

int Dragengine.Gui.Font.hashCode ( )

Hash code for use as dictionary keys.

Implements Object.hashCode().

References equals(), getAvgCharWidth(), and hashCode().

Referenced by hashCode().

◆ loadAsynchron()

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.

References loadAsynchron().

Referenced by loadAsynchron().

◆ new() [1/2]

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

Use font with different size.

References new().

◆ 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.

References new().

Referenced by new(), and new().


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