Syntax
DrawTxtFill(Text.i, x.d, y.d, Brush)
Description
Draws text onto the current drawing target using a pre-created text object and the specified brush (image or gradient) for the fill. The text object defines the content, font, size, layout constraints, and formatting.
Parameters
Text.i
The handle of the text object (created with CreateText()) to draw.
x.d
The horizontal coordinate of the text layout's top-left corner in
device-independent pixels (DIPs).
y.d
The vertical coordinate of the text layout's top-left corner in DIPs.
Brush
The handle of the brush (created with CreateBrushImg(), CreateBrushGradientLinear(), etc.) used to fill the
text glyphs.
Return Value
This command does not return a value. It returns internally if the Text or Brush handle is invalid.
Remarks
The text object should be created beforehand using CreateText(). The coordinates are specified in DIPs but are converted internally to physical pixels based on the current output's DPI before drawing. Font size within the text object is automatically scaled based on the drawing context's DPI. The appearance of the text fill depends on the brush type and its properties (position, scale, rotation, extend mode, opacity). To draw text with a solid color, use DrawTxt().
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
; Create a text object
Global MyText = CreateText("Gradient Text!", "Impact", 48)
TextSetWidth(MyText, 300) ; Set layout width
; Create a gradient brush
Global GradientBrush = CreateBrushGradientLinear(0, 0, TextGetWidth(MyText), 0, RGB(0, 255, 0), 1, RGB(0, 0, 255), 1) ; Green to Blue
Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw, *UserData)
DrawClear(RGB(220, 220, 220), 1)
; Draw the text filled with the gradient brush
DrawTxtFill(MyText, 20, 20, GradientBrush)
EndProcedure
MyWindow = CreateWindow(0, 0, 340, 100, "DrawTxtFill Example")
If MyWindow
AddEventHandler(MyWindow, #PG_Event_Draw, @DrawHandler())
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
FreeText(MyText)
FreeBrush(GradientBrush)
StopProGUI()
See Also
CreateText, FreeText, DrawTxt, CreateBrushImg, CreateBrushGradientLinear, BeginDraw, EndDraw
Supported OS
Windows (Direct2D only)