2016-03-18 11:36:04 +00:00
|
|
|
{{DISPLAYTITLE:_FONTHEIGHT}}
|
2017-10-10 14:55:21 +00:00
|
|
|
The [[_FONTHEIGHT]] function returns the font height of a font handle created by [[_LOADFONT]].
|
2015-08-02 12:12:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{{PageSyntax}}
|
2017-10-10 14:55:21 +00:00
|
|
|
:{{Parameter|pixelHeight%}} = [[_FONTHEIGHT]][({{Parameter|fontHandle&}})]
|
2015-08-02 12:12:44 +00:00
|
|
|
|
|
|
|
|
2017-10-10 14:55:21 +00:00
|
|
|
{{PageDescription}}
|
|
|
|
* 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.
|
2015-08-02 12:12:44 +00:00
|
|
|
|
|
|
|
|
2017-10-10 14:55:21 +00:00
|
|
|
{{PageExamples}}
|
2015-08-02 12:12:44 +00:00
|
|
|
''Example:'' Finding the [[_FONT|font]] or text block size of printed [[STRING|string]] characters in graphic [[SCREEN]] modes.
|
|
|
|
{{CodeStart}} '' ''
|
|
|
|
DO
|
2019-04-15 01:15:33 +00:00
|
|
|
{{Cl|INPUT}} "Enter Screen mode 1, 2 or 7 to 13 or 256, 32 for {{Cl|_NEWIMAGE}}: ", scr$
|
2015-08-02 12:12:44 +00:00
|
|
|
mode% = {{Cl|VAL}}(scr$)
|
2019-04-15 01:15:33 +00:00
|
|
|
{{Cl|LOOP}} {{Cl|UNTIL}} mode% > 0
|
2015-08-02 12:12:44 +00:00
|
|
|
{{Cl|SELECT CASE}} mode%
|
|
|
|
{{Cl|CASE}} 1, 2, 7 {{Cl|TO}} 13: {{Cl|SCREEN}} mode%
|
|
|
|
{{Cl|CASE}} 256, 32: {{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, mode%)
|
2019-04-15 01:15:33 +00:00
|
|
|
{{Cl|CASE ELSE}}: {{Cl|PRINT}} "Invalid mode selected!": {{Cl|END}}
|
2015-08-02 12:12:44 +00:00
|
|
|
{{Cl|END SELECT}}
|
|
|
|
|
2019-04-15 01:15:33 +00:00
|
|
|
{{Cl|INPUT}} "Enter first name of TTF font to use or hit enter for text block size: ", TTFont$
|
|
|
|
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(TTFont$) {{Cl|THEN}} {{Cl|INPUT}} "Enter font height: ", hi$
|
2015-08-02 12:12:44 +00:00
|
|
|
height& = {{Cl|VAL}}(hi$)
|
2019-04-15 01:15:33 +00:00
|
|
|
{{Cl|IF...THEN|IF}} height& > 0 {{Cl|THEN}}
|
|
|
|
fnt& = {{Cl|_LOADFONT}}("C:\Windows\Fonts\" + TTFont$ + ".ttf", height&, style$)
|
|
|
|
{{Cl|IF...THEN|IF}} fnt& <= 0 {{Cl|THEN}} {{Cl|PRINT}} "Invalid Font handle!": {{Cl|END}}
|
2015-08-02 12:12:44 +00:00
|
|
|
{{Cl|_FONT}} fnt&
|
|
|
|
{{Cl|END IF}}
|
|
|
|
|
|
|
|
TextSize wide&, high& 'get the font or current screen mode's text block pixel size
|
|
|
|
|
2019-04-15 01:15:33 +00:00
|
|
|
{{Cl|_PRINTSTRING}} (20, 100), "Block size = " + {{Cl|CHR$}}(1) + {{Cl|STR$}}(wide&) + " X" + {{Cl|STR$}}(high&) + " " + {{Cl|CHR$}}(2)
|
2015-08-02 12:12:44 +00:00
|
|
|
|
|
|
|
{{Cl|END}}
|
|
|
|
|
|
|
|
{{Cl|SUB}} TextSize (TextWidth&, TextHeight&)
|
2019-04-15 01:15:33 +00:00
|
|
|
TextWidth& = {{Cl|_PRINTWIDTH}}("W") 'measure width of one font or text character
|
2015-08-02 12:12:44 +00:00
|
|
|
TextHeight& = {{Cl|_FONTHEIGHT}} 'can measure normal text block heights also
|
|
|
|
{{Cl|END SUB}} '' ''
|
|
|
|
{{CodeEnd}}
|
|
|
|
|
|
|
|
|
|
|
|
{{PageSeeAlso}}
|
|
|
|
* [[_FONTWIDTH]], [[_FONT]]
|
|
|
|
* [[_PRINTWIDTH]], [[_PRINTSTRING]]
|
|
|
|
* [[SCREEN]], [[_LOADFONT]]
|
|
|
|
* [[Text Using Graphics]] (Demo)
|
|
|
|
|
|
|
|
|
2019-04-15 01:15:33 +00:00
|
|
|
{{PageNavigation}}
|