FONT

From QB64 Wiki
Revision as of 10:14, 18 September 2010 by imported>Clippy
Jump to navigation Jump to search

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


Syntax

_FONT Font_handle[, Image_handle&]


Description

  • If the image handle is omitted the current image destination is used.
  • Font_handle is the handle retrieved from _LOADFONT function, the _FONT function, or a predefined handle.
  • Predefined QB64 font handles;
    • _FONT 8 - default font for SCREEN 1, 2, 7, 8 and 13
    • _FONT 14 - default font for SCREEN 9 and 10
    • _FONT 16 - default font for SCREEN 0 (WIDTH 80, 25 text only), 11 and 12
    • _FONT 9, 15 and 17 are the double width versions of 8, 14 and 16 in textmode(SCREEN 0) only.
  • Can alpha blend a font with a background screen created by _NEWIMAGE in 32 bit color.
  • Check for valid (values > 0) handle values before using or freeing the font handles!
  • Free unused font handles with _FREEFONT. Freeing invalid handles will create an "illegal function call" error!
  • NOTE: SCREEN 0 can only use ONE font type and style per SCREEN page!


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

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

_FONT (function)

_LOADFONT

_FREEFONT



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page