Changes the font in the current Form or Printer.
SetFont hFont (Command)
[Object].SetFont Name, Size, Bold, Italic, Underline, StrikeThru, CharSet (Method)
hFont:Handle
Object:Ocx Object
CharSet:Integer
Size:Single
Name:String
Bold, Italic, Underline, StrikeThru: Bool
SetFont hFont selects a font using a font handle or a system constant. A font handle can be obtained using Font To, Dlg Font, _font$, or CreateFontIndirect(). SetFont hFont is a 16-bit compatible command.
ConstantDESCRIPTION
SYSTEM_FONT( 13) - standard proportional font
SYSTEM_FIXED_FONT( 16) - a similar non-proportional font
ANSI_VAR_FONT( 12) - a Helvetica or Times font, SYSTEM_FONT, but a little smaller.
ANSI_FIXED_FONT( 11) - a typewriter font (like Courier), a little smaller than SYSTEM_FIXED_FONT
DEVICE_DEFAULT_FONT( 14) - can be any font, mostly SYSTEM_FONT, selected by the driver.
OEM_FIXED_FONT( 10) - DOS window character set. However, instead of ANSI (WINDOWS) character set the OEM (read IBM) character set is used.
The second variant [Object.]SetFont is an Ocx method and supports a compact way of changing the current Font object. In contrast with the first variant, SetFont hFont, the SetFont method manipulates the current Font object of an Ocx object, or the current active Form or Printer.
' AutoRedraw also opens the window Me
AutoRedraw = 1
Dim fnt As Handle, i As Int, s$
' Select a screen font
Dlg Font Me, 0, 1
' Create a handle
Font To fnt
' Read the name of a font
RFont Name s$
' Activate the font
SetFont fnt
' Test it
Print "test", s$
' Activate the SYSTEM_FONT
SetFont 13
' another test
Print "test"
' Give the used memory free
DelFont fnt
The font handling for Form and Printer objects is very different from each other. API font handles (Font To, Dlg Font) should not be mixed with Font objects.
In contrast with GFA-BASIC 16 SetFont 0 is not allowed (crash).
Font, Font To, SetFont, GetFont, RFont, Dlg Font, _hFont, _font$, _font$=, FreeFont, DelFont
{Created by Sjouke Hamstra; Last updated: 23/10/2014 by James Gaite}