RSX Code Reference
    Preparing search index...

    Class Font

    Font resource containing data about textual characters and how to render text. Contains one or multiple font bitmaps, each for a specific size.

    Hierarchy (View Summary)

    Index
    • get isDestroyed(): boolean

      Determines if the resource is destroyed.

      Returns boolean

      This can happen when the Resource was forcefully unloaded or reverted. For this reason, it is safer to hold on to a instead of directly referencing a resource pointer, as the current Resource can always be retrieved via .value.

    • get name(): string

      Name of the resource. Use primarily for easier identification and not important to the engine itself.

      Returns string

    • get uuid(): UUID

      Returns a universally unique identifier of this resource.

      Returns UUID

    • Calculate the dimensions for the text.

      Parameters

      • text: string
      • fontSize: number

        The size of the font.

      • OptionalmaximumWidth: number

        (Optional) The maximum width to enforce a line breaks.

      • OptionalwordBreak: boolean
      • Optionalelision: EnumValue<ElisionType>

      Returns Size2

    • Duplicates the resource and creates a unique UUID for the duplicated resource.

      Returns Resource

      The duplicated resource or null, if the duplication failed.

    • Finds the available font size closest to the provided size.

      Parameters

      • size: number

        Size of the font in points.

      Returns number

      Nearest available font size.

    • Returns font data for a specific font size. In the case the font is dynamic, this method will not create new data for the given size. Use GetOrCreateData instead.

      Parameters

      • size: number

        Size of the font in points.

      • OptionalisLinearlyScaled: boolean

        Whether or not the font should use linear advancing for glyphs, instead of pixel aligned values.

      Returns FontData

      Data object if it exists, false otherwise.

    • Returns font data for a specific font size. If no such data exists and the font IsDynamic() new data will be created. If the font is not dynamic, the nearest baked font data will be returned.

      Parameters

      • size: number

        Size of the font in points.

      • OptionalisLinearlyScaled: boolean

        Whether or not the font should use linear advancing for glyphs, instead of pixel aligned values.

      Returns FontData

      An existing Data object if it exists or a newly created one.

    • Returns font data for a specific font size. If no such data exists and the font IsDynamic() new data will be created.

      Parameters

      • size: number

        Size of the font in points.

      • OptionalisLinearlyScaled: boolean

        Whether or not the font should use linear advancing for glyphs, instead of pixel aligned values.

      Returns FontData

      An existing Data object if it exists or a newly created one.

    • Returns the requested font bitmap texture page.

      Parameters

      • page: number

        The bitmap page index to be returned.

      Returns Texture

      The requested texture page or if not found.

    • Checks if the font supports dynamic glyph generation. The font needs FontImporterOptions::dynamic set to true when importing it.

      Returns boolean

    • Virtual

      Method called by RSX to perform actions required after the creation of the resource.

      Returns void

    • Virtual

      Method called by RSX to perform any operations needed after deserialization.

      Returns void

      Use this API to restore your serializable data into live objects.

    • Virtual

      Method called by RSX to disable the resource.

      Returns void

      Use this API to deactivate the resource before it is serialized.

    • Virtual

      Method called by RSX to enable the resource.

      Returns void

      Use this API to activate the resource after it has been disabled by serialization.

    • Virtual

      Method called by RSX to perform initialization of the resource.

      Returns void

      Use this API to initialize data and default construct all fields.

    • Virtual

      Method called by RSX to perform any operations before serialization.

      Returns void

      Use this API to bake your live data into serializable data.

    • Prepares all characters in for rendering. If any character in is not rendered yet, it will be rendered and inserted into a suitable texture page.

      Parameters

      • charSet: string
      • size: number
      • OptionalisLinearlyScaled: boolean

      Returns boolean

      If the font is not dynamic (IsDynamic() returns then this method does nothing.

    • Reverts the resource to the on-disk representation.

      Returns boolean

      This is a potentially expensive call, as it needs to deserialize and replace all existing in-memory resource handles.