Libraries.Game.Graphics.Font Documentation
The Font class is used to load a font from the system.
Example Code
use Libraries.Game.Graphics.Font
use Libraries.Game.Graphics.Label
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
Label label
if not font:IsFontAvailable("Verdana")
output "The font could not be found!"
return now
end
font:LoadFont("Verdana")
font:SetSize(18)
label:SetFont(font)
Add(label)
end
end
Inherits from: Libraries.Language.Object
Actions Documentation
ChangeSubFont(text style)
This action changes the style of the font. This is only applicable to TrueTypeCollection (.ttc) files.
Parameters
- text style: The style of the font to change to.
Example
use Libraries.Game.Graphics.Font
use Libraries.System.File
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
File file
file:SetPath("CustomFont.ttf")
font:LoadFont(file)
font:ChangeSubFont("Italic")
end
end
Compare(Libraries.Language.Object object)
This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.
Parameters
- Libraries.Language.Object: The object to compare to.
Return
integer: The Compare result, Smaller, Equal, or Larger.
Example
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
Copy()
Example
use Libraries.Game.Graphics.Font
Font font
Font font2 = font:Copy()
output "Hooray!"
Dispose()
This action will release the resources used by a loaded font. The Font object will no longer be usable until another font is loaded.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
font:LoadFont("Arial")
font:Dispose()
end
end
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
Example
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
GetAngle()
This action will return the current angle of the font. The default angle is 0 degrees.
Return
number: Returns the current angle of the font.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
output "The font has an angle of " + font:GetAngle() + " degrees."
end
end
GetAvailableFonts()
This action will return an array of all files found in the system's default font folder.
Return
Libraries.Containers.Array: Returns an array with all the font files on the system.
Example
use Libraries.Game.Graphics.Font
use Libraries.System.File
use Libraries.Containers.Array
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
Array<File> fontFiles = font:GetAvailableFonts()
integer index = 0
output "The following fonts are available on the system: "
repeat fontFiles:GetSize() times
File temp = fontFiles:Get(index)
output temp:GetPath()
index = index + 1
end
end
end
GetGlyph(text character)
This action will return a Glyph object for this font's representation of the given character.
Parameters
- text character: The character to create a glyph of.
Return
Libraries.Game.Graphics.Glyph: Returns a glyph representation of the character.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Graphics.Glyph
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
font:LoadFont("Arial")
Glyph a = font:GetGlyph("a")
end
end
GetHashCode()
This action gets the hash code for an object.
Return
integer: The integer hash code of the object.
Example
Object o
integer hash = o:GetHashCode()
GetIdentifier()
This action returns an identifier that uniquely identifies whatever Font has been loaded by this object. This is used to request Font information from the FontManager. Most users will never need to use this action directly.
Return
text:
GetKerning(text currentCharacter, text nextCharacter)
This action calculates the kerning value between a pair of characters and then returns it.
Parameters
- text currentCharacter: The first character in the pair.
- text nextCharacter: The second character in the pair.
Return
integer: Returns the kerning value between these two characters.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
font:LoadFont("Arial")
integer kerning = font:GetKerning("A", "V")
end
end
GetLineHeight()
This action will return the height of each line of text produced by this font.
Return
integer: Returns the height of a line of text for this font.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
font:LoadFont("Arial")
integer height = font:GetLineHeight()
end
end
GetMaximumAscent()
This action calculates the kerning value between a pair of characters and then returns it.
Return
integer: Returns the kerning value between these two characters.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
font:LoadFont("Arial")
integer kerning = font:GetKerning("A", "V")
end
end
GetMaximumDescent()
This action will return an array of all files found in the system's default font folder.
Return
integer: Returns an array with all the font files on the system.
Example
use Libraries.Game.Graphics.Font
use Libraries.System.File
use Libraries.Containers.Array
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
Array<File> fontFiles = font:GetAvailableFonts()
integer index = 0
output "The following fonts are available on the system: "
repeat fontFiles:GetSize() times
File temp = fontFiles:Get(index)
output temp:GetPath()
index = index + 1
end
end
end
GetName()
This action gets the name of the font, including the file extension.
Return
text:
Example
use Libraries.Game.Graphics.Font
use Libraries.System.File
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
File file
file:SetPath("CustomFont.ttf")
font:LoadFont(file)
output font:GetName()
end
end
GetSize()
This action will return the current size of the font. The default font size is 14.
Return
integer: Returns the current size of the font.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
output "The default font size is " + font:GetSize()
end
end
GetUnderlinePosition()
This action will return the height of each line of text produced by this font.
Return
integer: Returns the height of a line of text for this font.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
font:LoadFont("Arial")
integer height = font:GetLineHeight()
end
end
GetUnderlineThickness()
This action will check if the font has been loaded yet. If the font has been loaded, this will return true. Otherwise, it will return false.
Return
integer: Returns true if the font is loaded, and false if it is not.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
font:LoadFont("Arial")
boolean loaded = font:IsLoaded()
end
end
IsBordered()
This action will return true if this font currently supports borders, or false if it does not. The default value is false.
Return
boolean: Returns whether or not borders are enabled on this font.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
output "By default, font borders enabled = " + font:IsBordered()
end
end
IsFontAvailable(text fontName)
This action will look in the default system font folder and look for a font of the given name. If a font is found with the same name, the action will return true. Otherwise, it returns false.
Parameters
- text fontName: The name of the font to check for on the system.
Return
boolean: Returns true if the font is on the system, and false if it is not.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
output font:IsFontAvailable("Times New Roman")
end
end
IsLoaded()
This action will check if the font has been loaded yet. If the font has been loaded, this will return true. Otherwise, it will return false.
Return
boolean: Returns true if the font is loaded, and false if it is not.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
font:LoadFont("Arial")
boolean loaded = font:IsLoaded()
end
end
LoadFont(text fontName)
This action will load a font by name from the system. On Windows, this will search for fonts in "C:\Windows\Fonts". On Mac, this will search for fonts in "/Library/Fonts".
Parameters
- text fontName: The name of the font to load.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
font:LoadFont("Arial")
end
end
LoadFont(Libraries.System.File fontFile)
Example
use Libraries.Game.Graphics.Font
use Libraries.System.File
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
File file
file:SetPath("CustomFont.ttf")
font:LoadFont(file)
end
end
Rotate(number rotation)
This action will rotate the characters produced by this font by the given number of degrees.
Parameters
- number rotation: The number of degrees to rotate the font.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
font:Rotate(45)
end
end
SetAngle(number newAngle)
This action will set the angle in degrees of the characters produced by this font.
Parameters
- number newAngle: The number of degrees to angle the font by.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
font:SetAngle(90)
end
end
SetBordered(boolean bordered)
This action will either enable or disable borders for this font. By default, fonts do not support borders.
Parameters
- boolean bordered: True to enable borders, or false to disable them.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
font:SetBordered(true)
end
end
SetSize(integer newSize)
This action will set the size of the font. The default font size is 14.
Parameters
- integer newSize: The size to change the font to.
Example
use Libraries.Game.Graphics.Font
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
font:SetSize(16)
end
end
SetStyle(text style)
This action sets the style of the font to use, such as bold, italic, condensed, and so on. This is only applicable to TrueTypeCollection (.ttc) files.
Parameters
- text style: The style of the font to load.
Example
use Libraries.Game.Graphics.Font
use Libraries.System.File
use Libraries.Game.Game
class Main is Game
action Main
StartGame()
end
action CreateGame
Font font
File file
file:SetPath("CustomFont.ttf")
font:SetStyle("Regular")
font:LoadFont(file)
end
end
On this page
Variables TableAction Documentation- ChangeSubFont(text style)
- Compare(Libraries.Language.Object object)
- Copy()
- Dispose()
- Equals(Libraries.Language.Object object)
- GetAngle()
- GetAvailableFonts()
- GetGlyph(text character)
- GetHashCode()
- GetIdentifier()
- GetKerning(text currentCharacter, text nextCharacter)
- GetLineHeight()
- GetMaximumAscent()
- GetMaximumDescent()
- GetName()
- GetSize()
- GetUnderlinePosition()
- GetUnderlineThickness()
- IsBordered()
- IsFontAvailable(text fontName)
- IsLoaded()
- LoadFont(text fontName)
- LoadFont(Libraries.System.File fontFile)
- Rotate(number rotation)
- SetAngle(number newAngle)
- SetBordered(boolean bordered)
- SetSize(integer newSize)
- SetStyle(text style)