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-01 20:50
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » DOS font issue View 2,589 Replies 11
Original Poster Posted 2006-09-20 05:13 ·  中国 北京 丰台区 联通
初级用户
Credits 25
Posts 9
Joined 2006-04-01 08:53
20-year member
UID 53148
Gender Male
Status Offline
When I am making the graphical interface of the program, I need to use many different fonts, and these fonts are all available in Windows, such as FangSong, XinWei, etc. I want to ask everyone, for the programs running under DOS (both 16-bit and 32-bit), is there a more convenient font solution to realize the display of Windows fonts?
Floor 2 Posted 2006-09-20 07:37 ·  中国 北京 丰台区 联通
初级用户
Credits 25
Posts 9
Joined 2006-04-01 08:53
20-year member
UID 53148
Gender Male
Status Offline
Hope that friends who see this post can help top it. If you think this question is very naive, please also give me a little guidance in your busy schedule. Maybe a few words from you will help me a lot. Thank you.
Floor 3 Posted 2006-09-20 12:09 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 2,227
Posts 790
Joined 2005-01-27 00:00
21-year member
UID 35703
Gender Male
Status Offline
Please go to the Chinese version to find the post where "Benshi" provided about VGA text Chinese character display!
my major is english----my love is dos----my teacher is the buddha----my friends--how about U
Floor 4 Posted 2006-09-22 11:06 ·  中国 广东 广州 白云区 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
Among 16x16 dot matrix Chinese characters under DOS, only the default SimSun font looks the best
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 5 Posted 2006-09-22 20:56 ·  中国 北京 联通
初级用户
Credits 25
Posts 9
Joined 2006-04-01 08:53
20-year member
UID 53148
Gender Male
Status Offline
Floor 6 Posted 2006-09-22 21:15 ·  中国 北京 联通
初级用户
Credits 25
Posts 9
Joined 2006-04-01 08:53
20-year member
UID 53148
Gender Male
Status Offline
By the way, when I use the PictureBox control to generate the character font, there is a place that feels very awkward, that is, the issue of font size. Since I need to scan the characters in the PictureBox one by one, the key point is to know how many pixels the character of this font occupies, such as 16*16 or 32*32. But the units of Windows font size are all points. So my method is to scan a character and then measure its length and width boundaries, and use this boundary as the length and width pixel values of the font for future display and scanning. I always feel this method is quite awkward, and I hope everyone can also give some pointers.
Floor 7 Posted 2006-09-22 21:52 ·  中国 湖南 长沙 电信
中级用户
★★
Credits 282
Posts 126
Joined 2006-05-17 22:29
20-year member
UID 55724
Status Offline
1 twip = 1/1440 inch
1 point = 1/72 inch = 20 twips

But it is more complicated to convert these units to pixels:
Horizontal 1 inch = GetDeviceCaps(hDC, LOGPIXELSX) pixels
Vertical 1 inch = GetDeviceCaps(hDC, LOGPIXELSY) pixels

GetDeviceCaps is a GDI API used to get the properties of the DC
hDC is the DC you use for drawing, such as: Picture1.hDC


So the font height is generally calculated like this:
lfHeight = PointSize * GetDeviceCaps(hDC, LOGPIXELSY) / 72


Since the Screen object's TwipsPerPixelX, TwipsPerPixelY properties can be used to know how many twips are in one pixel, so it can be calculated like this:
lfHeight = PointSize * 20 / Screen.TwipsPerPixelY
人类存在的目的就是试图理解人类为何存在
Floor 8 Posted 2006-09-22 22:05 ·  中国 湖南 长沙 电信
中级用户
★★
Credits 282
Posts 126
Joined 2006-05-17 22:29
20-year member
UID 55724
Status Offline
Text layout is very complicated.

You can use GetTextMetrics to obtain the text layout information of the current font, and GetOutlineTextMetrics can further obtain the text layout information of TTF fonts.

GetCharABCWidths and GetCharABCWidthsFloat can obtain the left and right hanging attributes of the font, which are used for non - monospaced fonts or italic states, allowing a part of one character to be located within the cell of another character, such as: fffffff

Use GetTextExtentPoint32 to calculate the size occupied by a string after drawing on this DC
人类存在的目的就是试图理解人类为何存在
Floor 9 Posted 2006-09-25 07:12 ·  中国 北京 海淀区 联通
初级用户
Credits 25
Posts 9
Joined 2006-04-01 08:53
20-year member
UID 53148
Gender Male
Status Offline
Thank you very much. I'm sorry I'm slow-witted and didn't understand much. I'll study your post again. Thanks.
Floor 10 Posted 2006-11-01 10:32 ·  中国 浙江 嘉兴 海宁市 电信
初级用户
Credits 118
Posts 10
Joined 2004-06-15 00:00
22-year member
UID 26789
Gender Male
Status Offline
Make your own dedicated font library and writing function, or design your own CHR font.

There is a software for making CHR font libraries, which can make Chinese CHR font libraries, but each file can hold at most 255 Chinese characters.
Floor 11 Posted 2006-11-01 10:34 ·  中国 浙江 嘉兴 海宁市 电信
初级用户
Credits 118
Posts 10
Joined 2004-06-15 00:00
22-year member
UID 26789
Gender Male
Status Offline
If you make your own font, first decide whether to make a monospaced font or a proportional font. The implementation is very different!
Floor 12 Posted 2006-11-01 10:34 ·  中国 浙江 嘉兴 海宁市 电信
初级用户
Credits 118
Posts 10
Joined 2004-06-15 00:00
22-year member
UID 26789
Gender Male
Status Offline
I just noticed it's stone after replying, heh
Forum Jump: