Libraries.Game.Graphics.Fonts.FontFileReader Documentation

The FontFileReader class is used to read font files. Currently it only supports TrueType files (.ttf extension). TrueType files come in different formats, and not all of these formats are supported at the moment. As a result, some TrueType files will load and be read, but they will not display characters correctly.

Example Code

use Libraries.Game.Graphics.Fonts.all
use Libraries.Game.Game
use Libraries.System.File

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        FontFileReader reader
        File file
        // This is the directory for fonts on Mac
        file:SetWorkingDirectory("/Library/Fonts")
        file:SetPath("Arial.ttf")
        reader:Load(file)
    end
end

Inherits from: Libraries.Language.Object

Actions Documentation

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

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)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

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)

GetCharacterGlyphPoints(text character)

This action will return the Bezier curve glyph points of a given character. If the character has already been read, it gets the points from the character map. Otherwise, it will get the data from the font file.

Parameters

  • text character: The character to get the Bezier curve glyph points of.

Return

Libraries.Game.Graphics.Fonts.BezierCurveGlyphPoints: Returns the Bezier curve glyph points of the character.

Example

use Libraries.Game.Graphics.Fonts.all
use Libraries.Game.Game
use Libraries.System.File

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        FontFileReader reader
        File file
        BezierCurveGlyphPoints points
        // This is the directory for fonts on Mac
        file:SetWorkingDirectory("/Library/Fonts")
        file:SetPath("Arial.ttf")
        reader:Load(file)
        points = reader:GetCharacterGlyphPoints("a")
    end
end

GetFileInformation()

This action returns all the information read from the TrueType file.

Return

Libraries.Game.Graphics.Fonts.TrueTypeFileInformation: Returns a TrueTypeFileInformation containing all of the contents from the TrueType file.

Example


    use Libraries.Game.Graphics.Fonts.all
    use Libraries.Game.Game
    use Libraries.System.File

    class Main is Game
        action Main
            StartGame()
        end

        action CreateGame
            FontFileReader reader
            File file
            TrueTypeFileInformation information
            // This is the directory for fonts on Mac
            file:SetWorkingDirectory("/Library/Fonts")
            file:SetPath("Arial.ttf")
            reader:Load(file)
            information = reader:GetFileInformation()
        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()

GetKerningTable()

This action returns the kerning table, containing kerning values for all characters, of the font.

Return

Libraries.Game.Graphics.Fonts.KerningTable: Returns the kerning table of the font.

Example

use Libraries.Game.Graphics.Fonts.all
use Libraries.Game.Game
use Libraries.System.File

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        FontFileReader reader
        File file
        KerningTable table
        // This is the directory for fonts on Mac
        file:SetWorkingDirectory("/Library/Fonts")
        file:SetPath("Arial.ttf")
        reader:Load(file)
        table = reader:GetKerningTable()
    end
end

GetKerningValue(text lefthandCharacter, text righthandCharacter)

This action returns the kerning value between two given characters.

Parameters

  • text lefthandCharacter: The lefthand character of the pair.
  • text righthandCharacter: The righthand character of the pair.

Return

integer: Returns the kerning value between two given characters.

Example

use Libraries.Game.Graphics.Fonts.all
use Libraries.Game.Game
use Libraries.System.File

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        FontFileReader reader
        File file
        // This is the directory for fonts on Mac
        file:SetWorkingDirectory("/Library/Fonts")
        file:SetPath("Arial.ttf")
        reader:Load(file)
        integer kerning = reader:GetKerningValue("A", "V")
        output kerning
    end
end

Load(Libraries.System.File fileInformation)

This action will load the font file if it is found on the system and then read all information from the file.

Parameters

Example

use Libraries.Game.Graphics.Fonts.all
use Libraries.Game.Game
use Libraries.System.File

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        FontFileReader reader
        File file
        // This is the directory for fonts on Mac
        file:SetWorkingDirectory("/Library/Fonts")
        file:SetPath("Arial.ttf")
        reader:Load(file)
    end
end