VB怎么样读取ttf字体中的postScriptName信息

Carlven2012 2014-07-31 09:38:48
如题,以前问过好多地方,都无人知道,很不心甘。
注意:不是字体名称,而是字体的postScriptName。
顺便我说一下获取它,是用在什么地方: Photoshop调用字体,就是以字体的postScriptName为准来区别字体的。
...全文
576 32 打赏 收藏 转发到动态 举报
写回复
用AI写文章
32 条回复
切换为时间正序
请发表友善的回复…
发表回复
Carlven2012 2014-08-23
  • 打赏
  • 举报
回复
引用 31 楼 Chen8013 的回复:
我有一个“BT”的办法, 就是从文件尾部,按“关键字”直接读取出来。 哈哈……
你说对了,我就是分析文件结构才读取得到那些信息:

Private Type OFFSET_TABLE
    uMajorVersion As Integer
    uMinorVersion As Integer
    uNumOfTables As Integer
    uSearchRange As Integer
    uEntrySelector As Integer
    uRangeShift As Integer
End Type

Private Type TABLE_DIRECTORY
    szTag As String * 4
    uCheckSum As Long
    uOffset As Long
    uLength As Long
End Type

Private Type NAME_TABLE_HEADER
    uFSelector As Integer
    uNRCount As Integer
    uStorageOffset As Integer
End Type

Private Type NAME_RECORD
    uPlatformID As Integer
    uEncodingID As Integer
    uLanguageID As Integer
    uNameID As Integer
    uStringLength As Integer
    uStringOffset As Integer
End Type

Private Enum NameIDs
    gfiCopyrightNotice = 0                                 ' Copyright notice
    gfiFontFamilyName = 1                                  ' Font Family name
    gfiFontSubfamilyName = 2
    gfiUniqueFontIdentifier = 3                            ' Some unique ID for this font.
    gfiFullFontName = 4
    gfiVersionString = 5
    gfiPostscriptName = 6                                  ' Postscript name for the font.
    gfiTrademark = 7                                       ' Trademark notice/information for this font.
End Enum
舉杯邀明月 2014-08-17
  • 打赏
  • 举报
回复
我有一个“BT”的办法,
就是从文件尾部,按“关键字”直接读取出来。
哈哈……
PctGL 2014-08-16
  • 打赏
  • 举报
回复
这么热闹啊, 等我有空的时候我帮lz研究研究
赵4老师 2014-08-11
  • 打赏
  • 举报
回复
参考: MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TTFONTS.DSP MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TTFONTS.HLP MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TTFONTS.PH MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TTFONTS.ERR MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TTFONTS.RES MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\DIALOGS.C MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\DISPLAY.C MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TTFONTS.C MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TTFONTS.H MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\ALLFONT.C MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TOOLBAR.C MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TTFONTS.RC MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\MAKEFILE MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\README.TXT MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TTFONTS.ICO MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TTFONTS.HPJ MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TTFONTS.RTF MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TTFONTS.DEF MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\BMTT.BMP MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\BMDEVICE.BMP
Carlven2012 2014-08-10
  • 打赏
  • 举报
回复
哎,算了吧,结了,看来没人会。
赵4老师 2014-08-08
  • 打赏
  • 举报
回复
引用 21 楼 bcrun 的回复:
楼主太抠了,只出40分,给你加到200了:)
这算不算强迫消费?
bcrun 2014-08-08
  • 打赏
  • 举报
回复
楼主太抠了,只出40分,给你加到200了:)
Carlven2012 2014-08-08
  • 打赏
  • 举报
回复
可不可以不要复制MSDN里面的东西? 来点实在的行不,老大?(C语言我搞不懂)
赵4老师 2014-08-08
  • 打赏
  • 举报
回复
参考 MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\DIALOGS.C MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\DISPLAY.C MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TOOLBAR.C MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\FONTS\TTFONTS\TTFONTS.C
赵4老师 2014-08-08
  • 打赏
  • 举报
回复
Windows GDI GetFontData The GetFontData function retrieves font metric data for a TrueType font. DWORD GetFontData( HDC hdc, // handle to DC DWORD dwTable, // metric table name DWORD dwOffset, // offset into table LPVOID lpvBuffer, // buffer for returned data DWORD cbData // length of data ); Parameters hdc [in] Handle to the device context. dwTable [in] 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 file for TrueType font files or from the beginning of the data for the currently selected font for TrueType Collection files. To retrieve the data from the beginning of the file for TrueType Collection files specify 'ttcf' (0x66637474). dwOffset [in] 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 [out] Pointer to a buffer that receives the font information. If this parameter is NULL, the function returns the size of the buffer required for the font data. cbData [in] 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/2000/XP: To get extended error information, call GetLastError. Remarks This function is intended to be used to retrieve TrueType font information directly from the font file by font-manipulation applications. For information about embedding fonts see the Font Embedding Reference. 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. Requirements Windows NT/2000/XP/Vista: Included in Windows NT 3.1 and later. Windows 95/98/Me: Included in Windows 95 and later. Header: Declared in Wingdi.h; include Windows.h. Library: Use Gdi32.lib. See Also Fonts and Text Overview, Font and Text Functions, GetTextMetrics, OUTLINETEXTMETRIC -------------------------------------------------------------------------------- Requirements Windows NT/2000/XP/Vista: Included in Windows NT 3.1 and later. Windows 95/98/Me: Included in Windows 95 and later. Header: Declared in Wingdi.h; include Windows.h. Library: Use Gdi32.lib. See Also Fonts and Text Overview, Font and Text Functions, GetTextMetrics, OUTLINETEXTMETRIC -------------------------------------------------------------------------------- Windows GDI GetFontLanguageInfo The GetFontLanguageInfo function returns information about the currently selected font for the specified display context. Applications typically use this information and the GetCharacterPlacement function to prepare a character string for display. DWORD GetFontLanguageInfo( HDC hdc // handle to DC ); Parameters hdc [in] Handle to a display device context. Return Values The return value identifies characteristics of the currently selected font. The function returns 0 if the font is "normalized" and can be treated as a simple Latin font; it returns GCP_ERROR if an error occurs. Otherwise, the function returns a combination of the following values. Value Meaning GCP_DBCS The character set is DBCS. GCP_DIACRITIC The font/language contains diacritic glyphs. FLI_GLYPHS The font contains extra glyphs not normally accessible using the code page. Use GetCharacterPlacement to access the glyphs. This value is for information only and is not intended to be passed to GetCharacterPlacement. GCP_GLYPHSHAPE The font/language contains multiple glyphs per code point or per code point combination (supports shaping and/or ligation), and the font contains advanced glyph tables to provide extra glyphs for the extra shapes. If this value is specified, the lpGlyphs array must be used with the GetCharacterPlacement function and the ETO_GLYPHINDEX value must be passed to the ExtTextOut function when the string is drawn. GCP_KASHIDA The font/ language permits Kashidas. GCP_LIGATE The font/language contains ligation glyphs which can be substituted for specific character combinations. GCP_USEKERNING The font contains a kerning table which can be used to provide better spacing between the characters and glyphs. GCP_REORDER The language requires reordering for displayfor example, Hebrew or Arabic. The return value, when masked with FLI_MASK, can be passed directly to the GetCharacterPlacement function. Windows NT/2000/XP: To get extended error information, call GetLastError. Requirements Windows NT/2000/XP/Vista: Included in Windows NT 4.0 and later. Windows 95/98/Me: Included in Windows 95 and later. Header: Declared in Wingdi.h; include Windows.h. Library: Use Gdi32.lib. See Also Fonts and Text Overview, Font and Text Functions, ExtTextOut, GetCharacterPlacement -------------------------------------------------------------------------------- Requirements Windows NT/2000/XP/Vista: Included in Windows NT 4.0 and later. Windows 95/98/Me: Included in Windows 95 and later. Header: Declared in Wingdi.h; include Windows.h. Library: Use Gdi32.lib. See Also Fonts and Text Overview, Font and Text Functions, ExtTextOut, GetCharacterPlacement --------------------------------------------------------------------------------
Carlven2012 2014-08-08
  • 打赏
  • 举报
回复
查到了下面两个函数,仿佛与它俩有点关系,有熟悉它俩的师兄吗? 这两个函数是: GetFontData 返回字体数据 GetFontLanguageInfo 获取字体显示描述表的信息
Carlven2012 2014-08-08
  • 打赏
  • 举报
回复
引用 22 楼 zhao4zhong1 的回复:
[quote=引用 21 楼 bcrun 的回复:]
楼主太抠了,只出40分,给你加到200了:)


这算不算强迫消费?[/quote]
THK,版主深明大义。我对这论坛的功能还不太熟悉,之前是因为分不够。
BTW: OllyDbg和APIMonitor我都不会用啊,而且我下的那个字体试衣间软件,它说是用的什么虚拟的什么技术,不安装,直接运行,我试了下APIMonitor,没看到有什么价值的东西。不过我发现另一款软件FontExpert 2014也能查看字体的PostScript Name。
赵4老师 2014-08-07
  • 打赏
  • 举报
回复
引用 19 楼 Carlven2012 的回复:
对的, “字体试衣间”那软件就可以显示字体的PostScript Name这一属性。 但是拜托赵老师,我不是要软件,我是想知道获取字体这一属性的原理或方法呀。
用APIMonitor软件或OllyDbg软件查看“字体试衣间”软件调用哪些API和怎么调用获取字体这一属性的原理或方法。
Carlven2012 2014-08-06
  • 打赏
  • 举报
回复
对的, “字体试衣间”那软件就可以显示字体的PostScript Name这一属性。 但是拜托赵老师,我不是要软件,我是想知道获取字体这一属性的原理或方法呀。
赵4老师 2014-08-06
  • 打赏
  • 举报
回复
搜“字体试衣间”?
Carlven2012 2014-08-05
  • 打赏
  • 举报
回复
微软也有介绍:http://www.microsoft.com/typography/otspec/name.htm 就是不知道用什么函数、方法来取得它。
Carlven2012 2014-08-05
  • 打赏
  • 举报
回复
实在没法,看来我也只有调用Photoshop来获取了,虽然得等Photoshop启动成功后才能获取,效率也低了不少....
Carlven2012 2014-08-05
  • 打赏
  • 举报
回复
'The following name ID's are defined, and they apply to all platforms: Private Enum NameIDs ' (page 81: "Name ID's") ' Name strings are stored by platform, encoding and language (placing ' separate strings in for both Apple and MS platforms) gfiCopyrightNotice = 0 ' Copyright notice gfiFontFamilyName = 1 ' Font Family name gfiFontSubfamilyName = 2 ' For purposes of definition, this is assumed ' to address style (italic, oblique) and weight ' (light, bold, black, etc.) only. A font with ' no particular differences in weight or style ' (e.g. medium weight, not italic and fsSelection ' bit 6 set) should have the string "Regular" ' stored in this position. gfiUniqueFontIdentifier = 3 ' Some unique ID for this font. gfiFullFontName = 4 ' this should simply be a combination of strings 1 ' and 2. Exception: if string 2 is "Regular," then ' use only string 1. This is the font name that ' Windows will expose to users. gfiVersionString = 5 ' Version string. Supposed to be in n.nn format, ' but may include whatever (e.g. a date) gfiPostscriptName = 6 ' Postscript name for the font. gfiTrademark = 7 ' Trademark notice/information for this font. End Enum 谢谢楼上大哥的关注。 这是我在国外网站找到的一点信息。
舉杯邀明月 2014-08-05
  • 打赏
  • 举报
回复
今天上班有点忙,大概看了一下,
EnumFontFamExProc()
系统传过来的数据中,在lpElfe里面,
根本就找不到12楼中那种postScriptName模样的内容。
楼主在12楼的代码,可以贴出来看看不?

并且,真心觉得从API浏览器中得到的
ENUMLOGFONTEX类型定义,完全是错误的。

舉杯邀明月 2014-08-04
  • 打赏
  • 举报
回复
是不是数据类型的定义有误啊?
你看看,那个postScriptName的内容都不完整的。
明天上班有空再分析一下。
加载更多回复(12)

1,485

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧