Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : PS/2 & Serial example program with German custom font
Author | Message | ||||
Amnesie Guru Joined: 30/06/2020 Location: GermanyPosts: 396 |
Hello everyone, with the help of Jim I accomplished to get my custom drawn font, for german language, to get into basic. Wrote a small program for testing purpose. It is based on ARIAL bold and I substituted: $ = ss (ß) | = ue (ü) { = oe (ö) } = ae (ä) [ = AE (Ä) ] = OE (Ö) \ = UE (Ü) I asked Peter if there is any way to implement german "Umlaute" (äüö etc.) but he said for obvious reasons this will not happen. And it is perfectly fine! Thankfully he implemented PS/2 Scancodes. Since I am still not a basic "guru" I afraid my little testprogram is WAY to complex and bulky. But it works so far. My long term project is to work on a simple texteditor, for this "Umlaute" are absolutley important. My hope is that someone - maybe one of the german members here - who are way more experienced than me, could push me in the right direction for improvements. I know I could implement the font as a library, but this way it's all at one place. I guess my whole approach is "wrong"... (Even if it works). But maybe it is useful for anyone. Here is code (down below is the file as a download). 'German Umlaute via PS/2 and Serial with a custom font 'which uses: ' $ = ss ' | = ue ' { = oe ' } = ae ' [ = AE ' ] = OE ' \ = UE ' ' KNOWN BUGS: sometimes dubble questionmark ("??") after shift and "?" Option explicit Dim String lines$(10) length 41 Dim String a Dim integer myLine=1, ps2_pause=250 Dim integer shift_pressed=0, ps2key, last_ps2key, flag=0 CLS DefineFont #8 5F201010 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00030003 00030003 00030003 00030003 00000003 00030003 00000000 00000000 60066006 60066006 00000000 00000000 00000000 00000000 00000000 00000000 60036003 F03FC006 C006F03F F03F800D 800DF03F 001B001B 00000000 E0030000 300EF007 F00C300C 800DE00D F00CC00D 180D380C F00CF80D 00000000 00000000 3066183C 60663066 C03CC066 B3019E01 33033303 1E0C3306 00000000 00000000 E00FC007 600C600C 8007C007 D819900D 7818F018 8807FC0F 00000000 00000000 80018001 80018001 00000000 00000000 00000000 00000000 00000000 80010000 00030003 00060006 00060006 00060006 00030006 80010003 00000000 00060000 00030003 80018001 80018001 80018001 00038001 00060003 00000000 00000000 00000000 80038003 F83F9833 C007C007 701CE00E 00004004 00000000 00000000 00000000 C0000000 C000C000 F807F807 C000C000 0000C000 00000000 00000000 00000000 00000000 00000000 00000000 00030003 00010001 00000002 00000000 00000000 00000000 00000000 E003E003 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00030000 00000003 00000000 00000000 60006000 C000C000 C000C000 80018001 80018001 00030003 00000000 00000000 E007C003 300C700E 300C300C 300C300C 700E300C C003E007 00000000 00000000 80038001 800D8007 80018009 80018001 80018001 80018001 00000000 00000000 E007C003 300C300E 60003000 C001E000 00068003 F00FF00F 00000000 00000000 F007E003 3000300E E001E001 30007000 700E300C C003E007 00000000 00000000 E0006000 E001E000 60036003 600C6006 F00FF00F 60006000 00000000 00000000 E007E007 000C0006 E00FC00F 3000700C 700E300C C003E007 00000000 00000000 F007E003 000C3006 E00FC00D 300C700E 3006300C C003E007 00000000 00000000 F00FF00F C0006000 8001C000 80018001 00038003 00030003 00000000 00000000 E007C003 300C300C E007300C 300CE007 300C300C C003E007 00000000 00000000 E007C003 300C600C 700E300C B003F007 600C3000 C007E00F 00000000 00000000 80010000 00008001 00000000 00000000 80018001 00000000 00000000 00000000 80010000 00008001 00000000 00000000 80018001 80008000 00000001 00000000 00000000 E0002000 000FC003 000F001C E000C003 00002000 00000000 00000000 00000000 F01FF01F 00000000 F01FF01F 00000000 00000000 00000000 00000000 00000000 000E0008 E0018007 E0017000 000E8007 00000008 00000000 00000000 E007C003 300C300E E0007000 8001C001 00008001 80018001 00000000 C0070000 7813300C C82CE817 C82CC82C E026D02F 10080810 0000E007 00000000 00000000 80038003 C006C006 600CC006 E00F600C 3018F01F 18303018 00000000 00000000 F01FE01F 30183018 E01F3018 1818F01F 18181818 E01FF01F 00000000 00000000 F00FE003 101C380C 00180018 00180018 380C101C E003F00F 00000000 00000000 F01FC01F 18183018 18181818 18181818 30181818 C01FF01F 00000000 00000000 F80FF80F 000C000C F80F000C 000CF80F 000C000C F80FF80F 00000000 00000000 F00FF00F 000C000C E00F000C 000CE00F 000C000C 000C000C 00000000 00000000 F01FE007 10383818 00300030 F830F830 38181838 E007F81F 00000000 00000000 18181818 18181818 F81F1818 1818F81F 18181818 18181818 00000000 00000000 80018001 80018001 80018001 80018001 80018001 80018001 00000000 00000000 30003000 30003000 30003000 30003000 700E300C C003E007 00000000 00000000 30181818 C0186018 C01B8019 601CC01E 30187018 18181818 00000000 00000000 000C000C 000C000C 000C000C 000C000C 000C000C F00FF00F 00000000 00000000 38383838 783C783C D8365834 D836D836 98339833 18319833 00000000 00000000 181C1818 181E181E 9819181B D8189819 78187818 18183818 00000000 00000000 F01FC007 18303018 18301830 18301830 30181830 C007F01F 00000000 00000000 F00FE00F 180C380C F00F380C 000CE00F 000C000C 000C000C 00000000 00000000 F01FC007 18303018 18301830 18301830 F018B831 B007F01F 00001800 00000000 F01FE01F 18183818 F01F3818 E018C01F 30187018 1C183818 00000000 00000000 F007E003 180C380E E007000F 3800F001 380E180C E003F007 00000000 00000000 F81FF81F 80018001 80018001 80018001 80018001 80018001 00000000 00000000 18181818 18181818 18181818 18181818 381C1818 E007F00F 00000000 00000000 30181830 30183018 600C600C C006E00E 8003C006 80038003 00000000 00000000 C631C631 6C1BC631 6C1B6C1B 6C1B6C1B 380E380E 380E380E 00000000 00000000 701C3018 C006600C 8003C007 C0078003 600CC006 3018701C 00000000 00000000 381C1818 6006300C C0036006 80018001 80018001 80018001 00000000 00000000 F807F807 60003000 C000E000 80038001 00060003 F80FF80F 00000000 60036003 C0010000 6003E003 30066003 F80F3006 180CF80F 0C180C18 00000000 60066006 18180000 18181818 18181818 18181818 381C1818 E007F00F 00000000 30063006 E0030000 180CF80F 0C180C18 0C180C18 180C0C18 E003F80F 00000000 80010000 C003C003 60066006 300C6006 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 FFFF0000 0000FFFF 00000000 C0008001 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 E00FC007 E001600C 600EE007 E00F600C 0000B007 00000000 000C0000 000C000C E00FC00D 300C700E 300C300C E00F700E 0000C00D 00000000 00000000 00000000 E007C003 000C600E 000C000C E007600E 0000C003 00000000 30000000 30003000 F007B003 300C700E 300C300C F007700E 0000B003 00000000 00000000 00000000 C0078003 E00F600C 000CE00F C007600E 00008003 00000000 C0030000 0006C007 800F800F 00060006 00060006 00060006 00000006 00000000 00000000 60070000 E01CE00F 60186018 E01C6018 6007E00F E01F6018 0000C00F 000C0000 000C000C F00FE00D 300C300E 300C300C 300C300C 0000300C 00000000 00000000 80018001 80010000 80018001 80018001 80018001 00008001 00000000 00000000 80018001 80010000 80018001 80018001 80018001 80018001 00078007 000C0000 000C000C C00C600C 800F800D C00EC00F 600CC00C 0000600C 00000000 80010000 80018001 80018001 80018001 80018001 80018001 00008001 00000000 00000000 00000000 FC3F3837 8C31CC39 8C318C31 8C318C31 00008C31 00000000 00000000 00000000 F00FE00D 300C300E 300C300C 300C300C 0000300C 00000000 00000000 00000000 E007C003 300C700E 300C300C E007700E 0000C003 00000000 00000000 00000000 E00FC00D 300C700E 300C300C E00F700E 000CC00D 000C000C 00000000 00000000 F007B003 300C700E 300C300C F007700E 3000B003 30003000 00000000 00000000 F0037003 00038003 00030003 00030003 00000003 00000000 00000000 00000000 E00FC007 000F600C E000C007 E00F600C 0000C007 00000000 00010000 00030003 C007C007 00030003 00030003 C0030003 0000C001 00000000 00000000 00000000 300C300C 300C300C 300C300C F00F700C 0000B007 00000000 00000000 00000000 30063006 60033006 60036003 C001C001 0000C001 00000000 00000000 00000000 C631C631 6C1BCC19 6C1B6C1B 380E380E 0000380E 00000000 00000000 00000000 70073006 C0016003 C001C001 70076003 00003006 00000000 00000000 00000000 180C180C 30063006 60036003 C001E003 8001C001 00078007 00000000 00000000 F803F803 70003000 C001E000 F8038001 0000F803 00000000 60060000 00006006 E007C003 300C700E 300C300C E007700E 0000C003 00000000 60060000 00006006 300C300C 300C300C 300C300C F00F700C 0000B007 00000000 30030000 00003003 F007E003 30003004 3006F003 F0073006 0000B003 00000000 00000000 F80F8807 0000F008 00000000 00000000 00000000 00000000 00000000 End DefineFont Font 8 Do key_input: a=Inkey$ If ps2key <> MM.Info(PS2) Then 'store the previous pressed key last_ps2key = ps2key 'to check if shift is released EndIf ps2key = MM.Info(PS2) 'get PS/2 keystroke If MM.Info(PS2) = 18 Then 'is shift active? shift_pressed=1 EndIf If MM.Info(PS2) - 61440 = last_ps2key Then 'reset shift shift_pressed=0 'EXAMPLE: if shift was pressed EndIf '(scancode 18) + "?"-key (scancode '78) released, final scancode is: '61518. If we now calculate: '61518-61440 it equals always the 'previous pressed key, in this 'case "78" ("?"-key) 'This way it's possible with only 'one IF-statement to cover all 'cases when SHIFT was pressed If MM.Info(PS2) = 78 And shift_pressed = 1 Then '? a = Chr$(63) Pause ps2_pause EndIf If MM.Info(PS2) = 78 And shift_pressed = 0 Then 'ss a = Chr$(36) Pause ps2_pause EndIf If MM.Info(PS2) = 84 And shift_pressed = 1 Then 'UE a = Chr$(92) Pause ps2_pause EndIf If MM.Info(PS2) = 84 And shift_pressed = 0 Then 'ue a = Chr$(124) Pause ps2_pause EndIf If MM.Info(PS2) = 82 And shift_pressed = 1 Then 'AE a = Chr$(91) Pause ps2_pause EndIf If MM.Info(PS2) = 82 And shift_pressed = 0 Then 'ae a = Chr$(125) Pause ps2_pause EndIf If MM.Info(PS2) = 76 And shift_pressed = 1 Then 'OE a = Chr$(93) Pause ps2_pause EndIf If MM.Info(PS2) = 76 And shift_pressed = 0 Then 'oe a = Chr$(123) Pause ps2_pause EndIf If a="" Then GoTo key_input 'get new keystroke EndIf 'Remapping of SERIAL input to custom font --------------------- If a = Chr$(223) Then a = Chr$(36) 'ss If a = Chr$(220) Then a = Chr$(92) 'UE If a = Chr$(252) Then a = Chr$(124) 'ue If a = Chr$(196) Then a = Chr$(91) 'AE If a = Chr$(228) Then a = Chr$(125) 'ae If a = Chr$(214) Then a = Chr$(93) 'OE If a = Chr$(246) Then a = Chr$(123) 'oe '-------------------------------------------------------------- 'Just some test for reading and writing to sd card If a = Chr$(145) Then 'If F1-key (145) pressed... Open "test.txt" For OUTPUT As #1 Print #1, lines(myLine) Close #1 EndIf If a = Chr$(146) Then 'If F2-key (146) pressed... Open "test.txt" For INPUT As #1 Line Input #1, lines(myLine) Close #1 EndIf '-------------------------------------------------------------- 'New line handling If Len(lines(myLine))>=41 Then myLine=myLine+1 EndIf lines(myLine) = lines(myLine) + a 'add new char to string array 'Show Text Text 0,13+myLine*16,lines(myLine),,8,1,RGB(green) Loop File download: german_chars.zip Greetings Daniel |
||||
Pluto Guru Joined: 09/06/2017 Location: FinlandPosts: 359 |
How difficult would it be to implement Å and å (A with one dot) into your font? Then it would also cover the swedish fonts. /Pluto |
||||
Amnesie Guru Joined: 30/06/2020 Location: GermanyPosts: 396 |
Hi Pluto, this is no problem at all! I've done it with Photoshop and converted the image via this tool on "http://www.rinkydinkelectronics.com/r_fonts.php", after that one can convert it with Jims program "FontTweak" ("https://www.c-com.com.au/MMedit.htm", scroll a bit down) to get it into the right format. Greetings Daniel |
||||
Pluto Guru Joined: 09/06/2017 Location: FinlandPosts: 359 |
Thanks Daniel. /Pluto |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6101 |
Can I suggest that you create a font that uses the extended characters for non ASCII characters. Code Page 865 'should' cover most of the European and Nordic characters. It will be nice if there is one that keeps everyone happy. Fonts 1 and 4 use extended characters but not a standard set. Then you use If a = Chr$(223) Then a = "\nnn" 'etc That way you still have the full ASCII ( >= chr$(32) available. You will need OPTION ESCAPE at the start of your program. I don't have a nonUS keyboard so not able to help with any keymappings. Jim VK7JH MMedit MMBasic Help |
||||
Print this page |