_FONTHEIGHT - mkilgore/QB64pe GitHub Wiki

The _FONTHEIGHT function returns the font height of a font handle created by _LOADFONT.

Syntax

pixelHeight% = _FONTHEIGHT[(fontHandle&)]

Description

  • Returns the height of the last font used if a handle is not designated.
  • If no font is set it returns the current screen mode's text block height.

Examples

Example: Finding the font or text block size of printed string characters in graphic SCREEN modes.

INPUT "Enter first name of TTF font to use or hit enter for text block size: ", TTFont$
IF...THEN LEN(TTFont$) THEN INPUT "Enter font height: ", hi$
height& = VAL(hi$)
IF...THEN height& > 0 THEN
  fnt& = _LOADFONT("C:\Windows\Fonts\" + TTFont$ + ".ttf", height&, style$)
  IF...THEN fnt& <= 0 THEN PRINT "Invalid Font handle!": END
  _FONT fnt&
END IF

TextSize wide&, high& 'get the font or current screen mode's text block pixel size

_PRINTSTRING (20, 100), "Block size = " + CHR$(1) + STR$(wide&) + " X" + STR$(high&) + " " + CHR$(2)

END

SUB TextSize (TextWidth&, TextHeight&)
TextWidth& = _PRINTWIDTH("W") 'measure width of one font or text character
TextHeight& = _FONTHEIGHT 'can measure normal text block heights also
END SUB '' ''

See also


Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page
⚠️ **GitHub.com Fallback** ⚠️