Libraries.Game.Graphics.Fonts.CharacterMap Documentation

The CharacterMap class is used to lookup characters in a hash table. Primarily, it provides actions for finding the character code of a character, normally in UNICODE, a character's Bezier curve points if they have been stored, a character's glyph if it has been created, and the index and table offset of each character in the font file.

Example Code

use Libraries.Game.Graphics.Fonts.all
use Libraries.Game.Game

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        CharacterMap map
        output map:GetGlyphIndex("a")
    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)

GetCharacterCode(text character)

This action returns the character code for a given character.

Parameters

  • text character: The character to get the character code of.

Return

integer: Returns the character code, normally in UNICODE, of the character.

Example


    use Libraries.Game.Graphics.Fonts.all
    use Libraries.Game.Game

    class Main is Game
        action Main
            StartGame()
        end

        action CreateGame
            CharacterMap map
            output map:GetCharacterCode("a")
        end 
    end

GetGlyph(text character)

This action returns the glyph of the given character.

Parameters

  • text character: The character to get the glyph of.

Return

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

Example

use Libraries.Game.Graphics.Fonts.all
use Libraries.Game.Game
use Libraries.Game.Graphics.Glyph

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        CharacterMap map
        Glyph glyph = map:GetGlyph("a")
    end
end

GetGlyphIndex(text character)

This action returns the location of the character in the glyph table from the font file.

Parameters

  • text character: The character to get the location for.

Return

integer: Returns the location of the character in the glyph table.

Example

use Libraries.Game.Graphics.Fonts.all
use Libraries.Game.Game

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        CharacterMap map
        output map:GetGlyphIndex("a")
    end
end

GetGlyphPoints(text character)

This action returns the Bezier curve glyph points of the given character.

Parameters

  • text character: The character to get the 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

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        CharacterMap map
        BezierCurveGlyphPoints points = map:GetGlyphPoints("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()

GlyphPointsHaveBeenRead(text character)

This action checks if the given character's Bezier curve glyph points have already been read from the file.

Parameters

  • text character: The character to check if the glyph points have already been read.

Return

boolean: Returns true if the glyph points have already been read from the file, and false if they have not.

Example

use Libraries.Game.Graphics.Fonts.all
use Libraries.Game.Game

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        CharacterMap map
        output map:GlyphPointsHaveBeenRead("a")
    end
end

HasGlyph(text character)

This action returns whether or not a glyph has been created for the given character.

Parameters

  • text character: The character to check whether or not it has a glyph.

Return

boolean: Returns true if there is a glyph for this character, and false if there is not.

Example

use Libraries.Game.Graphics.Fonts.all
use Libraries.Game.Game

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        CharacterMap map
        output map:HasGlyph("a")
    end
end

HasKey(text character)

This action returns whether or not the given character is in the character table.

Parameters

  • text character: The character to look for.

Return

boolean: Returns true if the character is in the character table, and false if it is not.

Example

use Libraries.Game.Graphics.Fonts.all
use Libraries.Game.Game

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        CharacterMap map
        output map:HasKey("a")
    end
end

SetGlyph(text character, Libraries.Game.Graphics.Glyph glyph)

This action sets the glyph of a given character.

Parameters

Example

use Libraries.Game.Graphics.Fonts.all
use Libraries.Game.Game
use Libraries.Game.Graphics.Glyph

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        CharacterMap map
        Glyph glyph
        map:SetGlyph("a", glyph)
    end
end

SetGlyphIndexAndOffset(text character, integer glyphIndex, integer glyphOffset)

This action sets the index of the character in the font file's glyph offset location table, and the character's offset in the glyph table.

Parameters

  • text character: The character to set the indices for.
  • integer glyphIndex: The index of the character in the font file's glyph offset location table.
  • integer glyphOffset: The offset of the character in the glyph table.

Example


    use Libraries.Game.Graphics.Fonts.all
    use Libraries.Game.Game

    class Main is Game
        action Main
            StartGame()
        end

        action CreateGame
            CharacterMap map
            map:SetGlyphIndexAndOffset("a", 0, 0)
        end
    end

SetGlyphPoints(text character, Libraries.Game.Graphics.Fonts.BezierCurveGlyphPoints glyphPoints)

This action sets the Bezier curve glyph points for a given character.

Parameters

Example

use Libraries.Game.Graphics.Fonts.all
use Libraries.Game.Game

class Main is Game
    action Main
        StartGame()
    end 

    action CreateGame
        CharacterMap map
        BezierCurveGlyphPoints glyphPoints
        map:SetGlyphPoints("a", glyphPoints)
    end
end