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-08-26 13:08
中国DOS联盟论坛 » DOS汉化世界 & 中文系统 (中文化室) » Documentation on the curved font library format of UCDOS 5.0 View 4,131 Replies 6
Original Poster Posted 2009-01-02 22:35 ·  中国 山东 临沂 电信
初级用户
Credits 47
Posts 12
Joined 2008-09-05 21:54
17-year member
UID 124909
Gender Male
Status Offline
### Document on the Format of the Curved Font Library in UCDOS 5.0

UCDOS, the most powerful and compatible external Chinese character system under DOS, now some people have been looking for the format of the curved font library displayed by UCDOS 5.0. I finally found several such documents through searching online, but found several errors in the implementation of the algorithm, and have now corrected them and posted them online for everyone's reference.

**Note:** The calculation formula for the address of English characters has been corrected. It should be multiplied by 94 instead of 100, and the original text has been corrected.

### Analysis of the Structure of UCDOS Curved Outline Font Library

UCDOS is a domestic Chinese character operating system with many excellent performances. In particular, its rich PostScript curved outline fonts have left a deep impression on users. To make full use of the existing curved font libraries in UCDOS, such as making beautiful software interfaces, using them as small curved font libraries for one's own system, or converting to other types of font libraries, it is necessary to first understand the structure of the UCDOS curved outline font library.

1. **Structure of Curved Outline Font Library and Address Calculation**

All kinds of curved outline font libraries in UCDOS are stored in specific directories of UCDOS (such as C:\UCDOS\FNT) and are distinguished by their own special file names, such as:
- ASCPS: English font curved outline font library
- HZKPST: Graphic symbol curved outline font library
- HZKPSKTJ: Simplified Kai body curved outline font library
- HZKPSSTJ: Simplified Song body curved outline font library
- HZKPSHTJ: Simplified Hei body curved outline font library
- HZKPSFSJ: Simplified Fang Song body curved outline font library

In addition, more than thirty other extended simplified and traditional Chinese curved outline font libraries are provided for users to choose from.

Each curved outline font library is composed of two parts: the Chinese character index area and the font data area. The Chinese character index area is composed of many index entries. Each index entry is composed of six bytes, among which the offset address of the font data is 4 bytes, and the length of the font data occupies 2 bytes. The font data of the Chinese character can be obtained from the offset address of the font data and the length of the font data provided by the Chinese character index. In order to determine the offset of a Chinese character in the Chinese character index area of the font library, it is necessary to obtain it through the Chinese character location code or the Chinese character internal code. According to the regulations of GB2312-80, generally, the Chinese character library collects 7445 Chinese characters and non-Chinese graphic characters, among which there are 6763 Chinese characters and 682 non-Chinese graphic characters. And in order to facilitate encoding and management, they are divided into 94 areas, each area is divided into 94 positions. At the same time, in order to distinguish Chinese characters from English, it is stipulated that in the computer, the encoding of Chinese characters is represented by the internal code, and one internal code occupies 2 bytes. Each Chinese character or non-Chinese graphic character corresponds to a unique location code and internal code. The conversion formula between the Chinese character internal code and the Chinese character location code is as follows:
Internal code = Location code + 0xA0A0

The offset of the Chinese character in the index area of the curved outline font library can be obtained from the Chinese character internal code or location code. The calculation method is as follows:
OFFSET = ((High byte of internal code - 0XA0 - 16) × 94 + (Low byte of internal code - 0XA0 - 1)) × 6
= ((Area code - 16) × 94 + (Position code - 1)) × 6

For example: The location code of the Chinese character "啊" is 1601 (the 16th area and the 1st position). The offset of the internal code of "啊" in the index area of the curved outline font library can be obtained as follows:
Internal code = Location code + 0xA0A0 = 1601 + 0xA0A0 = 0x1001 + 0xA0A0 = 0xB0A1
Offset OFFSET = ((0XB0 - 0XA0 - 16) × 94 + (0XA1 - 0XA0 - 1)) × 6
Or OFFSET = ((16 - 16) × 94 + (1 - 1)) × 6

The symbol library of Chinese characters is separate from the Chinese character library. The offset of graphic symbols before area 16 is:
offset = ((High byte of internal code - 0xa0 - 1) × 94 + (Low byte of internal code - 0xa0 - 1)) × 6 = ((Area code - 1) × 94 + (Position code - 1)) × 6

The offset of the English font is relatively special. There are 10 kinds of fonts, each font has 100 English characters. The offset can be determined in this way (let the font number be N and the ASCII code of the English character be CC):
offset = (N × 94 - F(CC - 32)) × 6

In UCDOS 5.0, read 4 consecutive bytes from this offset and convert it into a long integer, which is the font data address (Address). Then read 2 consecutive bytes and convert it into an integer, which is the length (Length) of the font data.

In UCDOS 6.0, after reading 4 consecutive bytes from this offset address and converting it into a long integer, it is necessary to subtract the hexadecimal 0x10000000 to get the font data address. Then read 2 consecutive bytes and convert it into an integer, which is the length (Length) of the font data, including the symbol library. But English characters do not need adjustment.

2. **Format of Font Data**

The glyph data of the cubic curve font library needs to be interpreted and recombined. When reading the glyph data of the cubic curve font library, only four bits are read each time. The method is that when a byte is read for the first time, the low four bits are read. When the byte is read again, the high four bits are read. When the read data does not need to be used as a coordinate quantity, the read four-bit data will be regarded as a command and interpreted. If the current command requires a coordinate quantity, the coordinate quantity is divided into absolute coordinate values and coordinate increments. The absolute coordinate value is one byte, which is recombined from the two read four-bit data. The recombination method is that the first read four-bit data is used as the high four bits, and the second read four-bit data is used as the low four bits. The coordinate increment is a four-bit or six-bit binary number, where the highest bit is the sign bit. The four-bit coordinate increment is the currently read four-bit data. When the coordinate increment is a six-bit binary number, it is also obtained by recombination. The method is to use the first read four-bit data as the high four bits of the six-bit data, and the high two bits of the second read four-bit data as the low two bits of the six-bit data to get the first coordinate increment. Then use the low two bits of the second read four-bit data as the high two bits of the six-bit data, and the third read four-bit data as the low four bits of the six-bit data to get the second coordinate increment.

3. **Meaning of Control Words**

The control words of UCDOS are 4 bits (half-byte), and there are 16 different functional control words, which respectively control different curve segments for generating curved outline glyphs. The specific meanings are as follows:

**Table 1: Meaning and Function of Control Words**

| Control Word | Parameter Meaning | Length | Function | Current Point |
|--------------|-------------------|--------|----------|---------------|
| 0000 | X1,Y1 | 16 bits| Start point of stroke, move current point to this point | X1,Y1 |
| 0001 | X1 | 8 bits | Draw a horizontal line from current point to X1 point | X1,CY |
| 0010 | Y1 | 8 bits | Draw a vertical line from current point to Y1 point | CX,Y1 |
| 0011 | X1,Y1 | 16 bits| Draw a line from current point to (X1,Y1) point | X1,Y1 |
| 0100 | X1,Y1,X2,Y2 | 32 bits| Draw a quadratic Bezier curve with current point, (X1,Y1) and (X2,Y2) as control points | X2,Y2 |
| 0101 | X1,Y1,X2,Y2,X3,Y3 | 48 bits| Draw a cubic Bezier curve with current point, (X1,Y1), (X2,Y2) and (X3,Y3) as control points | X3,Y3 |
| 0110 | X1,Y1,X2,Y2 | 32 bits| Draw a rectangle with (X1,Y1) as the upper left corner and (X2,Y2) as the lower right point | Unchanged |
| 0111 | #X1,Y1 | 12 bits| Draw a line from current point to (CX+#X1,Y1) point | CX+#X1,Y1 |
| 1000 | X1,#Y1 | 12 bits| Draw a line from current point to (X1+CY+#Y1) point | X1+CY+#Y1 |
| 1001 | #X1,#Y1 | 8 bits | Draw a line from current point to (CX+#X1,CY+#Y1) point | CX+#X1,CY+#Y1 |
| 1010 | &X1,&Y1 | 12 bits| Draw a line from current point to (CX+&X1,CY+&Y1) point | CX+&X1,CY+&Y1 |
| 1011 | #X1,#Y1,#X2,#Y2 | 16 bits| Draw a quadratic Bezier curve with current point, (CX+#X1,CY+#Y1) and (CX+#X1+#X2,CY+#Y1+#Y2) as control points | CX+#X1+#X2,CY+#Y1+#Y2 |
| 1100 | &X1,&Y1,&X2,&Y2 | 24 bits| Draw a quadratic Bezier curve with current point, (CX+&X1,CY+&Y1) and (CX+&X1+&X2,CY+&Y1+&Y2) as control points | CX+&X1+&X2,CY+&Y1+&Y2 |
| 1101 | #X1,#Y1,#X2,#Y2,#X3,#Y3 | 24 bits| Draw a cubic Bezier curve with current point, (CX+#X1,CY+#Y1), (CX+#X1+#X2,CY+#Y1+#Y2) and (CX+#X1+#X2+#X3,CY+#Y1+#Y2+#Y3) as control points | CX+#X1+#X2+#X3,CY+#Y1+#Y2+#Y3 |
| 1110 | &X1,&Y1,&X2,&Y2,&X3,&Y3 | 36 bits| Draw a cubic Bezier curve with current point, (CX+&X1, CY+&Y1), (CX+&X1+&X2, CY+&Y1+&Y2) and (CX+&X1+&X2+&X3, CY+&Y1+&Y2+&Y3) as control points | CX+&X1+&X2+&X3,CY+&Y1+&Y2+&Y3 |
| 1111 | X1,Y1 | 16 bits| Only read two absolute coordinates, no other operations | Unchanged |

**Notes:**
① Parameters X1, Y1, X2, Y2, X3, Y3 all represent 8-bit length coordinate values, and are positive numbers, representing the range from 0 to 255;
② Parameters #X1, #Y1, #X2, #Y2, #X3, #Y3 all represent increments relative to the current point, the highest bit is the sign bit, 0 means positive, 1 means negative, representing the range from -7 to +7;
③ Parameters &X1, &Y1, &X2, &Y2, &X3, &Y3 all represent 6-bit length increments relative to the current point, the highest bit is the sign bit, 0 means positive, 1 means negative, representing the range from -31 to +31;
④ CX, CY all represent the coordinate values of the current point
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
sanchuan +2 2009-01-02 23:07
DOSroot +6 2009-04-17 04:07
Floor 2 Posted 2009-01-02 23:08 ·  中国 湖北 武汉 电信
初级用户
★★
Credits 113
Posts 51
Joined 2008-11-16 23:24
17-year member
UID 131196
Gender Male
From 武汉
Status Offline
Rare materials. The thread starter has worked hard.
三川一笑
Floor 3 Posted 2009-01-10 10:36 ·  中国 山东 临沂 电信
初级用户
Credits 47
Posts 12
Joined 2008-09-05 21:54
17-year member
UID 124909
Gender Male
Status Offline
You guys just look but don't post replies, that's too unkind. 〉〉〉〉〉〉〉〉〉〉〉〉
Floor 4 Posted 2009-01-10 10:38 ·  中国 山东 临沂 电信
初级用户
Credits 47
Posts 12
Joined 2008-09-05 21:54
17-year member
UID 124909
Gender Male
Status Offline
I will post my real program here after a while to share with everyone. Hope everyone gives a thumbs up
Floor 5 Posted 2009-04-17 01:59 ·  中国 广东 东莞 电信
新手上路
Credits 5
Posts 2
Joined 2009-04-16 12:08
17-year member
UID 143088
Gender Male
Status Offline
Floor 6 Posted 2010-05-29 02:45 ·  中国 广东 珠海 香洲区 电信
新手上路
Credits 19
Posts 11
Joined 2008-12-30 01:50
17-year member
UID 135303
Gender Male
Status Offline
Exactly what I needed, bookmarked
Floor 7 Posted 2011-01-23 18:11 ·  中国 广东 深圳 电信
新手上路
Credits 7
Posts 4
Joined 2011-01-22 16:56
15-year member
UID 180918
Gender Male
Status Offline
Thanks
Forum Jump: