1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-01 15:00:38 +00:00
QB64-PE/internal/help/_FONTHEIGHT.txt

59 lines
2.1 KiB
Plaintext
Raw Normal View History

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]].
{{PageSyntax}}
2017-10-10 14:55:21 +00:00
:{{Parameter|pixelHeight%}} = [[_FONTHEIGHT]][({{Parameter|fontHandle&}})]
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.
2017-10-10 14:55:21 +00:00
{{PageExamples}}
''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$
mode% = {{Cl|VAL}}(scr$)
2019-04-15 01:15:33 +00:00
{{Cl|LOOP}} {{Cl|UNTIL}} mode% > 0
{{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}}
{{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$
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}}
{{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)
{{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
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}}
<