Download Now

    Reference TTextBlock

    Declared in Codebot.Render.Fonts.pas on line 110

    TTextBlock draws text using a font. The vertices are rebuilt only when a property changes. Text is drawn in the current modelview space with y pointing up, X and Y being the top left of the first line. Use the TWorld.WorldToSpace function to position text in a 2D world.
      TTextBlock = class(TContextManagedObject)
      public
        { Create a text block optionally using a font. If no font is given the
          default font is used. }
        constructor Create(Font: TFont = nil);
        destructor Destroy; override;
        { Measure the size of the text in modelview units }
        function Measure: TVec2;
        { Draw the text. If Text is not empty it replaces the Text property. }
        procedure Draw(const Text: string = '');
        { The font used to draw text }
        property Font: TFont read GetFont write SetFont;
        { The text to draw }
        property Text: string read FText write SetText;
        { The left of the text }
        property X: Float read FX write SetX;
        { The top of the text }
        property Y: Float read FY write SetY;
        { The size of one font pixel in modelview units }
        property Scale: Float read FScale write SetScale;
        { The color of the text which defaults to opaque white }
        property Color: TVec4 read FColor write SetColor;
      end;

    See also

    Float in Codebot.System.pas
    TContextManagedObject in Codebot.Render.Contexts.pas
    TVec2 in Codebot.Geometry.pas
    TVec4 in Codebot.Geometry.pas