Libraries.Game.Graphics.Fonts.QuorumStrategy Documentation

The QuorumStrategy class is used to load fonts on the system using the QuorumFont font engine.

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.Game.Graphics.Fonts.FontStrategy, Libraries.Language.Object

Summary

Actions Summary Table

ActionsDescription
ChangeSubFont(text newStyle)This action changes the style of the font to the new style specified (such as bold, italic, condensed, and so on).
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.
GetAngle()This action will return the current angle of the font.
GetAvailableFonts()This action will return an array of all files found in the system's default font folder.
GetColor()This action will return the color of the characters produced by this font.
GetGlyph(text targetCharacter)This action will return a Glyph object for this font's representation of the given character.
GetHashCode()This action gets the hash code for an object.
GetKerning(text currentCharacter, text nextCharacter)This action calculates the kerning value between a pair of characters and then returns it.
GetLineGap()- glyphMinimu
GetLineHeight()This action will return the height of each line of text produced by this font.
GetMaximumAscent()^ change to read from fileInformation instead of fileRead
GetMaximumDescent()this seems wrong to me, and it doesn't seem to affect the fonts at a
GetSize()This action will return the current size of the font.
IsFontAvailable(text fontName)This action will look in the default system font folder and look for a font of the given name.
IsLoaded()This action will check if the font has been loaded yet.
LoadFont(text fontName)This action will load a font by name from the system.
LoadFont(Libraries.System.File fontFile)This action loads a font from a given font file.
Rotate(number rotation)This action will rotate the characters produced by this font by the given number of degrees.
SetAngle(number newAngle)This action will set the angle in degrees of the characters produced by this font.
SetColor(Libraries.Game.Graphics.Color newColor)This action will set the color of the characters produced by this font.
SetSize(integer newSize)This action will set the size of the font.
SetStyle(text newStyle)This action sets the style of font to use, such as bold, italic, condensed, and so on.

Actions Documentation

ChangeSubFont(text newStyle)

This action changes the style of the font to the new style specified (such as bold, italic, condensed, and so on). This action only works both if the font file is a TrueTypeCollection (.ttc) file and if the file has already been loaded. If the file has not been loaded yet, use the SetStyle(text style) action to set the desired style and then load the font file.

Example Code

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

Parameters

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.

GetAngle()

This action will return the current angle of the font. The default angle is 0 degrees.

Example Code

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

Return

number: Returns the current angle of the font.

GetAvailableFonts()

This action will return an array of all files found in the system's default font folder.

Example Code

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

Return

Libraries.Containers.Array: Returns an array with all the font files on the system.

GetColor()

This action will return the color of the characters produced by this font.

Example Code

use Libraries.Game.Graphics.Font
        use Libraries.Game.Graphics.Color
        use Libraries.Game.Game

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                Font font
                Color color = font:GetColor()
            end
        end

Return

Libraries.Game.Graphics.Color: The color being used by this font.

GetGlyph(text targetCharacter)

This action will return a Glyph object for this font's representation of the given character.

Example Code

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

Parameters

Return

Libraries.Game.Graphics.Glyph: Returns a glyph representation of the character.

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.

GetKerning(text currentCharacter, text nextCharacter)

This action calculates the kerning value between a pair of characters and then returns it.

Example Code

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

Parameters

Return

integer: Returns the kerning value between these two characters.

GetLineGap()

- glyphMinimu

Return

integer:

GetLineHeight()

This action will return the height of each line of text produced by this font.

Example Code

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

Return

integer: Returns the height of a line of text for this font.

GetMaximumAscent()

^ change to read from fileInformation instead of fileRead

Return

integer:

GetMaximumDescent()

this seems wrong to me, and it doesn't seem to affect the fonts at a

Return

integer:

GetSize()

This action will return the current size of the font. The default font size is 14.

Example Code

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

Return

integer: Returns the current size of the font.

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.

Example Code

use Libraries.Game.Graphics.Font
        use Libraries.Game.Game

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                Font font
                boolean hasFont = font:IsFontAvailable("Times New Roman")
            end
        end

Parameters

Return

boolean: Returns true if the font is on the system, and false otherwise.

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.

Example Code

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

Return

boolean: Returns true if the font is loaded, and false if it is not.

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". On Android, this will search for fonts in "/system/fonts".

Example Code

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

Parameters

LoadFont(Libraries.System.File fontFile)

This action loads a font from a given font file.

Example Code

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

Parameters

Rotate(number rotation)

This action will rotate the characters produced by this font by the given number of degrees. Note that this function is not yet implemented.

Example Code

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

Parameters

SetAngle(number newAngle)

This action will set the angle in degrees of the characters produced by this font. Note that this function is not yet implemented.

Example Code

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

Parameters

SetColor(Libraries.Game.Graphics.Color newColor)

This action will set the color of the characters produced by this font.

Example Code

use Libraries.Game.Graphics.Font
        use Libraries.Game.Graphics.Color
        use Libraries.Game.Game

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                Font font
                Color color
                font:SetColor(color:Orange())
            end
        end

Parameters

SetSize(integer newSize)

This action will set the size of the font. The default font size is 14.

Example Code

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

Parameters

SetStyle(text newStyle)

This action sets the style of font to use, such as bold, italic, condensed, and so on. This is only applicable to TrueTypeCollection (.ttc) files.

Example Code

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("Bold")
                font:LoadFont(file)
            end
        end

Parameters