中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-10-31 13:54
47,815 topics / 349,930 posts / today 0 new / 48,290 members
DOS开发编程 & 发展交流 (开发室) » Program source code for displaying Chinese characters
Printable Version  3,395 / 28
Floor16 pfox Posted 2003-10-14 00:00
银牌会员 Posts 446 Credits 1,451
The following is a quote from QB45 on 2003-10-14 19:13:07:
pfox, I have analyzed the font file you sent. The source code is as follows. Actually, this is not a 16*15 dot matrix font, but a 14*14 dot matrix font. Because of your misguidance, I took a lot of detours! I don't know where you got this font file from! Its order is arranged by radicals!


Thank you. It's a font from Taiwan Guoqiao.
Floor17 qb45 Posted 2003-10-14 00:00
高级用户 Posts 194 Credits 677
The Chinese character library file of 16*15 (or 14*14...) that you sent.
I have analyzed it. The source program is as follows. Actually, this is not a 16*15 dot matrix character library, but a 15*15 dot matrix character library. I don't know where you got this character library file! The order of the character library is the same as the dot matrix character library file sent by Pfox, which is arranged according to radical-phonetic components. However, the dot matrix character library file sent by Pfox contains special symbols such as pinyin, mathematics, etc., but yours does not! The source program is similar to the above one. I haven't analyzed your other two character libraries. It is estimated that they are similar. You can rewrite my this source program and analyze it to have a try!
The following is the source program
input "Please enter the complete path and file name of the 16*15 dot matrix character library_ ",file$
OPEN file$ FOR BINARY AS #1
SCREEN 12
FOR i1 = 0 TO 30
x0 = 0
FOR i = 1 TO 42
SEEK #1, (i - 1 + i1 * 42) * 30 + 1
zimo$ = INPUT$(30, 1)
num = 1
y0 = i1 * 15
FOR y = 0 TO 14
chr1$ = MID$(zimo$, num, 1)
num = num + 1
chr2$ = MID$(zimo$, num, 1)
num = num + 1
chr3$ = chr2$ + chr1$
LINE (x0, y0 + y)-STEP(14, 0), 7, , CVI(chr3$)
NEXT y
x0 = x0 + 15
NEXT i
NEXT i1
end
Floor18 Roy Posted 2003-10-15 00:00
管理员 Posts 1,633 Credits 4,869
The following is a quote from QB45 on 2003-10-14 21:38:15:
The 16*15 (or is it 14*14?) dot matrix font file of the et3 Chinese system you sent
      I have analyzed it, and the source code is as follows. Actually, this is not a 16*15 dot matrix font, but a 15*15 dot matrix font. I don't know where you got this font file from! The order of the font is the same as the dot matrix font file sent by Pfox, arranged by radical, but the dot matrix font file sent by Pfox contains special symbols such as pinyin, mathematics, etc., while yours does not! The source code is similar to the above one. I haven't analyzed your other two font files. I estimate they are similar. You can rewrite this source code of mine and analyze it by yourself!
The following is the source code
input "Please enter the complete path and file name of the 16*15 dot matrix font_ ",file$
OPEN file$ FOR BINARY AS #1
SCREEN 12
FOR i1 = 0 TO 30
    x0 = 0
    FOR i = 1 TO 42
        SEEK #1, (i - 1 + i1 * 42) * 30 + 1
        zimo$ = INPUT$(30, 1)
        num = 1
        y0 = i1 * 15
        FOR y = 0 TO 14
            chr1$ = MID$(zimo$, num, 1)
            num = num + 1
            chr2$ = MID$(zimo$, num, 1)
            num = num + 1
            chr3$ = chr2$ + chr1$
            LINE (x0, y0 + y)-STEP(14, 0), 7, , CVI(chr3$)
        NEXT y
        x0 = x0 + 15
     NEXT i
NEXT i1
end
This is Zhenhan's font... It seems really 16*15...
This is the recorded 16*16 font... The 16*16.bas can be used to display the characters... But it doesn't match the characters...
Floor19 qb45 Posted 2003-10-15 00:00
高级用户 Posts 194 Credits 677
You said: "This is Zhenhan's font... It seems really 16*15..."
If you are using the program I mentioned above without any changes, it should be a 15*15 dot matrix instead of a 16*15 dot matrix font, because 16*15 doesn't need to make a separate font library, unless it's a game font! In the BAS program that reads the 16*16 dot matrix font library, change the algorithm to draw one less line, and isn't it a 16*15 Chinese character? Of course, it's easier said than done! But the key is to judge that the impact of that line on the Chinese character is not significant, so as to remove it! You can use the way of judging the size! You can give it a try!
May I ask, why are you interested in this thing?
Floor20 sunny1979 Posted 2003-10-16 00:00
初级用户 Posts 86 Credits 376
Support you! The writing is pretty good. Just it seems these Chinese characters are a bit complicated to display. You can directly call the character patterns HZK16, HZK24 printing mode in the font library, which seems simpler! I think so, maybe everyone has different opinions!
Floor21 qb45 Posted 2003-10-16 00:00
高级用户 Posts 194 Credits 677
Generally, when displaying Chinese characters on the screen, the support of a Chinese character system is required. But when you need to display Chinese characters by yourself, you need to read the Chinese character font file by yourself, read out the character dot matrix, and then use the drawing method to display it on the screen.

In the dot matrix font file HZK16 of UCDOS, the character dot matrix is arranged according to the internal code of Chinese characters. The internal code of Chinese characters starts from some graphic characters, and the starting code is A1A1H. The first digit of the internal code of a Chinese character is the area code, each area has 94 Chinese characters, and the second digit is the code within each area. The dot matrix of each Chinese character is 16 dots * 16 dots, totaling 32 bytes. The data is arranged as the first line 1-8 dots, 9-16 dots, the second line 1-8 dots, 9-16 dots... Each bit of data is 1 for the dot to be displayed, and 0 for the dot not to be displayed. The so-called 16*16 means that each Chinese character is displayed in an area of 16 dots in both vertical and horizontal directions. However, later there are also HZK12, HZK24, HZK32 and HZK48 font files and bold, regular script and official script font files. Although there are various types of Chinese character fonts, they are all arranged in the order of the area and position. The previous byte is the area code of the Chinese character, and the latter byte is the position code of the character. Each area records 94 Chinese characters, and the position code is the position of the character in the area. Therefore, the specific position formula of a Chinese character in the Chinese character font is: 94*(area code - 1) + position code - 1. The subtraction of 1 is because the array starts with 0 and the area code and position code start with 1. This is only the position of the Chinese character in the Chinese character font in units of Chinese characters. Then, how to get the position of the Chinese character in units of bytes? Just multiply by the number of bytes occupied by one Chinese character's font, that is: (94*(area code - 1) + position code - 1) * number of bytes occupied by one Chinese character's font, and different results will be obtained according to the different sizes of Chinese characters in each Chinese character font. Taking the 16*16 dot matrix font as an example, the formula is: (94*(area code - 1) + (position code - 1)) * 32. The 32-byte information starting from this position in the Chinese character font file records the font information of the character.

After understanding the composition principle of dot matrix Chinese characters and Chinese character fonts, displaying Chinese characters becomes simple. Taking the 16*16 dot matrix font as an example, the usual method is: move the file working pointer to the place of the desired Chinese character font, read the Chinese character font file into a 2*16 array, and then use a for loop to display bit by bit.

However, the font files provided by netizens Roy and Pfox cannot be calculated by this formula, so the display does not match the expected result. To solve this problem, you need to know how it gets the position of the Chinese character to be displayed in the font. I think there should be a file like a font index table. You can look for it! If not, you should see if the structure of Taiwan's Chinese character fonts has its own arrangement method!
Floor22 凌晨一点 Posted 2003-10-25 00:00
初级用户 Posts 54 Credits 255
Hehe, as early as the 1970s, BASIC was very popular. At that time, some small machines (non-PC machines, looking quite like the little telex machines of the 1990s) had operating systems written in BASIC. Many application programs, such as the "draft" of Lotus spreadsheet processing programs, were implemented with it. The famous founder of Blizzard was making pocket money for college life by writing small games for some computer companies with BASIC at that time. Until now, BASIC is still one of the programming languages with the largest number of users. There's no other reason than it's simple, easy to get started with, and has considerable functionality.

Of course, I'm not telling you to stick to it. I also moved from QB to C. Now I sometimes use it to write some small programs to relive the past ^_^ I also think you should learn C. Those who play programming should be able to pick it up and put it down. To be honest, I hesitated for a long time when I moved from BASIC to C ^_^ But now I think it was worth it.

Come on!
Floor23 warm Posted 2003-10-25 00:00
初级用户 Posts 25 Credits 175
May I ask why you switched from Basic to C at that time? Was it because of speed issues?
Floor24 凌晨一点 Posted 2003-10-27 00:00
初级用户 Posts 54 Credits 255
There are many reasons. Speed is one aspect, and there are also aspects such as functions, flexibility, etc. Of course, having powerful functions is the more significant one. ^_^
Floor25 spirit Posted 2004-01-08 00:00
初级用户 Posts 5 Credits 111
Floor26 qb45 Posted 2004-01-08 00:00
高级用户 Posts 194 Credits 677
Thanks for everyone's encouragement and suggestions. I don't want to learn C. If I learn, I'll learn assembly! Learning C only makes me have a half-baked understanding of computers. I'm just using functions written by others. It's boring!!!!!
Floor27 iceboy Posted 2004-01-11 00:00
银牌会员 Posts 512 Credits 1,681
Hope to make a LIB that displays Chinese characters & images at 800*600@75Hz. The refresh rate is low, it's really uncomfortable to look at. (Unless it's black background with white characters)
Floor28 qb45 Posted 2004-01-12 00:00
高级用户 Posts 194 Credits 677
If I have the materials, I can do it!
I don't have relevant materials in this regard!
Floor29 pizigao Posted 2004-01-13 00:00
银牌会员 Posts 292 Credits 1,063
Top it's also great that I want to learn C language too
Prev  1 2
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023