BB___FONT

=FONT= toc

Description
> Fonts are //specified// using the FONT command string. The FONT specifier includes:
 * //font facename//
 * //font size//
 * optional modifiers: //bold, italic, strikeout, and underline//

Syntax

 * Controls that do not support changing their caption**
 * 1) "font //faceName fontSize [optional modifier]//"

>> //(Button, Static Text, Group Box, Text Box, Text Editor)//
 * Controls that support changing their caption (notice the leading exclamation point)**
 * 1) "!font //faceName fontSize [optional modifier]//"

Hints
> The font //faceName// is case insensitive. Font names consisting of more that one word, must have the words connected by an underscore (_). ie: courier_new. > Font sizes are usually specified in points, but may be spec'd in pixels. >> When specifying in pixels, include both width and height of font. If width is set to 0, the default width for that font face height will be used. >> When specifying in points, only one parameter is required; the point size, which is it's height. ie: 12 point. > Visible size of a font specified in points will change with DPI settings - that is, it could differ on another computer. If you want text fit to your GUI on different computers, you might specify size in pixels. > If font width specified in pixels, be aware that sometimes Windows fails to set exact required width: >> //Liberty BASIC asks Windows for the specified font ... In either case, Windows will return whatever font Windows returns. Sometimes that may not even be the font named in the request. Font systems are a funny thing.// >> (CarlG) > If font specified (e.g. as "font consolas 16 bold") is not found on user system, it would end up with default font (probably Arial) but with size and style specified (16 bold).

Fonts in the mainwin
> Font statements are not used to set fonts in the mainwin. The mainwin adopts the IDE font and size. In the IDE click on setup, editor font and choose one that you prefer. (//thanks to Rod//). > These selections are stored in the JB INI file (//justbasic1.ini//). If you want your distributed program to use the same mainwin font as you have specified for running it through the IDE, you must include the //justbasic1.ini// with your distribution package.

Specifying Fonts
code format="lb" ' A basic font specification "font Arial 10"             ' 10 point Arial font ' A font spec with an optional modifier "font courier_new 12 bold"  ' 12 point bold Courier New ' Specifying a font with pixels "font MS_SANS_SERIF 5 14"   ' font is 5 pixels wide x 14 pixels high code

Setting the Font for the entire Window
//Sets the font of all the controls in a window. This is an optional command. Without it, the system default font spec will be used.// code format="lb" nomainwin ' the text in this static text control definition will be printed statictext #fontTest.st1, "This is a font test...", 10, 10, 200, 200 textbox #fontTest.tb1, 10, 220, 200, 30

open "Font Test" for window as #fontTest print #fontTest, "trapclose [quit]"

' send the font spec to the window with the PRINT command ' all controls in the window will use this font print #fontTest, "font consolas 16 bold"

' print this text to the text box print #fontTest.tb1, "consolas 16 point bold font" wait

[quit] close #fontTest end code

Setting the Font for individual Controls
//Overrides the General font for individual controls.// code format="lb" nomainwin statictext #fontTest.st1, "This is a font test.", 10, 10, 200, 200 textbox #fontTest.tb1, 10, 220, 200, 25

open "Font Test" for window as #fontTest print #fontTest, "trapclose [quit]"

' The General font spec; The static text control will use this font spec. print #fontTest, "font consolas 16 bold"

' a separate spec is sent to the text box control ' note the preceding exclamation point (!) which is required when ' sending commands to controls that also display text. print #fontTest.tb1, "!font arial 10"

' the text box text will be displayed in arial 10 pt. print #fontTest.tb1, "arial 10 point font" wait

[quit] close #fontTest end code

Useful Functions
code format="lb" ' Place a useful function using this keyword here code