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!