China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-19 08:54
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » Program source code for displaying Chinese characters View 2,757 Replies 28
Floor 16 Posted 2003-10-14 00:00 ·  中国 广东 汕头 电信
银牌会员
★★★
Credits 1,451
Posts 446
Joined 2002-10-20 00:00
23-year member
UID 29
Gender Male
Status Offline
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.
Floor 17 Posted 2003-10-14 00:00 ·  中国 湖北 武汉 联通
高级用户
★★
Credits 677
Posts 194
Joined 2003-09-13 00:00
22-year member
UID 9778
Gender Male
Status Offline
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
Floor 18 Posted 2003-10-15 00:00 ·  中国 香港
管理员
★★★★
專業島民
Credits 4,869
Posts 1,633
Joined 2002-12-10 00:00
23-year member
UID 465
Gender Male
Status Offline
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...
我的網站:http://mw16.2ya.com/ 我的網誌: http://scrappedblog.blogspot.com/
~
我的Winamp正在播放的歌曲:
Floor 19 Posted 2003-10-15 00:00 ·  中国 湖北 武汉 联通
高级用户
★★
Credits 677
Posts 194
Joined 2003-09-13 00:00
22-year member
UID 9778
Gender Male
Status Offline
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?
Floor 20 Posted 2003-10-16 00:00 ·  中国 陕西 西安 长安区 电信
初级用户
★★
忍者
Credits 376
Posts 86
Joined 2003-10-16 00:00
22-year member
UID 11361
Gender Male
Status Offline
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!
以C语言软件开发为主:http://sunny1979.icpcn.com
Floor 21 Posted 2003-10-16 00:00 ·  中国 湖北 武汉 联通
高级用户
★★
Credits 677
Posts 194
Joined 2003-09-13 00:00
22-year member
UID 9778
Gender Male
Status Offline
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!
Floor 22 Posted 2003-10-25 00:00 ·  中国 湖南 长沙 电信
初级用户
★★
Credits 255
Posts 54
Joined 2003-10-24 00:00
22-year member
UID 11864
Gender Male
Status Offline
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!
Floor 23 Posted 2003-10-25 00:00 ·  中国 广东 中山 电信
初级用户
Credits 175
Posts 25
Joined 2003-10-23 00:00
22-year member
UID 11741
Gender Male
Status Offline
May I ask why you switched from Basic to C at that time? Was it because of speed issues?
Floor 24 Posted 2003-10-27 00:00 ·  中国 湖南 长沙 电信
初级用户
★★
Credits 255
Posts 54
Joined 2003-10-24 00:00
22-year member
UID 11864
Gender Male
Status Offline
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. ^_^
Floor 25 Posted 2004-01-08 00:00 ·  中国 浙江 杭州 华数宽带
初级用户
Credits 111
Posts 5
Joined 2003-12-01 00:00
22-year member
UID 13634
Gender Male
Status Offline
Floor 26 Posted 2004-01-08 00:00 ·  中国 湖北 武汉 联通
高级用户
★★
Credits 677
Posts 194
Joined 2003-09-13 00:00
22-year member
UID 9778
Gender Male
Status Offline
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!!!!!
Floor 27 Posted 2004-01-11 00:00 ·  中国 湖北 武汉 联通
银牌会员
★★★
Credits 1,681
Posts 512
Joined 2003-08-02 00:00
22-year member
UID 7953
Gender Male
Status Offline
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)
Somehow somewhere I've got to choose.
No matter if it is win or lose.
Floor 28 Posted 2004-01-12 00:00 ·  中国 湖北 武汉 联通
高级用户
★★
Credits 677
Posts 194
Joined 2003-09-13 00:00
22-year member
UID 9778
Gender Male
Status Offline
If I have the materials, I can do it!
I don't have relevant materials in this regard!
Floor 29 Posted 2004-01-13 00:00 ·  中国 浙江 杭州 电信
银牌会员
★★
三生缘里笑红尘
Credits 1,063
Posts 292
Joined 2003-03-09 00:00
23-year member
UID 1073
Gender Male
Status Offline
Top it's also great that I want to learn C language too
Forum Jump: