FONTHEIGHT (function): Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:_FONTHEIGHT (function)}} | {{DISPLAYTITLE:_FONTHEIGHT (function)}} | ||
The [[_FONTHEIGHT]] function returns the font height of a font handle created by [[_LOADFONT]]. | The [[_FONTHEIGHT]] function returns the font height of a font handle created by [[_LOADFONT]]. | ||
{{PageSyntax}} | {{PageSyntax}} | ||
:{{Parameter|pixelHeight%}} = [[_FONTHEIGHT]][({{Parameter|fontHandle&}})] | :{{Parameter|pixelHeight%}} = [[_FONTHEIGHT]][({{Parameter|fontHandle&}})] | ||
Line 15: | Line 14: | ||
{{PageExamples}} | {{PageExamples}} | ||
''Example:'' Finding the [[_FONT|font]] or text block size of printed [[STRING|string]] characters in graphic [[SCREEN]] modes. | ''Example:'' Finding the [[_FONT|font]] or text block size of printed [[STRING|string]] characters in graphic [[SCREEN]] modes. | ||
{{CodeStart}} | {{CodeStart}} | ||
DO | DO | ||
{{Cl|INPUT}} "Enter Screen mode 1, 2 or 7 to 13 or 256, 32 for {{Cl|_NEWIMAGE}}: ", scr$ | {{Cl|INPUT}} "Enter Screen mode 1, 2 or 7 to 13 or 256, 32 for {{Cl|_NEWIMAGE}}: ", scr$ | ||
Line 44: | Line 43: | ||
TextWidth& = {{Cl|_PRINTWIDTH}}("W") 'measure width of one font or text character | TextWidth& = {{Cl|_PRINTWIDTH}}("W") 'measure width of one font or text character | ||
TextHeight& = {{Cl|_FONTHEIGHT}} 'can measure normal text block heights also | TextHeight& = {{Cl|_FONTHEIGHT}} 'can measure normal text block heights also | ||
{{Cl|END SUB}} | {{Cl|END SUB}} | ||
{{CodeEnd}} | {{CodeEnd}} | ||
Latest revision as of 00:36, 29 January 2023
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.
DO INPUT "Enter Screen mode 1, 2 or 7 to 13 or 256, 32 for _NEWIMAGE: ", scr$ mode% = VAL(scr$) LOOP UNTIL mode% > 0 SELECT CASE mode% CASE 1, 2, 7 TO 13: SCREEN mode% CASE 256, 32: SCREEN _NEWIMAGE(800, 600, mode%) CASE ELSE: PRINT "Invalid mode selected!": END END SELECT INPUT "Enter first name of TTF font to use or hit enter for text block size: ", TTFont$ IF LEN(TTFont$) THEN INPUT "Enter font height: ", hi$ height& = VAL(hi$) IF height& > 0 THEN fnt& = _LOADFONT("C:\Windows\Fonts\" + TTFont$ + ".ttf", height&, style$) IF 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