QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The _FONT statement sets the current _LOADFONT function font handle to be used by PRINT.

Syntax

_FONT fontHandle&[, imageHandle&]

Parameter(s)

Description

Example(s)

Previewing a font in SCREEN 0. A different true type font can be substituted below.


fontpath$ = ENVIRON$("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path.
DO: CLS
  DO
    style$ = "MONOSPACE"
    PRINT
    INPUT "Enter A FONT Size 8 TO 25: ", fontsize%
  LOOP UNTIL fontsize% > 7 and fontsize% < 26
  DO
    PRINT
    INPUT "Enter (0) for REGULAR OR (1) for ITALIC FONT: ", italic%
  LOOP UNTIL italic% = 0 or italic% = 1
  DO
    PRINT
    INPUT "Enter (0) for REGULAR OR (1) for BOLD FONT: ", bold%
  LOOP UNTIL italic% = 0 or italic% = 1
  IF italic% = 1 THEN style$ = style$ + ", ITALIC"
  IF bold% = 1 then style$ = style$ + ", BOLD"

  GOSUB ClearFont
  font& = _LOADFONT(fontpath$, fontsize%, style$)
  _FONT font&  
  PRINT
  PRINT "This is your LUCON font! Want to try another STYLE?(Y/N): "; 
  DO: SLEEP: K$ = UCASE$(INKEY$): LOOP UNTIL K$ = "Y" OR K$ = "N"
LOOP UNTIL K$ = "N"
GOSUB ClearFont

PRINT "This is the QB64 default _FONT 16!"
END

ClearFont: 
IF font& > 0 THEN
    _FONT 16   'select inbuilt 8x16 default font
    _FREEFONT font&
END IF
RETURN

NOTE: ENVIRON$(“SYSTEMROOT”) returns a string value of: “C:\WINDOWS”. Add the “\FONTS" folder and the .TTF font file name.

See Also