D2Text command

Requires: Direct2D.lg32

Purpose

Draws text with a single format to the current render target.

Syntax

D2Text x!, y!, text$ [, D2brush] [, options]

x!, y!: float expression
text$: string expression
D2brush: Object
options: integer expression

Description

D2Text x, y, text$ mimics the GFABASIC Text command. The coordinates x! and y! specify the top left corner of the drawing. The optional brush argument specifies a brush object to draw with. If the brush is omitted a solid color brush based on the foreground color is used. The foreground color is defined using the D2Color or the D2RGBColor command. D2Text uses the font set with D2SetFont (default is DEFAULT_GUI_FONT).

For completeness the application may specify the drawing options. However, to provide GB compatibility to the Text command, the options parameter can be left to its default value. The optional options argument can be a combination of the following DWRITE_DRAW_TEXT_OPTIONS constants:

Example

'

' D2Text sample  (dpi-unaware)

'

$Library "direct2d"

Global Object Win1RT

OpenW 1, 0, 0, 320, 300, ~15

Set Win1RT = D2GetRT()

Global Object Fnt

Set Fnt = D2Font("Gabriola", 13)

Do

Sleep

Until Me Is Nothing

 

Sub Win_1_Paint

D2BeginDraw Win1RT, D2C_White

D2SetFont Fnt

D2Text 16, 16, "Hello Direct2D"

D2SetFont "Courier New", 13

D2Text 16, 40, "DirectWrite"

D2EndDraw

EndSub

 

Sub Win_1_ReSize

D2ResizeRT Win1RT, _X, _Y

Remarks

As with all drawing operations, D2Text must be embedded between D2BeginDraw and D2EndDraw. D2Text invokes the ID2D1RenderTarget::DrawText method.

For more information see here.

See Also

D2SetFont, D2Layout, D2SetRT, D2BeginDraw, D2EndDraw, D2DrawText

{Created by Sjouke Hamstra; Last updated: 28/03/2020 by James Gaite}