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

Summary

Actions Summary Table

ActionsDescription
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetCharacterGlyphPoints(text character)This action will return the Bezier curve glyph points of a given character.
GetFileInformation()This action returns all the information read from the TrueType file.
GetHashCode()This action gets the hash code for an object.
GetKerningTable()This action returns the kerning table, containing kerning values for all characters, of the font.
GetKerningValue(text lefthandCharacter, text righthandCharacter)This action returns the kerning value between two given characters.
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.

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.

Example Code

Object o
        Object t
        integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Equals(Libraries.Language.Object object)

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

Example Code

use Libraries.Language.Object
        use Libraries.Language.Types.Text
        Object o
        Text t
        boolean result = o:Equals(t)

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

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.

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

Parameters

Return

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

GetFileInformation()

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

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

Return

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

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetKerningTable()

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

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

Return

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

GetKerningValue(text lefthandCharacter, text righthandCharacter)

This action returns the kerning value between two given characters.

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)
                integer kerning = reader:GetKerningValue("A", "V")
                output kerning
            end
        end

Parameters

Return

integer: Returns the kerning value between two given characters.

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.

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

Parameters