AudioAsset
Ease
FastString
FontAsset
NineSlice
PackedSprite
PackedSpriteID
RB
   HardwareSettings
   IRetroBlitGame
RBAsset
Rect2i
ShaderAsset
SoundReference
SpriteGrid
SpriteSheetAsset
TMXMapAsset
   TMXLayer
   TMXLayerLoadState
   TMXObject
   TMXObjectGroup
   TMXProperties
Vector2i

RB.PrintMeasure

Method  -  Static

public static Vector2i PrintMeasure(string text)
public static Vector2i PrintMeasure(Rect2i rect, int flags, string text)
public static Vector2i PrintMeasure(FastString text)
public static Vector2i PrintMeasure(Rect2i rect, int flags, FastString text)
public static Vector2i PrintMeasure(FontAsset font, string text)
public static Vector2i PrintMeasure(FontAsset font, Rect2i rect, int flags, string text)
public static Vector2i PrintMeasure(FontAsset font, FastString text)
public static Vector2i PrintMeasure(FontAsset font, Rect2i rect, int flags, FastString text)

Parameters

text string Text
rect Rect2i Rectangular area to print to
flags int Any combination of flags: RB.ALIGN_H_LEFT, RB.ALIGN_H_RIGHT, RB.ALIGN_H_CENTER, RB.ALIGN_V_TOP, RB.ALIGN_V_BOTTOM, RB.ALIGN_V_CENTER, RB.TEXT_OVERFLOW_CLIP, RB.TEXT_OVERFLOW_WRAP.
font FontAsset Font asset

Returns

Vector2i

Printed dimensions of the text

Description

Measures a text string without printing it, and returns a Vector2i representing the width and height of the text string. All alignment and clipping flags are taken into account as well.

Refer to RB.Print for more detail on aligning and setting clip regions for text.

Example

void Render() {
    // Text string with the "damage" number in red
    var text = "Player hit for @FF0000" + damage + "@-!!!";

    // Manually align the text to the upper right corner of the screen with a 4 pixel offset
    var textSize = RB.PrintMeasure(text);
    var textPos = new Vector2i(RB.DisplaySize.width - text.width - 44);
    RB.Print(textPos, Color.white, text);

    // Automatically align text using a rect and alignment flags
    RB.Print(
        new Rect2i(00RB.DisplaySize.width, RB.DisplaySize.height),
        Color.white,
        RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER,
        text);
}

See Also

RB.Print
FontAsset

See Docs

Features - Fonts