![]() |
Forum Index : Microcontroller and PC projects : Font format
Author | Message | ||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I was asked to provide details about fonts to enable producing fonts on the CMM2. This program should give enough to get you started. It uses a large font to print something then reads the pixels to reassemble the first character. I would advise sticking to font sizes where the width by height is an exact multiple of 8. It will make life a lot easier. The output from this program is an exact copy of the included font first character. A good test to see if we have things working. CLS pixX = 100 pixY = 100 ' print something to play with TEXT pixX+1,pixY,CHR$(48),lt,9 PRINT @(10,150), "" ' move the cursor to somewhere safe charCount = 10 charStart = 48 charHeight = 50 charWidth = 32 ' print the header txt$ = HEX$(charCount,2)+HEX$(charStart,2)+HEX$(charHeight,2)+HEX$(charWidth,2) PRINT txt$ txt$ = "" FOR y = 0 TO charHeight-1 FOR x = 0 TO charWidth -1 IF PIXEL(pixX+x,pixY+y)= 0 THEN pxl = 0 ELSE pxl = 1 outBuffer% = (outbuffer%<<1)+ pxl '<<7) IF b MOD 8 = 0 AND b <> 0 THEN ' we have filled the first output group chunk% = (chunk%>>8) + (outbuffer%<<24) outBuffer% = 0 ENDIF IF b MOD 32 = 0 AND b <> 0 THEN ' we have a 'word' txt$ = txt$+ HEX$(chunk%,8)+" " ' fill the output line IF LEN(txt$) > 70 THEN PRINT txt$ txt$ = "" ENDIF chunk% = 0 ENDIF b = b + 1 NEXT x NEXT y txt$ = txt$+ HEX$(chunk%,8)+" " PRINT txt$ END DEFINEFONT #9 0A303220 00000000 00000000 00FEFF00 00FFFF01 80FFFF03 60FFFF01 F0FEFF0C F801001E F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F 7800003E 18000038 08000020 00000000 00000020 18000038 7800003E F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F000001E 60FEFF0C 00FFFF01 80FFFF03 00FFFF01 00FEFF00 00000000 00000000 00000000 00000000 00000000 00000000 00000000 60000000 F0000000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 78000000 18000000 08000000 00000000 00000000 18000000 78000000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F0000000 60000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00FEFF00 00FFFF01 80FFFF03 60FFFF01 F0FEFF00 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 78000000 18FEFF01 88FFFF03 E0FFFF0F C0FFFF27 00FFFF39 0000003E 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000001E 00FEFF0C 00FFFF01 80FFFF03 00FFFF01 00FEFF00 00000000 00000000 00000000 00000000 00FEFF00 00FFFF01 80FFFF03 60FFFF01 F0FEFF00 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 78000000 18FEFF01 88FFFF03 E0FFFF0F C0FFFF07 18FFFF01 78000000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F0000000 60FEFF00 00FFFF01 80FFFF03 00FFFF01 00FEFF00 00000000 00000000 00000000 00000000 00000000 00000000 00000000 60000000 F000000C F801001E F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F 7800003E 18FEFF39 88FFFF23 E0FFFF0F C0FFFF07 18FFFF01 78000000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F0000000 60000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00FEFF00 00FFFF01 80FFFF03 00FFFF01 00FEFF0C 0000001E 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003E 00FEFF39 80FFFF23 E0FFFF0F C0FFFF07 18FFFF01 78000000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F0000000 60FEFF00 00FFFF01 80FFFF03 00FFFF01 00FEFF00 00000000 00000000 00000000 00000000 00FEFF00 00FFFF01 80FFFF03 00FFFF01 00FEFF0C 0000001E 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003F 0000003E 00FEFF39 80FFFF23 E0FFFF0F C0FFFF27 18FFFF39 7800003E F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F000001E 60FEFF0C 00FFFF01 80FFFF03 00FFFF01 00FEFF00 00000000 00000000 00000000 00000000 00FEFF00 00FFFF01 80FFFF03 60FFFF01 F0FEFF00 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 78000000 18000000 08000000 00000000 00000000 18000000 78000000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F0000000 60000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00FEFF00 00FFFF01 80FFFF03 60FFFF01 F0FEFF0C F801001E F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F 7800003E 18FEFF39 88FFFF23 E0FFFF0F C0FFFF27 18FFFF39 7800003E F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F000001E 60FEFF0C 00FFFF01 80FFFF03 00FFFF01 00FEFF00 00000000 00000000 00000000 00000000 00FEFF00 00FFFF01 80FFFF03 60FFFF01 F0FEFF0C F801001E F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F F801003F 7800003E 18FEFF39 88FFFF23 E0FFFF0F C0FFFF07 18FFFF01 78000000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F8010000 F0000000 60FEFF00 00FFFF01 80FFFF03 00FFFF01 00FEFF00 00000000 00000000 00000000 END DEFINEFONT Jim VK7JH MMedit |
||||
capsikin Guru ![]() Joined: 30/06/2020 Location: AustraliaPosts: 341 |
Thanks. I think it could be useful to have a description of the format, so I had a go at documenting the format of the hex numbers based on reading your code. My description could probably use some more work but I'm posting it in case it's useful either for understanding or for making better documentation. Also, these were my notes on the header word: |
||||
berighteous Senior Member ![]() Joined: 18/07/2020 Location: United StatesPosts: 110 |
I just make my own font in any size and color(s) I want in photoshop, load the image on a spare page, and use my own font subroutine to read an array of strings and blit the letter images to the screen. I can add a constant value to the letter coordinates to change colors from my font page. in the snippet below I'm printing each line in black for a drop shadow and then in whatever color on top of it. This particular font is 6x6 and is good at 320x200. I'm loading it on page 9 in mode 3. This font is upper case only. ![]() dim ozmessage1$(19) ozmessage1$(0)= " ABOUT OIDZONE " ozmessage1$(1)= " " ozmessage1$(2)= " HOW TO PLAY: " ozmessage1$(3)= " YOUR JOB IS TO CLEAR THE OIDZONE " ozmessage1$(4)= " OF ASTEROIDS AND OTHER HAZARDOUS " ozmessage1$(5)= " OBJECTS. YOU HAVE A FAST SHIP " ozmessage1$(6)= " AND A PULSE-CANON TO BLAST AWAY " ozmessage1$(7)= " AT ANYTHING IN YOUR PATH. " ozmessage1$(8)= " " ozmessage1$(9)= " TO CLEAR THE OIDZONE, YOU MUST " ozmessage1$(10)= " FIRST BLAST THE ASTEROIDS INTO " ozmessage1$(11)= " MANY SMALL PIECES, THEN DESTROY " ozmessage1$(12)= " EACH PIECE INDIVIDUALLY. YOU " ozmessage1$(13)= " MUST BE VERY CAREFUL, AS ANY OF " ozmessage1$(14)= " THE SMALLER ASTEROIDS CAN EASILY " ozmessage1$(15)= " DESTROY YOUR SMALL SHIP. ONCE " ozmessage1$(16)= " YOU CLEAR YOUR ZONE, YOU WILL GO " ozmessage1$(17)= " TO ANOTHER, MORE DIFFICULT ZONE. " ozmessage1$(18)= " " ozmessage1$(19)= " PRESS ANY KEY TO CONTINUE:" vtab=25 htab=6 fwidth=6 fheight=6 vspace=7 dim myfont(12)=(0,12,24,36,48,60,72,84,96,108,120,132,144) dim letterx(58)=(0,6,12,18,24,30,36,42,48,54,60,66,72,78,84,90,96,102,108,114,120,126,132,138,144,150,156,162,168,0,6,12,18,24,30,36,42,48,54,60,66,72,78,84,90,96,102,108,114,120,126,132,138,144,150,156,162,168,174) dim lettery(58)=(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6) dim fcolors(21)=(0,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,12) page write 0:cls for q = 0 to 19 printline ozmessage1$(q),htab+1,vtab+1+q*vspace,fcolors(1) printline ozmessage1$(q),htab,vtab+q*vspace,fcolors(q+2) next sub printline f$,htab,vtab,fcolor colorfont=color*fheight for i = 1 to len(f$) a = asc(mid$(f$,i,1))-32 h=htab+i*fwidth v=vtab blit letterx(a),lettery(a)+1+myfont(fcolor),htab+fwidth*i,vtab,fwidth,fheight,9,&b100 next i end sub ![]() ![]() sorry for the lousy phone photos, my video capture thing I ordered is lost in the mail. Edited 2020-09-22 16:58 by berighteous |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |