'=========================================================================== ' Subject: TINY FONTS (6X8) FOR PB Date: 08-21-99 (16:10) ' Author: Dieter Folger Code: PB ' Origin: folger@bamberg.baynet.de Packet: GRAPHICS.ABC '=========================================================================== '--------------------------------------------------------------------------- 'TINYFONT.BAS for PowerBasic '6x8 font for use in graphic mode 12 'For constructing font characters see end of file 'Based on the font that Sami Ky”stil„ uses for his WINDOZE GUI '--------------------------------------------------------------------------- DEFINT A - Z DIM Font (33:144) AS SHARED STRING 'change if you construct more chars LoadFont 'read font into array SCREEN 12 LINE (0,0)-(640,480),3,BF 'paint the screen '-------------Demo program ------------ 'Normal VGA font first: LOCATE 5,2 : PRINT " This is a demo of the 6x8 font:" PrintText 10, 100, "The text doesn't erase the background", 0, 16 'Value 16 for BgCol doesn't erase existing background PrintText 10, 120, "You can use a different background color", 15, 1 'Use blue background here 'Show all chars included in TinyFont: FOR i = 33 TO 88 : S1$ = S1$ + CHR$(i):NEXT FOR i = 89 TO 144 : S2$ = S2$ + CHR$(i):NEXT PrintText 10, 140, "These are the 112 characters in the font:", 4, 14 PrintText 10, 160, S1$, 15, 16 PrintText 10, 170, S2$, 15, 16 '3d text T$ = "This line is printed with a 3d effect" PrintText 10, 190, T$, 0, 7 PrintText 10-1, 190-1, T$, 15, 16 ' bold text T$ = "This line is printed bold" PrintText 10, 210, T$, 0, 16 PrintText 10+1, 210, T$, 0, 16 PrintText 10,230,STRING$(103,"="),15,16 END '----------------------------------------------------------------------------- SUB LoadFont '---------------------------------------------------------------------------- FOR i = 33 TO 144 FOR j = 1 to 8 READ c Font(i) = Font(i) + CHR$(c) NEXT NEXT END SUB '---------------------------------------------------------------------------- SUB PrintText (x, y, Text$, FgCol, BgCol) '---------------------------------------------------------------------------- FOR i = 1 TO LEN(Text$) IF BgCol <> 16 THEN 'then we draw a square in background color (speed!) LINE (x - 1, y - 1)-(x + 6, y + 8), BgCol, BF END IF SELECT CASE MID$(Text$,i,1) 'special German characters: CASE " " : GOTO SkipSpace CASE "α" : MID$(Text$, i, 1) = CHR$(127) CASE "š" : MID$(Text$, i, 1) = CHR$(128) CASE "" : MID$(Text$, i, 1) = CHR$(129) CASE "™" : MID$(Text$, i, 1) = CHR$(130) CASE "”" : MID$(Text$, i, 1) = CHR$(131) CASE "„" : MID$(Text$, i, 1) = CHR$(132) CASE "Ž" : MID$(Text$, i, 1) = CHR$(142) END SELECT Cr$ = Font(ASC(Mid$(Text$,i,1))) PrintChar x, y, Cr$, FgCol SkipSpace: INCR x, 6 'move x-position pointer NEXT END SUB '--------------------------------------------------------------------------- SUB PrintChar (x, y, Cr$, Col) '--------------------------------------------------------------------------- c = 1 FOR Ypos = 0 TO 7 FontLine = ASC(MID$(Cr$,c,1)) FOR Xpos = 0 TO 5 IF BIT(FontLine, Xpos) THEN PSET(x + 5 - Xpos, y + Ypos),Col NEXT INCR c NEXT END SUB '---------------------------------------------------------------------------- ' Font data area '---------------------------------------------------------------------------- ' ! 33 DATA 08,28,28,08,08,00,08,00 ' " 34 DATA 54,54,36,00,00,00,00,00 ' # 35 DATA 00,20,62,20,20,62,20,00 ' $ 36 DATA 16,28,32,24,04,56,08,00 ' % 37 DATA 50,50,04,08,16,38,38,00 ' & 38 DATA 16,40,40,16,42,36,26,00 ' DATA 39 DATA 24,24,16,00,00,00,00,00 ' ( 40 DATA 08,16,16,16,16,16,08,00 ' ) 41 DATA 16,08,08,08,08,08,16,00 ' * 42 DATA 00,20,28,62,28,20,00,00 ' + 43 DATA 00,08,08,62,08,08,00,00 ' , 44 DATA 00,00,00,00,00,24,24,16 ' - 45 DATA 00,00,00,30,00,00,00,00 ' . 46 DATA 00,00,00,00,00,24,24,00 ' / 47 DATA 00,02,04,08,16,32,00,00 ' 0 48 DATA 28,34,38,42,50,34,28,00 ' 1 49 DATA 08,24,08,08,08,08,28,00 ' 2 50 DATA 28,34,02,12,16,32,62,00 ' 3 51 DATA 28,34,02,28,02,34,28,00 ' 4 52 DATA 04,12,20,36,62,04,04,00 ' 5 53 DATA 62,32,32,60,02,34,28,00 ' 6 54 DATA 12,16,32,60,34,34,28,00 ' 7 55 DATA 63,02,04,08,16,16,16,00 ' 8 56 DATA 28,34,34,28,34,34,28,00 ' 9 57 DATA 28,34,34,30,02,04,24,00 ' ; 58 DATA 00,00,24,24,00,24,24,00 ' ' 59 DATA 00,00,24,24,00,24,24,16 ' < 60 DATA 04,08,16,32,16,08,04,00 ' = 61 DATA 00,00,63,00,00,63,00,00 ' > 62 DATA 16,08,04,02,04,08,16,00 ' ? 63 DATA 28,34,02,12,08,00,08,00 ' @ 64 DATA 28,34,46,42,46,32,28,00 ' A 65 DATA 28,34,34,34,62,34,34,00 ' B 66 DATA 60,34,34,60,34,34,60,00 ' C 67 DATA 28,34,32,32,32,34,28,00 ' D 68 DATA 60,34,34,34,34,34,60,00 ' E 69 DATA 63,32,32,60,32,32,63,00 ' F 70 DATA 63,32,32,60,32,32,32,00 ' G 71 DATA 28,34,32,46,34,34,30,00 ' H 72 DATA 34,34,34,62,34,34,34,00 ' I 73 DATA 28,08,08,08,08,08,28,00 ' J 74 DATA 02,02,02,02,34,34,28,00 ' K 75 DATA 34,36,40,48,40,36,34,00 ' L 76 DATA 32,32,32,32,32,32,62,00 ' M 77 DATA 34,54,42,34,34,34,34,00 ' N 78 DATA 34,50,42,38,34,34,34,00 ' O 79 DATA 28,34,34,34,34,34,28,00 ' P 80 DATA 60,34,34,60,32,32,32,00 ' Q 81 DATA 28,34,34,34,42,36,26,00 ' R 82 DATA 60,34,34,60,36,34,34,00 ' S 83 DATA 28,34,32,28,02,34,28,00 ' T 84 DATA 63,08,08,08,08,08,08,00 ' U 85 DATA 34,34,34,34,34,34,28,00 ' V 86 DATA 34,34,34,34,34,20,08,00 ' W 87 DATA 34,34,42,42,42,42,20,00 ' X 88 DATA 34,34,20,08,20,34,34,00 ' Y 89 DATA 34,34,34,20,08,08,08,00 ' Z 90 DATA 60,04,08,16,32,32,60,00 ' [ 91 DATA 28,16,16,16,16,16,28,00 ' \ 92 DATA 00,32,16,08,04,02,00,00 ' ] 93 DATA 28,04,04,04,04,04,28,00 ' ^ 94 DATA 08,20,34,00,00,00,00,00 ' _ 95 DATA 00,00,00,00,00,00,00,63 ' ` 96 DATA 24,24,08,00,00,00,00,00 ' a 97 DATA 00,00,28,02,30,34,30,00 ' b 98 DATA 32,32,60,34,34,34,60,00 ' c 99 DATA 00,00,28,34,32,34,28,00 ' d 100 DATA 02,02,30,34,34,34,30,00 ' e 101 DATA 00,00,28,34,62,32,28,00 ' f 102 DATA 12,16,16,60,16,16,16,00 ' g 103 DATA 00,00,30,34,34,30,02,28 ' h 104 DATA 32,32,56,36,36,36,36,00 ' i 105 DATA 08,00,08,08,08,08,12,00 ' j 106 DATA 04,00,12,04,04,04,36,24 ' k 107 DATA 32,32,36,40,48,40,36,00 ' l 108 DATA 08,08,08,08,08,08,12,00 ' m 109 DATA 00,00,52,42,42,42,42,00 ' n 110 DATA 00,00,56,36,36,36,36,00 ' o 111 DATA 00,00,28,34,34,34,28,00 ' p 112 DATA 00,00,60,34,34,34,60,32 ' q 113 DATA 00,00,30,34,34,34,30,02 ' r 114 DATA 00,00,44,18,16,16,56,00 ' s 115 DATA 00,00,30,32,30,02,60,00 ' t 116 DATA 00,16,60,16,16,20,08,00 ' u 117 DATA 00,00,36,36,36,36,26,00 ' v 118 DATA 00,00,34,34,34,20,08,00 ' w 119 DATA 00,00,34,34,42,62,20,00 ' x 120 DATA 00,00,36,36,24,36,36,00 ' y 121 DATA 00,00,36,36,36,28,08,48 ' z 122 DATA 00,00,60,04,24,32,60,00 ' { 123 DATA 12,16,16,48,16,16,12,00 ' | 124 DATA 08,08,08,00,08,08,08,00 ' } 125 DATA 24,04,04,06,04,04,24,00 ' ~ 126 DATA 20,40,00,00,00,00,00,00 ' α 127 DATA 12,20,20,18,18,18,20,00 ' š 128 DATA 34,00,34,34,34,34,28,00 '  129 DATA 00,36,00,36,36,36,26,00 ' ™ 130 DATA 34,28,34,34,34,34,28,00 ' ” 131 DATA 20,00,28,34,34,34,28,00 ' „ 132 DATA 20,00,28,02,30,34,30,00 ' up arrow 133 DATA 08,28,08,08,08,08,08,00 ' down arrow 134 DATA 08,08,08,08,08,28,08,00 ' right arrow 135 DATA 00,00,04,62,04,00,00,00 ' left arrow 136 DATA 00,00,08,31,08,00,00,00 ' diamond 137 DATA 00,12,18,33,33,18,12,00 ' ώ 138 DATA 00,00,30,30,30,30,00,00 ' cross 139 DATA 00,17,10,04,10,17,00,00 ' triangle up 140 DATA 00,00,08,28,62,00,00,00 ' triangle down 141 DATA 00,00,62,28,08,00,00,00 ' Ž 142 DATA 34,28,34,34,62,34,34,00 ' triangle right 143 DATA 00,16,24,28,24,16,00,00 ' triangle left 144 DATA 00,04,12,28,12,04,00,00 '--------------------------------------------------------------------------- ' Constructing font character bitmaps '--------------------------------------------------------------------------- ' Each font char is a 6x8 pattern ' Example of letter k (data line: 32,32,36,40,48,40,36,00) ' when you write the decimal values in binary you see: ' 1 0 0 0 0 0 = 32 dec ' 1 0 0 0 0 0 = 32 dec ' 1 0 0 1 0 0 = 36 dec ' 1 0 1 0 0 0 = 40 dec ' 1 1 0 0 0 0 = 48 dec ' 1 0 1 0 0 0 = 40 dec ' 1 0 0 1 0 0 = 36 dec ' 0 0 0 0 0 0 = 00 dec ' value 1 = pixel is set / value 0 = pixel not set ' Following this pattern and converting binary to decimal you can ' design your own characters (it's easier when you use a squared sheet ' of paper). '==== eof ==================================================================