读书人

怎么获得某个字体支持的字号大小情况

发布时间: 2012-01-19 20:57:58 作者: rapoo

如何获得某个字体支持的字号大小情况?
比如记事本中打开font对话框,选择某个字体后右边的“大小”列表中会显示出这个字体所默认支持的大小情况,有什么api可以获得这个数据吗?
双击直接打开字体的ttf文件可以看到它里面支持的字号大小情况的,我觉得应该有什么api函数可以获得,有人做过这方面的研究吗?

[解决办法]
你不选那就是使用系统默认的大小了。
[解决办法]
白猫已经找到答案了,放出来吧
[解决办法]

探讨
比如记事本中打开font对话框,选择某个字体后右边的“大小”列表中会显示出这个字体所默认支持的大小情况,有什么api可以获得这个数据吗?
双击直接打开字体的ttf文件可以看到它里面支持的字号大小情况的,我觉得应该有什么api函数可以获得,有人做过这方面的研究吗?

[解决办法]
有是肯定的,只是俺不知道,但是俺不胡说八道
[解决办法]
楼主,可以换头像了
给1000可用分我就告诉你怎么换
[解决办法]
点阵字体支持的字号是有限的。但TrueType字体却不一样,属无级变化字体。我刚测试了一下,Fixedsys字体默认的字号只有12,但随便输入一个200,却是可以的。
推荐你看一遍文章:TrueType字体技术 http://translate.google.com.hk/translate?hl=zh-CN&sl=zh-TW&u=http://www.netprint101.com/text/43373744-225.html&ei=923DTbC4LoukugPu7OCfAQ&sa=X&oi=translate&ct=result&resnum=1&ved=0CB8Q7gEwAA&prev=/search%3Fq%3DTrueType%25E5%25AD%2597%25E4%25BD%2593%25E6%259C%2589%25E6%25B2%25A1%25E6%259C%2589%25E5%25A4%25A7%25E5%25B0%258F%25E9%2599%2590%25E5%2588%25B6%26hl%3Dzh-CN%26newwindow%3D1%26safe%3Dstrict%26biw%3D1276%26bih%3D827%26prmd%3Divns
[解决办法]
字体大小的限定在正常的使用当中几乎是感觉不到的,无论是什么样的字体,在 Windows 中,
都是从 GDI 接口输出到屏幕上的,也就是以图形方式输出而来,在 GDI 设备当中,字体对象
被选入 GDI 设备后,系统会根据你设置的字体大小自动运算字体输出所需要的点阵图,然后刷
新到设备上,这种参数的所谓限制,主要是在字体过大,无法处理那么大的点阵图数据,导致内
存溢出,并不存在计算上的限制或固定格式上的限制。通常的软件会给出常用的字号作为参考,
并不是读取到什么特定参数表,而是自定义几个常用的字号而已。
如果你不相信,你可以尝试使用 Label 控件做个实验:
Label1.FontSize = 1000
一样放大给你看,至于再大比如2160以上,在我这里是不行了,可能不同的显卡和分辨率支持
不一样也不一定,因为 Windows 的 GDI 支持的大小也与显卡和分辨率有关。估计字体过大
溢出也是这么个原因。
[解决办法]
一起鄙视床上等你~~
[解决办法]
GetFontData???
[解决办法]
GetFontData
The GetFontData function retrieves font metric data for a TrueType font.

DWORD GetFontData(
HDC hdc, // handle to device context
DWORD dwTable, // metric table to query
DWORD dwOffset, // offset into table being queried
LPVOID lpvBuffer, // pointer to buffer for returned data
DWORD cbData // length of data to query
);

Parameters
hdc
Handle to the device context.
dwTable
Specifies the name of a font metric table from which the font data is to be retrieved. This parameter can identify one of the metric tables documented in the TrueType Font Files specification published by Microsoft Corporation. If this parameter is zero, the information is retrieved starting at the beginning of the font file.
dwOffset
Specifies the offset from the beginning of the font metric table to the location where the function should begin retrieving information. If this parameter is zero, the information is retrieved starting at the beginning of the table specified by the dwTable parameter. If this value is greater than or equal to the size of the table, an error occurs.
lpvBuffer
Pointer to a buffer to receive the font information. If this parameter is NULL, the function returns the size of the buffer required for the font data.
cbData
Specifies the length, in bytes, of the information to be retrieved. If this parameter is zero, GetFontData returns the size of the data specified in the dwTable parameter.


Return Values
If the function succeeds, the return value is the number of bytes returned.

If the function fails, the return value is GDI_ERROR.

Windows NT: To get extended error information, callGetLastError.

Remarks
An application can sometimes use the GetFontData function to save a TrueType font with a document. To do this, the application determines whether the font can be embedded by checking the otmfsType member of the OUTLINETEXTMETRIC structure. If bit 1 of otmfsType is set, embedding is not permitted for the font. If bit 1 is clear, the font can be embedded. If bit 2 is set, the embedding is read-only. If embedding is permitted, the application can retrieve the entire font file, specifying zero for the dwTable, dwOffset, and cbData parameters.

If an application attempts to use this function to retrieve information for a non-TrueType font, an error occurs.


[解决办法]
其实微软的网站上已经说得很清楚了,无论是TrueType字体,还是OpenType字体,都是无级变化字体。
参见微软的网站:http://windows.microsoft.com/zh-CN/windows7/Fonts-frequently-asked-questions
[解决办法]
怎么又回来了乜,莫非要注销了重来?

读书人网 >VB

热点推荐