1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-26 14:25:53 +00:00
QB64-PE/internal/help/_FONTHEIGHT.txt
SMcNeill 6e01fc8dce Altered string compare routines (<,<=,>,>=) so they don't give false results with CHR$(0).
Added new _STRCMP and _STRICMP commands for quick string comparisons.
Cleaned up QB64 to finish removing the QUI (quick user insert) code and folders.
Altered UCASE and LCASE routines to be faster in some situations for us.
2014-09-22 08:19:03 -04:00

54 lines
2.1 KiB
Plaintext

The '''_FONTHEIGHT''' function returns the font height of a font handle created by {{KW|_LOADFONT}}.
{{PageSyntax}}
:{{Parameter|pixel_height%}} = {{KW|_FONTHEIGHT}}[({{Parameter|font_handle}})]
* Will return height of the last font used if a handle is not designated.
* If no font is used it returns the current screen mode's text block height.
''Example:'' Finding the [[_FONT|font]] or text block size of printed [[STRING|string]] characters in graphic [[SCREEN]] modes.
{{CodeStart}} '' ''
DO
{{Cl|INPUT}} &quot;Enter Screen mode 1, 2 or 7 to 13 or 256, 32 for {{Cl|_NEWIMAGE}}: &quot;, scr$
mode% = {{Cl|VAL}}(scr$)
{{Cl|LOOP}} {{Cl|UNTIL}} mode% &gt; 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}} &quot;Invalid mode selected!&quot;: {{Cl|END}}
{{Cl|END SELECT}}
{{Cl|INPUT}} &quot;Enter first name of TTF font to use or hit enter for text block size: &quot;, TTFont$
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(TTFont$) {{Cl|THEN}} {{Cl|INPUT}} &quot;Enter font height: &quot;, hi$
height&amp; = {{Cl|VAL}}(hi$)
{{Cl|IF...THEN|IF}} height&amp; &gt; 0 {{Cl|THEN}}
fnt&amp; = {{Cl|_LOADFONT}}(&quot;C:\Windows\Fonts\&quot; + TTFont$ + &quot;.ttf&quot;, height&amp;, style$)
{{Cl|IF...THEN|IF}} fnt&amp; &lt;= 0 {{Cl|THEN}} {{Cl|PRINT}} &quot;Invalid Font handle!&quot;: {{Cl|END}}
{{Cl|_FONT}} fnt&amp;
{{Cl|END IF}}
TextSize wide&amp;, high&amp; 'get the font or current screen mode's text block pixel size
{{Cl|_PRINTSTRING}} (20, 100), &quot;Block size = &quot; + {{Cl|CHR$}}(1) + {{Cl|STR$}}(wide&amp;) + &quot; X&quot; + {{Cl|STR$}}(high&amp;) + &quot; &quot; + {{Cl|CHR$}}(2)
{{Cl|END}}
{{Cl|SUB}} TextSize (TextWidth&amp;, TextHeight&amp;)
TextWidth&amp; = {{Cl|_PRINTWIDTH}}(&quot;W&quot;) 'measure width of one font or text character
TextHeight&amp; = {{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}}