Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Confusing Chr$ explanation
#34
Here you have a code that demonstrates the whole thing

With the arrow keys left and right can you change the height of the TTF Font

Code: (Select All)
OPTION _EXPLICIT

' Screen mode 13 with 640x480 
SCREEN _NEWIMAGE(640, 480, 13)

DIM keyin AS STRING
DIM curHeight AS INTEGER ' current height of TTF Font
DIM oldHeight AS INTEGER ' old height of TTF Font 
DIM FNThandle AS LONG '    Image handle

' This is for the TEXTfield positions
DIM MAXwidth AS INTEGER
DIM MAXheight AS INTEGER

curHeight = 32

FNThandle = _LOADFONT("C:\WINDOWS\fonts\courbd.ttf", curHeight, "monospace")
_FONT FNThandle

DO

  IF oldHeight <> curHeight THEN
    _FONT 16
    _FREEFONT FNThandle
    FNThandle = _LOADFONT("C:\WINDOWS\fonts\courbd.ttf", curHeight, "monospace")
    _FONT FNThandle
    oldHeight = curHeight
  END IF

  ' Rounding down the TEXTfield to a Integer
  MAXwidth = FIX(_WIDTH / _FONTWIDTH)
  MAXheight = FIX(_HEIGHT / _FONTHEIGHT)

  CLS , 7

  COLOR 7, 1
  LOCATE 1, 1: PRINT SPACE$(MAXwidth);
  LOCATE MAXheight, 1: PRINT SPACE$(MAXwidth);
  LOCATE 1, 2: PRINT "This is a TTF Font Example";
  LOCATE MAXheight, 2: PRINT "ESC - EXIT";

  COLOR 0, 7
  LOCATE 3, 2: PRINT "Screen Res : " + LTRIM$(STR$(_WIDTH)) + "x" + LTRIM$(STR$(_HEIGHT));
  LOCATE 4, 2: PRINT "Font   Res : " + LTRIM$(STR$(_FONTWIDTH)) + "x" + LTRIM$(STR$(_FONTHEIGHT));
  LOCATE 5, 2: PRINT "TextRes RD : " + LTRIM$(STR$(CLNG((_WIDTH / _FONTWIDTH) * 100) / 100)) + "x" + LTRIM$(STR$(CLNG((_HEIGHT / _FONTHEIGHT) * 100) / 100));
  LOCATE 6, 2: PRINT "TextRes INT: " + LTRIM$(STR$(MAXwidth)) + "x" + LTRIM$(STR$(MAXheight));
  LOCATE 7, 2: PRINT "FNT handle : " + LTRIM$(STR$(_FONT));

  LOCATE 9, 2: PRINT "<- Size -1";
  LOCATE 9, MAXwidth - 10: PRINT "Size +1 ->";

  DO
    COLOR 7, 1
    LOCATE MAXheight, MAXwidth - LEN(TIME$) + 1: PRINT TIME$;
    keyin = INKEY$
  LOOP WHILE keyin = ""

  IF keyin = CHR$(0) + CHR$(77) THEN IF curHeight < 32 THEN curHeight = curHeight + 1
  IF keyin = CHR$(0) + CHR$(75) THEN IF curHeight > 1 THEN curHeight = curHeight - 1

LOOP WHILE keyin <> CHR$(27)
SYSTEM
Reply


Messages In This Thread
Confusing Chr$ explanation - by PhilOfPerth - 07-07-2023, 01:18 AM
RE: Confusing Chr$ explanation - by CharlieJV - 07-07-2023, 01:31 AM
RE: Confusing Chr$ explanation - by PhilOfPerth - 07-07-2023, 01:49 AM
RE: Confusing Chr$ explanation - by Space_Ghost - 07-07-2023, 01:52 AM
RE: Confusing Chr$ explanation - by mnrvovrfc - 07-08-2023, 02:49 AM
RE: Confusing Chr$ explanation - by PhilOfPerth - 07-07-2023, 03:36 AM
RE: Confusing Chr$ explanation - by Space_Ghost - 07-07-2023, 04:52 AM
RE: Confusing Chr$ explanation - by PhilOfPerth - 07-07-2023, 05:39 AM
RE: Confusing Chr$ explanation - by Space_Ghost - 07-07-2023, 06:16 AM
RE: Confusing Chr$ explanation - by PhilOfPerth - 07-08-2023, 12:47 AM
RE: Confusing Chr$ explanation - by Space_Ghost - 07-08-2023, 01:14 AM
RE: Confusing Chr$ explanation - by SagaraS - 07-08-2023, 08:52 AM
RE: Confusing Chr$ explanation - by bplus - 07-08-2023, 02:05 PM
RE: Confusing Chr$ explanation - by Space_Ghost - 07-08-2023, 03:59 PM
RE: Confusing Chr$ explanation - by SagaraS - 07-08-2023, 07:35 PM
RE: Confusing Chr$ explanation - by TempodiBasic - 07-08-2023, 09:30 PM
RE: Confusing Chr$ explanation - by mnrvovrfc - 07-08-2023, 10:44 PM
RE: Confusing Chr$ explanation - by PhilOfPerth - 07-09-2023, 02:49 AM
RE: Confusing Chr$ explanation - by TempodiBasic - 07-09-2023, 03:10 PM
RE: Confusing Chr$ explanation - by PhilOfPerth - 07-09-2023, 04:22 AM
RE: Confusing Chr$ explanation - by Space_Ghost - 07-09-2023, 07:43 AM
RE: Confusing Chr$ explanation - by RhoSigma - 07-09-2023, 08:05 AM
RE: Confusing Chr$ explanation - by TempodiBasic - 07-09-2023, 03:48 PM
RE: Confusing Chr$ explanation - by PhilOfPerth - 07-10-2023, 01:29 AM
RE: Confusing Chr$ explanation - by SagaraS - 07-09-2023, 08:12 AM
RE: Confusing Chr$ explanation - by SagaraS - 07-09-2023, 11:50 AM
RE: Confusing Chr$ explanation - by TempodiBasic - 07-09-2023, 04:40 PM
RE: Confusing Chr$ explanation - by SagaraS - 07-10-2023, 11:23 AM
RE: Confusing Chr$ explanation - by mnrvovrfc - 07-10-2023, 03:34 PM
RE: Confusing Chr$ explanation - by mnrvovrfc - 07-11-2023, 04:17 PM
RE: Confusing Chr$ explanation - by PhilOfPerth - 07-12-2023, 06:03 AM
RE: Confusing Chr$ explanation - by SMcNeill - 07-16-2023, 11:00 PM
RE: Confusing Chr$ explanation - by SagaraS - 07-15-2023, 08:47 AM
RE: Confusing Chr$ explanation - by PhilOfPerth - 07-16-2023, 12:18 AM
RE: Confusing Chr$ explanation - by SagaraS - 07-16-2023, 10:31 AM
RE: Confusing Chr$ explanation - by mnrvovrfc - 07-16-2023, 05:06 PM
RE: Confusing Chr$ explanation - by bplus - 07-16-2023, 05:53 PM
RE: Confusing Chr$ explanation - by mnrvovrfc - 07-16-2023, 07:35 PM
RE: Confusing Chr$ explanation - by SagaraS - 07-16-2023, 08:24 PM
RE: Confusing Chr$ explanation - by PhilOfPerth - 07-16-2023, 11:24 PM
RE: Confusing Chr$ explanation - by SMcNeill - 07-16-2023, 11:42 PM
RE: Confusing Chr$ explanation - by PhilOfPerth - 07-17-2023, 01:10 AM
RE: Confusing Chr$ explanation - by bplus - 07-17-2023, 01:18 AM
RE: Confusing Chr$ explanation - by PhilOfPerth - 07-17-2023, 01:34 AM
RE: Confusing Chr$ explanation - by bplus - 07-17-2023, 01:41 AM
RE: Confusing Chr$ explanation - by PhilOfPerth - 07-17-2023, 01:49 AM
RE: Confusing Chr$ explanation - by bplus - 07-17-2023, 02:08 AM
RE: Confusing Chr$ explanation - by PhilOfPerth - 07-17-2023, 02:33 AM



Users browsing this thread: 4 Guest(s)