Requires: Direct2D.lg32
Reads font parameters of the current selected font.
v = D2RFont(param%)
Set FntObj = D2RFont(D2FT_OBJECT)
Param%, D2FT_OBJECT | : integer expression |
FntObj | : COM object |
v | : variant |
D2RFont reads and returns a font property of the current selected D2Font object. The parameter can have one of the following values:
For more information on the return values see D2Font().
Example 1
'
' D2RFont sample (dpi-unaware)
'
$Library "direct2d"
OpenW 1, 0, 0, 420, 300, 16 + 32
Global Object Win1RT
Set Win1RT = D2GetRT()
' App uses default font: DEFAULT_GUI_FONT
Do
Sleep
Until Me Is Nothing
Sub Win_1_Paint
D2BeginDraw Win1RT, D2C_White
D2Text 0, 0, "Font: " + D2RFont(D2FT_NAME) + _
", Height:" + Str(D2RFont(D2FT_HEIGHT)) + _
", Weight:" + Str(D2RFont(D2FT_WEIGHT)) + _
", Italics:" + Str(D2RFont(D2FT_ITALIC)) + _
", Stretch:" + Str(D2RFont(D2FT_STRETCH)) + _
", Locale:" + D2RFont(D2FT_LOCALENAME)
D2EndDraw
EndSub
Example 2 - Using D2FT_ALLSTR
'
' D2FontString sample (dpi-unaware)
'
$Library "direct2d"
Global Object Win1RT
OpenW 1, 0, 0, 320, 300, ~15
Set Win1RT = D2GetRT()
Global String sOrigFnt = D2RFont(D2FT_ALLSTR)
Do
Sleep
Until Me Is Nothing
Sub Win_1_Paint
Local sTxt As String = "Hello Direct2D World"
D2BeginDraw Win1RT, D2C_White
' Create a new font Gabriola, height=20, italic=true
D2SetFont " Gabriola , 20,,True"
D2Text 10, 10, sTxt
' Select original default font from string parameters
D2SetFont sOrigFnt
D2Text 10, 40, "Using DirectWrite"
D2EndDraw
EndSub
Sub Win_1_ReSize
D2ResizeRT Win1RT, _X, _Y
Example 3 - Using D2FT_OBJECT
'
' D2FontObject sample (dpi-unaware)
'
$Library "direct2d"
Global Object Win1RT, origFnt
OpenW 1, 0, 0, 320, 300, ~15
Set Win1RT = D2GetRT()
Set origFnt = D2RFont(D2FT_OBJECT)
Do
Sleep
Until Me Is Nothing
Sub Win_1_Paint
Local sTxt As String = "Hello Direct2D World"
D2BeginDraw Win1RT, D2C_White
' Create a new font
D2FontSize(D2PointsToDIPs(12)) ' in points
D2Text 10, 10, sTxt
' Select original default font
D2SetFont origFnt
D2Text 10, 30, "Using DirectWrite"
D2EndDraw
EndSub
Sub Win_1_ReSize
D2ResizeRT Win1RT, _X, _Y
D2Font, D2FontSize, D2FontBold, D2FontItalic, D2FontStretch, D2FontName, D2FontLocaleName, D2GetFontObj, D2SetFont
{Created by Sjouke Hamstra; Last updated: 27/12/2021 by James Gaite}