1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 12:50:37 +00:00
QB64-PE/internal/help/_FONTHEIGHT.txt
SteveMcNeill 33adc04fc4 Add temp folder to repo. It's necessary as well!
Just more initial setting on... nothing much to see here.
2022-04-28 13:39:56 -04:00

59 lines
2.1 KiB
Plaintext

{{DISPLAYTITLE:_FONTHEIGHT}}
The [[_FONTHEIGHT]] function returns the font height of a font handle created by [[_LOADFONT]].
{{PageSyntax}}
:{{Parameter|pixelHeight%}} = [[_FONTHEIGHT]][({{Parameter|fontHandle&}})]
{{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.
{{PageExamples}}
''Example:'' Finding the [[_FONT|font]] or text block size of printed [[STRING|string]] characters in graphic [[SCREEN]] modes.
{{CodeStart}} '' ''
DO
{{Cl|INPUT}} "Enter Screen mode 1, 2 or 7 to 13 or 256, 32 for {{Cl|_NEWIMAGE}}: ", scr$
mode% = {{Cl|VAL}}(scr$)
{{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%)
{{Cl|CASE ELSE}}: {{Cl|PRINT}} "Invalid mode selected!": {{Cl|END}}
{{Cl|END SELECT}}
{{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$)
{{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
{{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&)
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)
{{PageNavigation}}
<