![]() |
Forum Index : Microcontroller and PC projects : uM2(+): 8x6 font for small displays
Author | Message | ||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
I should never have doubted Geoff's brilliance ![]() His code works perfectly with fonts of any width. Attached is a 8x6 font as in the original graphics drivers I wrote (7x5 symbols with one column to the right and one row below. This is a much better font for the small displays than the default and takes almost no room in the program DefineFont #8 5C200806 00000000 82200000 00800008 00004551 4F510000 0045F994 2B1CEA21 690000C2 B04C2090 AA104A62 84608046 00000000 40108410 81400081 00841004 A89C8A00 82000080 0080203E 30000000 00000042 0000003E 01000000 21000086 00004208 CAAA2972 82210027 00872008 21842072 42F8800F 00270A04 F824C510 0FFA0041 00270A02 8A3C0831 21F80027 00044108 8A9C2872 28720027 0027089E 61008601 86010080 00846000 40208410 0F000081 0000F880 10028140 20720084 00022084 BA9A2072 28720027 8028FAA2 8ABC28F2 2872002F 00278220 8AA248E2 08FA004E 800F823C 823C08FA 28720008 80278A2E 8ABE288A 82708028 00872008 12044138 4A8A0046 8048A230 82200882 6A8B800F 80288AAA 9AAA2C8A 28728028 00278AA2 82BC28F2 28720008 8046AAA2 A2BC28F2 087A8048 002F081C 200882F8 288A0082 00278AA2 89A2288A 288A0042 00A5AAAA 5208258A 288A8028 00822094 420821F8 0471800F 00074110 A9944AA9 4170804A 00471004 00804821 00000000 800F0000 00008140 07000000 80277A02 8A320B82 0700002F 00278220 8AA62608 07008027 0007FA22 41382431 E8010004 002778A2 8A320B82 06208028 00872008 12040310 09820046 0089C228 20088260 0D000087 8028AA2A 8A320B00 07008028 00278A22 F2220F00 06000008 802078A6 82320B00 07000008 002F7020 41100E41 08000023 80668AA2 89A20800 08000042 00A5AAA2 21940800 08008048 002778A2 21840F00 0400800F 0EE24028 End DefineFont This was a major pig to convert as the bit order in the original is top-to-bottom, whereas the UTFT fonts are left-to-right and in this font two characters share the same word in the binary. for amusement here is the conversion code I used, it also contains details of the characters in the new font. dim f%(5),g%(7)
for m%=1 to 46 for i%=0 to 5 read f%(i%) g%(i%)=0 next i% g%(6)=0 g%(7)=0 for j%=0 to 7 for i%=0 to 5 k%=1<<(5-i%) if f%(i%) and (1<<j%) then g%(j%)= g%(j%) OR k% endif next i% next j% a%=0 s$="" for i%=0 to 7 s$=s$+BIN$(g%(i%),6) next i% print hex$(val("&B"+mid$(s$,25,8)),2); print hex$(val("&B"+mid$(s$,17,8)),2); print hex$(val("&B"+mid$(s$,9,8)),2); print hex$(val("&B"+mid$(s$,1,8)),2)," "; one$= hex$(val("&B"+mid$(s$,41,8)),2) one$=one$+ hex$(val("&B"+mid$(s$,33,8)),2) for i%=0 to 5 read f%(i%) g%(i%)=0 next i% g%(6)=0 g%(7)=0 for j%=0 to 7 for i%=0 to 5 k%=1<<(5-i%) if f%(i%) and (1<<j%) then g%(j%)= g%(j%) OR k% endif next i% next j% a%=0 s$="" for i%=0 to 7 s$=s$+BIN$(g%(i%),6) next i% print hex$(val("&B"+mid$(s$,9,8)),2); print hex$(val("&B"+mid$(s$,1,8)),2); print one$," "; print hex$(val("&B"+mid$(s$,41,8)),2); print hex$(val("&B"+mid$(s$,33,8)),2); print hex$(val("&B"+mid$(s$,25,8)),2); print hex$(val("&B"+mid$(s$,17,8)),2) next m% end Data &H00,&H00,&H00,&H00,&H00,&H00 ' 32 20 Data &H00,&H00,&H2f,&H00,&H00,&H00 ' 33 ! 21 Data &H00,&H07,&H00,&H07,&H00,&H00 ' 34 " 22 Data &H14,&H7f,&H14,&H7f,&H14,&H00 ' 35 # 23 Data &H24,&H2a,&H7f,&H2a,&H12,&H00 ' 36 $ 24 Data &Hc4,&Hc8,&H10,&H26,&H46,&H00 ' 37 % 25 Data &H36,&H49,&H55,&H22,&H50,&H00 ' 38 & 26 Data &H00,&H05,&H03,&H00,&H00,&H00 ' 39 ' 27 Data &H00,&H1c,&H22,&H41,&H00,&H00 ' 40 ( 28 Data &H00,&H41,&H22,&H1c,&H00,&H00 ' 41 ) 29 Data &H14,&H08,&H3E,&H08,&H14,&H00 ' 42 * 2A Data &H08,&H08,&H3E,&H08,&H08,&H00 ' 43 + 2B Data &H00,&H00,&H50,&H30,&H00,&H00 ' 44 , 2C Data &H08,&H08,&H08,&H08,&H08,&H00 ' 45 - 2D Data &H00,&H60,&H60,&H00,&H00,&H00 ' 46 . 2E Data &H20,&H10,&H08,&H04,&H02,&H00 ' 47 / 2f Data &H3E,&H51,&H49,&H45,&H3E,&H00 ' 48 0 30 Data &H00,&H42,&H7F,&H40,&H00,&H00 ' 49 1 31 Data &H42,&H61,&H51,&H49,&H46,&H00 ' 50 2 32 Data &H21,&H41,&H45,&H4B,&H31,&H00 ' 51 3 33 Data &H18,&H14,&H12,&H7F,&H10,&H00 ' 52 4 34 Data &H27,&H45,&H45,&H45,&H39,&H00 ' 53 5 35 Data &H3C,&H4A,&H49,&H49,&H30,&H00 ' 54 6 36 Data &H01,&H71,&H09,&H05,&H03,&H00 ' 55 7 37 Data &H36,&H49,&H49,&H49,&H36,&H00 ' 56 8 38 Data &H06,&H49,&H49,&H49,&H3E,&H00 ' 57 9 39 Data &H00,&H36,&H36,&H00,&H00,&H00 ' 58 : 3A Data &H00,&H56,&H36,&H00,&H00,&H00 ' 59 ; 3B Data &H08,&H14,&H22,&H41,&H00,&H00 ' 60 < 3C Data &H14,&H14,&H14,&H14,&H14,&H00 ' 61 = 3D Data &H00,&H41,&H22,&H14,&H08,&H00 ' 62 > 3E Data &H02,&H01,&H51,&H09,&H06,&H00 ' 63 ? 3F Data &H32,&H49,&H59,&H51,&H3E,&H00 ' 64 @ 40 Data &H7E,&H11,&H11,&H11,&H7E,&H00 ' 65 A 41 Data &H7F,&H49,&H49,&H49,&H36,&H00 ' 66 B 42 Data &H3E,&H41,&H41,&H41,&H22,&H00 ' 67 C 43 Data &H7F,&H41,&H41,&H22,&H1C,&H00 ' 68 D 44 Data &H7F,&H49,&H49,&H49,&H41,&H00 ' 69 E 45 Data &H7F,&H09,&H09,&H09,&H01,&H00 ' 70 F 46 Data &H3E,&H41,&H49,&H49,&H7A,&H00 ' 71 G 47 Data &H7F,&H08,&H08,&H08,&H7F,&H00 ' 72 H 48 Data &H00,&H41,&H7F,&H41,&H00,&H00 ' 73 I 49 Data &H20,&H40,&H41,&H3F,&H01,&H00 ' 74 J 4A Data &H7F,&H08,&H14,&H22,&H41,&H00 ' 75 K 4B Data &H7F,&H40,&H40,&H40,&H40,&H00 ' 76 L 4C Data &H7F,&H02,&H0C,&H02,&H7F,&H00 ' 77 M 4D Data &H7F,&H04,&H08,&H10,&H7F,&H00 ' 78 N 4E Data &H3E,&H41,&H41,&H41,&H3E,&H00 ' 79 O 4F Data &H7F,&H09,&H09,&H09,&H06,&H00 ' 80 P 50 Data &H3E,&H41,&H51,&H21,&H5E,&H00 ' 81 Q 51 Data &H7F,&H09,&H19,&H29,&H46,&H00 ' 82 R 52 Data &H46,&H49,&H49,&H49,&H31,&H00 ' 83 S 53 Data &H01,&H01,&H7F,&H01,&H01,&H00 ' 84 T 54 Data &H3F,&H40,&H40,&H40,&H3F,&H00 ' 85 U 55 Data &H1F,&H20,&H40,&H20,&H1F,&H00 ' 86 V 56 Data &H3F,&H40,&H38,&H40,&H3F,&H00 ' 87 W 57 Data &H63,&H14,&H08,&H14,&H63,&H00 ' 88 X 58 Data &H07,&H08,&H70,&H08,&H07,&H00 ' 89 Y 59 Data &H61,&H51,&H49,&H45,&H43,&H00 ' 90 Z 5A Data &H00,&H7F,&H41,&H41,&H00,&H00 ' 91 [ 5B Data &H55,&H2A,&H55,&H2A,&H55,&H00 ' 92 \ 5C Data &H00,&H41,&H41,&H7F,&H00,&H00 ' 93 ] 5D Data &H04,&H02,&H01,&H02,&H04,&H00 ' 94 ^ 5E Data &H40,&H40,&H40,&H40,&H40,&H00 ' 95 _ 5F Data &H00,&H01,&H02,&H04,&H00,&H00 ' 96 ' 60 Data &H20,&H54,&H54,&H54,&H78,&H00 ' 97 a 61 Data &H7F,&H48,&H44,&H44,&H38,&H00 ' 98 b 62 Data &H38,&H44,&H44,&H44,&H20,&H00 ' 99 c 63 Data &H38,&H44,&H44,&H48,&H7F,&H00 ' 100 d 64 Data &H38,&H54,&H54,&H54,&H18,&H00 ' 101 e 65 Data &H08,&H7E,&H09,&H01,&H02,&H00 ' 102 f 66 Data &H0C,&H52,&H52,&H52,&H3E,&H00 ' 103 g 67 Data &H7F,&H08,&H04,&H04,&H78,&H00 ' 104 h 68 Data &H00,&H44,&H7D,&H40,&H00,&H00 ' 105 i 69 Data &H20,&H40,&H44,&H3D,&H00,&H00 ' 106 j 70 Data &H7F,&H10,&H28,&H44,&H00,&H00 ' 107 k 71 Data &H00,&H41,&H7F,&H40,&H00,&H00 ' 108 l 72 Data &H7C,&H04,&H18,&H04,&H78,&H00 ' 109 m 73 Data &H7C,&H08,&H04,&H04,&H78,&H00 ' 110 n 74 Data &H38,&H44,&H44,&H44,&H38,&H00 ' 111 o 75 Data &H7C,&H14,&H14,&H14,&H08,&H00 ' 112 p 76 Data &H08,&H14,&H14,&H18,&H7C,&H00 ' 113 q 77 Data &H7C,&H08,&H04,&H04,&H08,&H00 ' 114 r 78 Data &H48,&H54,&H54,&H54,&H20,&H00 ' 115 s 79 Data &H04,&H3F,&H44,&H40,&H20,&H00 ' 116 t 80 Data &H3C,&H40,&H40,&H20,&H7C,&H00 ' 117 u 81 Data &H1C,&H20,&H40,&H20,&H1C,&H00 ' 118 v 82 Data &H3C,&H40,&H30,&H40,&H3C,&H00 ' 119 w 83 Data &H44,&H28,&H10,&H28,&H44,&H00 ' 120 x 84 Data &H0C,&H50,&H50,&H50,&H3C,&H00 ' 121 y 85 Data &H44,&H64,&H54,&H4C,&H44,&H00 ' 122 z 86 Data &H08,&H14,&HE8,&HA0,&HA0,&H00 ' Degree Symbol |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Most excellent. Will have to give it a whirl. Thanks Matherp!!!! |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1965 |
Tried to open the code in Font Tweak. I got the 8x6 grid but when I click on a character nothing happens. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6219 |
FontTweak doesn't like fonts that are not a multiple of 8 pixels across. The number of rows doesn't matter. I did this because that is the requirement for UTFT fonts. Before I change FontTweak to handle the non 8 bit option, I have to get more information from Geoff. 6x8 such as Peter's font has a whole number of bytes for each character. Does MMBasic allow a 7 x 7 character size or any other size that ends up with part bytes for characters? If so, what do I do with them? Options are add padding bits to the end of each character or pack them all together the same as rows within the character. Jim VK7JH MMedit |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1965 |
Thanks Jim Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
I can answer that one - definitely NO The MM firmware creates a pointer into the font table as follows p = fp + 4 + (int)(((c - fp[2]) * fp[1] * fp[0]) / 8); so if size is 7*7 then fp[1]*fp[0]/8 = 6 i.e. the font pointer will slip by one bit (or one byte if padded) for each ascii character, so although low ascii characters would display vaguely correctly higher ones would be completely wrong |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6219 |
Thanks for the confirmation Peter. I will make changes to FontTweak to allow dimensions that give complete bytes per character only. Jim VK7JH MMedit |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Hi Peter This font looks really nice on the small display (96x16) Thanks for this. ![]() These OLED displays have having an amazingly clear image the photos do not do them justice Regards Jman |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2927 |
Can I please just clarify something here as I maybe misunderstanding a really silly thing ![]() On page 22 (uM+ manual), FONT 2 is described as 12x20. All other fonts are multiples of 8 wide, but this one isn't. This was the initial reason I enquired with TassyJim about his Font editing 'app' only allowing for multiples of 8 wide. Thanks for any help clarifying what I am misunderstanding. WW |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6219 |
Font 2 is indeed 12x20 however, in the PDF describing fonts, Geoff states that they have to comply with the UTFT standard. According to the rinkydink website, the UTFT standard requires width in multiples of 8 pixels (assuming I read it right). I based FontTweak on that information. It appears that MMBasic can handle fonts widths other than multiples of 8 provided that width X height IS a multiple of 8. I am not sure if these fonts are UTFT standard but we are mainly interested in fonts for MMBasic so I will alter FontTweak to allow these other font sizes. So 6 x 8 is OK but 6x7 or 7x7is NOT OK 12x12 is OK but 12x13 or 13x12 is NOT Jim VK7JH MMedit |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1965 |
This font is great on the Nokia display, but how do I use the Degree symbol. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
You can always access any character using CHR$(ascii-code) so the degree symbol is CHR$(123). Note however that the symbol in the font I converted is some strange combination of the deg symbol and the letter "C". You can use Jim's font editor to change it if that doesn't suit |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1965 |
Thanks for that. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |