点阵字体, 矢量字体

点阵字体

http://zh.wikipedia.org/wiki/%E7%82%B9%E9%98%B5%E5%AD%97%E4%BD%93

点阵字体也叫位图字体,其中每个字形都以一组二维像素信息表示。这种文字显示方式于较早前的电脑系统(例如未有图形接口时的 DOS 操作系统)被普遍采用。
由于位图的缘故,点阵字体很难进行缩放,特定的点阵字体只能清晰地显示在相应的字号下,否则文字只被强行放大而有损字形,产生成马赛克式的锯齿边缘。
但对于字号 8-14px 的尺寸较小的汉字字体(即现今操作系统大多采用的默认字号)现今亦仍然被使用于荧幕显示上,能够提供更高的显示效果;
不过现今该种点阵字体主要只作为“辅助”的部分,当用户设置的字体尺寸并没有拥有位图像时,字体便会以矢量图象方式显示;
而当打印时,印有字体无论大小亦会使用矢量字体打印。常见的纯点阵字体有 bdf,pcf,fnt,hbf 等格式。

矢量字体

http://zh.wikipedia.org/wiki/%E7%9F%A2%E9%87%8F%E5%AD%97%E4%BD%93

矢量字体 是与 点阵字体 相对应的一种字体。

矢量字体的每个字形都是通过数学方程来描述的,一个字形上分区出若干个关键点,相邻关键点之间由一条光滑曲线连接,这条曲线可以由有限个参数来唯一确定。
矢量字的好处是字体可以无级缩放而不会产生变形。目前主流的矢量字体格式有3种:

Type1TrueTypeOpenType,这三种格式都是平台无关的。

Type1全称PostScript Type1,是1985年由Adobe公司提出的一套矢量字体标准,由于这个标准是基于PostScript Description Language(PDL),
而PDL又是高端打印机首选的打印描述语言,所以Type1迅速流行起来。但是Type1是非开放字体,Adobe对使用Type1的公司征收高额的使用费。

TrueType是1991年由Apple公司与Microsoft公司联合提出另一套矢量字标准。

Type1使用三次贝塞尔曲线来描述字形,TrueType则使用二次贝塞尔曲线来描述字形。
所以Type1的字体比TrueType字体更加精确美观。一个误解是,Type1字体比TrueType字体占用空间多。
这是因为同样描述一个圆形,二次贝塞尔曲线只需要8个关键点和7段二次曲线;而三次贝塞尔曲线则需要12个关键点和11段三次曲线。
然而实际情况是一般来说 Type1比TrueType要小10%左右。这是因为对于稍微复杂的字形,为了保持平滑,TrueType必须使用更多的关键点。
由于现代大部分打印机都是使用PDL作为打印描述语言,所以True1字体打印的时候不会产生形变,速度快;
而TrueType则需要翻译成PDL,由于曲线方程的变化,还会产生一定的形变,不如Type1美观。

这么说来,Type1应该比TrueType更具有优势,为什么如今的计算机上TrueType反而比Type1使用更广泛呢?

第一个原因是:Type1由于字体方程的复杂,所以在屏幕上渲染的时候花费的时间多,解决方案是大部分Type1字体嵌入了点阵字体,这样渲染快,
但是边缘不光滑,比较难看。很多ps文档和ps转换的pdf文档都是这样,在计算机上浏览的时候字体很难看,但是打印出来很美观。
TrueType则渲染比较快,可以平滑的显示在屏幕上,看上去很美观。

第二个原因是Type1的高额使用费,使得Type1没有被所有的操作系统所支持。
Windows家族只有OS/2和Windows 2000及之后的版本从操作系统级别开始支持Type1。
由于这个问题,Adobe只好在其所有的产品中嵌入Adobe Type Manager(ATM)作为渲染引擎。

OpenType则是Type1与TrueType之争的最终产物。
1995年,Adobe公司和Microsoft公司开始联手开发一种兼容Type1和TrueType,并且真正支持Unicode的字体,后来在发布的时候,正式命名为OpenType。
OpenType可以嵌入Type1和TrueType,这样就兼有了二者的特点,无论是在屏幕上察看还是打印,质量都非常优秀。
可以说OpenType是一个三赢的结局,无论是Adobe,Microsoft还是最终用户,都从OpenType中得到了好处。
Windows家族从Windows 2000开始,正式支持OpenType。
打开系统的字体目录(一般是C:\Windows\Fonts\或C:\Winnt\Fonts),可以看到:
一个红色A的图标的是点阵字体,
两个蓝色重叠的T的图标是TrueType字体,
两个绿色重叠的T的图标是TrueType字体集,
一个绿色O的图标就是OpenType字体。

如果字体扩展名为FON表示点阵字库
如果扩展名为TTF/OTF则表示矢量字库
如果扩展名为TTC则表示矢量字库集

Raster, Vector, TrueType, and OpenType Fonts

http://msdn.microsoft.com/ZH-CN/library/windows/desktop/dd162893(v=vs.85).aspx

Applications can use four different kinds of font technologies to display and print text:

  • Raster
  • Vector
  • TrueType
  • Microsoft OpenType

The differences between these fonts reflect the way that the glyph for each character or
symbol is stored in the respective font-resource file:

  • In raster fonts, a glyph is a bitmap
    that the system uses to draw a single character or symbol in the font.
  • In vector fonts, a glyph is a collection of line endpoints that define the line segments
    that the system uses to draw a character or symbol in the font.
  • In TrueType and OpenType fonts, a glyph is a collection of line and curve commands as well as a collection of hints.

The system uses the line and curve commands to define the outline of the bitmap
for a character or symbol in the TrueType or Microsoft OpenType font.
The system uses the hints to adjust the length of the lines and shapes of the curves used to draw the character or symbol.
These hints and the respective adjustments are based on the amount of scaling used to reduce or increase the size of the bitmap.
An OpenType font is equivalent to a TrueType font except that an OpenType font
allows PostScript glyph definitions in addition to TrueType glyph definitions.

Because the bitmaps for each glyph in a raster font are designed for a specific resolution of device,
raster fonts are generally considered to be device dependent.

Vector fonts, on the other hand, are not device dependent,
because each glyph is stored as a collection of scalable lines.

However, vector fonts are generally drawn more slowly than raster or TrueType and OpenType fonts.

TrueType and OpenType fonts provide both relatively fast drawing speed and true device independence.
By using the hints associated with a glyph, a developer can scale the characters
from a TrueType or OpenType font up or down and still maintain their original shape.

As previously mentioned, the glyphs for a font are stored in a font-resource file.
A font-resource file is actually a DLL that contains only data, there is no code.

For raster and vector fonts, this data is divided into two parts:

A header describing the font's metrics and the glyph data.
A font-resource file for a raster or vector font is identified by the .fon file name extension.

For TrueType and OpenType fonts, there are two files for each font:

the first file contains a relatively short header and
the second contains the actual font data.

The first file is identified by an .fot extension and
the second is identified by a .ttf extension.

 

TrueType、PostScript 和 OpenType 字体之间的区别是什么? 

http://windows.microsoft.com/zh-cn/windows-vista/whats-the-difference-between-truetype-postscript-and-opentype-fonts 

TrueType 字体可调整到任意大小,并且在所有大小情况下,都是清晰可读的。可以将它们发送给 Windows 支持的任何打印机或其他输出设备。
OpenType 字体与 TrueType 字体相关,但包括更大的基本字符集扩展,包括小型大写、老样式数字及更复杂的形状,
“字形”“连字”。OpenType 字体在任意大小下仍清晰可读,并且可以发送到 Windows 支持的任何打印机或其他输出设备。
PostScript 字体线条平滑、细节突出,是一种高质量的字体。他们经常用于打印,尤其是经常用于如书籍或杂志等的专业质量的打印。

哪种字体最适合我?

不一定。如果只想要一种打印效果好,并且在屏幕上易于阅读的字体,则可以考虑使用 TrueType 字体。
如果需要大型字符集用于语言覆盖和精细的版式,则可能想要使用 OpenType 字体。
如果需要打印专业质量的印刷出版物,如有光泽的杂志,或需要进行商业打印,则 PostScript 字体是一种很好的选择。

TrueType

http://zh.wikipedia.org/wiki/TrueType 

TrueType是由美国苹果公司和微软公司共同开发的一种电脑轮廓字体类型标准。这种类型字体文件的扩展名是.ttf,类型代码是tfil

早在80年代末,苹果公司为了对抗Adobe公司的Type 1PostScript字体,设计开发了TrueType,之后微软加入了开发,后来视窗系统的字体格式基本上都统一成TrueType,
而在苹果的麦金塔系统中却成了PostScript和TrueType对立的局面。TrueType后来也被Linux等系统使用,成为标准字体。
TrueType的主要强项在于它能给开发者提供关于字体显示、不同字体大小的像素级显示等的高级控制。

在新开发的OpenType类型字体中,可以选择PostScript还是TrueType作为记述方式。

TrueType字体中的字符(或 字形)轮廓由直线和二次贝塞尔曲线片段构成。这些构建在数学上比平面设计界PostScript使用的三次贝塞尔曲线(也被Type 1 字体所使用)更容易处理。
尽管如此,对于多数形状,三次要比二次贝塞尔曲线需要更多的点来描述。这个差异也意味着它不能将 Type 1 无损地转换为TrueType格式,可是你可以无损地将TrueType转换为Type 1。

OpenType

https://zh.wikipedia.org/wiki/OpenType

OpenType,是一种可缩放字型(scalable font)电脑字体类型,采用PostScript格式,是美国微软公司Adobe公司联合开发,用来替代TrueType字型的新字型。
这类字体的文件扩展名为.otf,类型代码是OTTO,现行标准为OpenType 1.4。

OpenType最初发表于1996年,并在2000年之后出现大量字体。它源于微软公司的TrueType Open字型,TrueType Open字型又源于TrueType字型。
OpenType font包括了Adobe CID-Keyed font技术。Adobe公司已经在2002年末将其字体库全部改用OpenType格式。
到2005年大概有一万多种OpenType字体,Adobe产品占了三分之一。

OpenType之前的主流是苹果公司和微软开发的TrueType类型,还有Adobe公司开发的Type 1("PostScript")字体类型。
微软在1994年独自开发了"TrueType Open"类型[1],之后1996年Adobe加入开发,增加了其在Type 1字体中使用的对字体轮廓的支持,OpenType这个名字于是便用来称呼合并之后的技术。

在后来的十几年中,Adobe和微软继续开发改进OpenType格式,在2005年末,OpenType开始申请成为国际标准组织(ISO)的公开标准。
这个新标准已经升级到OpenType 1.4,以适应ISO语言标准的一些变化,之后其被称为"开放字体类型(Open Font Format)"。这个新标准计划在2006年末完成。

OpenType使用TrueType字体通用的"sfnt"架构,但其加入若干“智能字体”(smartfont)选项,可以加强字体的字形和语言支持能力。
OpenType字体中的字形(glyph)、轮廓数据可以在两种格式中任选其一:
一个是在'glyf'表中TrueType格式轮廓,另一个是在'CFF '表中的CFF(压缩字体格式,Compact Font Format)格式轮廓。
CFF轮廓数据是基于PostScript语言Type 2字体格式。表格名'CFF '长度为四个字符,并且以一个空格字符结尾。

在如版式等大多数情况下,轮廓数据格式是什么类型并不重要,但这两种格式的区别在图元光栅化(rasterisation)的时候就有区别。
而单从"OpenType"一词中看不出来使用的是哪种数据格式,所以有时候使用"OpenType (PostScript flavor)", "OpenType CFF",或者"OpenType (TrueType flavor)"等称呼加以区别。

OpenType的主要特征有:

  • 字体编码基于万国码(Unicode),可以支持任何文本,或者同时支持多种文本。
  • 一个OpenType字体可以带有超多65,536个字形。对于中文字库而言,最基本的字汇应该包含Big5的13,060个汉字或是GB2312-80标准的6763个常用字型,
    这些字应该能满足一般用户的使用,对于户籍管理、银行系统和出版社等用户而言需要2万多字甚至7万多字的支持。
  • 字体有高级字形特征,可以进行对复杂文本进行充分的字形处理,并能通过更简单的脚本施加更复杂的字形效果,比如用罗马字母脚本书写英文。
  • 字体文件可以拓展到跨平台,能够在Mac OS,Windows和一些Unix系统中进行设置。
  • 若不含异体字等拓展字形和拓展文字性能,OpenType CFF字体比Type 1要小

PostScript字体

http://baike.baidu.cn/view/121491.htm

按 PostScript 页面描述语言 (PDL) 规则定义的字体,并且只能在 PostScript 兼容的打印机上打印。
当按屏幕字体显示的文档被发送到 PostScript 打印机时,如果有 PostScript 版本的字体,则打印机将使用该字体打印。
如果该字体不存在,但计算机安装了该版本的字体,则该字体将被下载到打印机。
如果打印机或计算机上都没有安装 PostScript font 字体,则位映射字体(光栅字体)被转换为 PostScript 字体,而打印机就使用位映射字体打印文本。
按印刷工业中的质量标准,PostScript 字体在平滑性、细节和忠实性方面比位映射字体要好

光栅字体

存储为位图的字体。光栅字体是为特定打印机设计的,有特定的大小和分辨率,而且不能缩放或旋转。如果打印机不支持光栅字体,就不会打印这些字体。
五种光栅字体分别为 Courier、MS Sans Serif、MS Serif、Small 和 Symbol。光栅字体也被称为位图字体。

Enumerating the Installed Fonts

http://msdn.microsoft.com/en-us/library/windows/desktop/dd162615(v=vs.85).aspx

In some instances, an application must be able to enumerate the available fonts and select the one most appropriate for a particular operation.
An application can enumerate the available fonts by calling the EnumFonts or EnumFontFamilies function.
These functions send information about the available fonts to a callback function that the application supplies.
The callback function receives information in LOGFONT and NEWTEXTMETRIC structures.
(The NEWTEXTMETRIC structure contains information about a TrueType font.
When the callback function receives information about a non-TrueType font, the information is contained in a TEXTMETRIC structure.)
By using this information, an application can limit the user's choices to only those fonts that are available.

The EnumFontFamilies function is similar to the EnumFonts function but includes some extra functionality. 
EnumFontFamilies allows an application to take advantage of styles available with TrueType fonts.
New and upgraded applications should use 
EnumFontFamilies instead of EnumFonts.

TrueType fonts are organized around a typeface name (for example, Courier New) and style names (for example, italic, bold, and extra-bold).
The EnumFontFamilies function enumerates all the styles associated with a specified family name, not simply the bold and italic attributes.
For example, when the system includes a TrueType font called Courier New Extra-BoldEnumFontFamilies lists it with the other Courier New fonts.
The capabilities of EnumFontFamilies are helpful for fonts with many or unusual styles and for fonts that cross international borders.

If an application does not supply a typeface name, the EnumFonts and EnumFontFamiliesfunctions supply information about one font in each available family.
To enumerate all the fonts in a device context, the application can specify NULL for the typeface name,
compile a list of the available typefaces, and then enumerate each font in each typeface.

EnumFonts function

The EnumFonts function enumerates the fonts available on a specified device.
For each font with the specified typeface name, the EnumFonts function retrieves information about
that font and passes it to the application defined callback function.
This callback function can process the font information as desired.
Enumeration continues until there are no more fonts or the callback function returns zero.

Note  This function is provided only for compatibility with 16-bit versions of Windows. Applications should use the EnumFontFamiliesEx function.

int EnumFonts(
  _In_  HDC hdc,
  _In_  LPCTSTR lpFaceName,
  _In_  FONTENUMPROC lpFontFunc,
  _In_  LPARAM lParam
);

 

Parameters

hdc [in]

A handle to the device context from which to enumerate the fonts.

lpFaceName [in]

A pointer to a null-terminated string that specifies the typeface name of the desired fonts.
If lpFaceName is NULLEnumFonts randomly selects and enumerates one font of each available typeface.

lpFontFunc [in]

A pointer to the application definedcallback function. For more information, see EnumFontsProc.

lParam [in]

A pointer to any application-defined data. The data is passed to the callback function along with the font information.

Return value

The return value is the last value returned by the callback function. Its meaning is defined by the application.

Remarks

Use EnumFontFamiliesEx instead of EnumFonts.
The EnumFontFamiliesEx function differs from the EnumFonts function in that it retrieves the style names associated with a TrueType font.
With EnumFontFamiliesEx, you can retrieve information about font styles that cannot be enumerated using the EnumFonts function.

The fonts for many East Asian languages have two typeface names: an English name and a localized name. 
EnumFontsEnumFontFamilies, and EnumFontFamiliesEx return the English typeface name if the system locale does not match the language of the font.

 

EnumFontFamilies function

http://msdn.microsoft.com/en-us/library/windows/desktop/dd162619(v=vs.85).aspx

The EnumFontFamilies function enumerates the fonts in a specified font family that are available on a specified device.
Note  This function is provided only for compatibility with 16-bit versions of Windows. Applications should use the EnumFontFamiliesEx function.

int EnumFontFamilies(
  _In_  HDC hdc,
  _In_  LPCTSTR lpszFamily,
  _In_  FONTENUMPROC lpEnumFontFamProc,
  _In_  LPARAM lParam
);

 

Parameters

hdc [in]

A handle to the device context from which to enumerate the fonts.

lpszFamily [in]

A pointer to a null-terminated string that specifies the family name of the desired fonts.
If lpszFamily is NULLEnumFontFamilies selects and enumerates one font of each available type family.

lpEnumFontFamProc [in]

A pointer to the application defined callback function. For information, see EnumFontFamProc.

lParam [in]

A pointer to application-supplied data. The data is passed to the callback function along with the font information.

Return value

The return value is the last value returned by the callback function. Its meaning is implementation specific.

Remarks

For each font having the typeface name specified by the lpszFamily parameter, the EnumFontFamilies function retrieves information about
that font and passes it to the function pointed to by the lpEnumFontFamProc parameter.
The application defined callback function can process the font information as desired.
Enumeration continues until there are no more fonts or the callback function returns zero.

When the graphics mode on the device context is set to GM_ADVANCED using the SetGraphicsMode function and
the DEVICE_FONTTYPE flag is passed to the FontType parameter, this function returns a list of type 1 and OpenType fonts on the system.
When the graphics mode is not set to GM_ADVANCED, this function returns a list of type 1, OpenType, and TrueType fonts on the system.

The fonts for many East Asian languages have two typeface names: an English name and a localized name. 
EnumFontsEnumFontFamilies, and EnumFontFamiliesEx return the English typeface name if the system locale does not match the language of the font.

EnumFontsProc 

The EnumFontsProc function is an application-defined callback function that processes font data from the EnumFonts function.
This function is provided only for compatibility with 16-bit versions of Windows. Applications should call the EnumFontFamiliesEx function.

The AND (&) operator can be used with the RASTER_FONTTYPE and DEVICE_FONTTYPE constants to determine the font type. 
The RASTER_FONTTYPE bit of the FontType parameter specifies whether the font is a raster or vector font. 
If the bit is one, the font is a raster font; if zero, it is a vector font. 
The DEVICE_FONTTYPE bit of FontType specifies whether the font is a device-based or graphics device interface (GDI)-based font. 
If the bit is one, the font is a device-based font; if zero, it is a GDI-based font.

The following example uses the EnumFontFamilies function to retrieve the number of available raster, vector, and TrueType font families.

    UINT uAlignPrev; 
    int aFontCount[] = { 0, 0, 0 }; 
    char szCount[8];
        HRESULT hr;
        size_t * pcch; 
 
    EnumFontFamilies(hdc, (LPCTSTR) NULL, 
        (FONTENUMPROC) EnumFamCallBack, (LPARAM) aFontCount); 
 
    uAlignPrev = SetTextAlign(hdc, TA_UPDATECP); 
 
    MoveToEx(hdc, 10, 50, (LPPOINT)NULL); 
    TextOut(hdc, 0, 0, "Number of raster fonts: ", 24); 
    itoa(aFontCount[0], szCount, 10); 
        
        hr = StringCchLength(szCount, 9, pcch);
        if (FAILED(hr))
        {
        // TODO: write error handler 
        }
    TextOut(hdc, 0, 0, szCount, *pcch); 
 
    MoveToEx(hdc, 10, 75, (LPPOINT)NULL); 
    TextOut(hdc, 0, 0, "Number of vector fonts: ", 24); 
    itoa(aFontCount[1], szCount, 10);
        hr = StringCchLength(szCount, 9, pcch);
        if (FAILED(hr))
        {
        // TODO: write error handler 
        } 
    TextOut(hdc, 0, 0, szCount, *pcch); 
 
    MoveToEx(hdc, 10, 100, (LPPOINT)NULL); 
    TextOut(hdc, 0, 0, "Number of TrueType fonts: ", 26); 
    itoa(aFontCount[2], szCount, 10);
        hr = StringCchLength(szCount, 9, pcch);
        if (FAILED(hr))
        {
        // TODO: write error handler 
        }
    TextOut(hdc, 0, 0, szCount, *pcch); 
 
    SetTextAlign(hdc, uAlignPrev); 
 
BOOL CALLBACK EnumFamCallBack(LPLOGFONT lplf, LPNEWTEXTMETRIC lpntm, DWORD FontType, LPVOID aFontCount) 
{ 
    int far * aiFontCount = (int far *) aFontCount; 
 
    // Record the number of raster, TrueType, and vector  
    // fonts in the font-count array.  
 
    if (FontType & RASTER_FONTTYPE) 
        aiFontCount[0]++; 
    else if (FontType & TRUETYPE_FONTTYPE) 
        aiFontCount[2]++; 
    else 
        aiFontCount[1]++; 
 
    if (aiFontCount[0] || aiFontCount[1] || aiFontCount[2]) 
        return TRUE; 
    else 
        return FALSE; 
 
    UNREFERENCED_PARAMETER( lplf ); 
    UNREFERENCED_PARAMETER( lpntm ); 
} 

 

This example uses two masks, RASTER_FONTTYPE and TRUETYPE_FONTTYPE, to determine the type of font being enumerated.
If the RASTER_FONTTYPE bit is set, the font is a raster font.
If the TRUETYPE_FONTTYPE bit is set, the font is a TrueType font.
If neither bit is set, the font is a vector font.
A third mask, DEVICE_FONTTYPE, is set when a device (for example, a laser printer) supports downloading TrueType fonts;
it is zero if the device is a display adapter, dot-matrix printer, or other raster device.
An application can also use the DEVICE_FONTTYPE mask to distinguish GDI-supplied raster fonts from device-supplied fonts.
The system can simulate bold, italic, underline, and strikeout attributes for GDI-supplied raster fonts, but not for device-supplied fonts.

An application can also check bits 1 and 2 in the tmPitchAndFamily member of the NEWTEXTMETRIC structure to identify a TrueType font.
If bit 1 is 0 and bit 2 is 1, the font is a TrueType font.

Vector fonts are categorized as OEM_CHARSET instead of ANSI_CHARSET.
Some applications identify vector fonts by using this information, checking the tmCharSet member of the NEWTEXTMETRIC structure.
This categorization usually prevents the font mapper from choosing vector fonts unless they are specifically requested.
(Most applications no longer use vector fonts because their strokes are single lines and
they take longer to draw than TrueType fonts, which offer many of the same scaling and rotation features that required vector fonts.)

EnumFontFamiliesEx function

The EnumFontFamiliesEx function enumerates all uniquely-named fonts in the system
that match the font characteristics specified by the LOGFONT structure.
EnumFontFamiliesEx enumerates fonts based on typeface name, character set, or both.

int EnumFontFamiliesEx(
  _In_  HDC hdc,
  _In_  LPLOGFONT lpLogfont,
  _In_  FONTENUMPROC lpEnumFontFamExProc,
  _In_  LPARAM lParam,
  DWORD dwFlags
);

 

Parameters

hdc [in]    

A handle to the device context from which to enumerate the fonts. 

 

 

lpLogfont [in]

A pointer to a LOGFONT structure that contains information about the fonts to enumerate. The function examines the following members.

Member

Description

lfCharSet

If set to DEFAULT_CHARSET, the function enumerates all uniquely-named fonts in all character sets.
(If there are two fonts with the same name, only one is enumerated.)
If set to a valid character set value, the function enumerates only fonts in the specified character set.

lfFaceName

If set to an empty string, the function enumerates one font in each available typeface name.
If set to a valid typeface name, the function enumerates all fonts with the specified name.

lfPitchAndFamily

Must be set to zero for all language versions of the operating system.

 

lpEnumFontFamExProc [in]

A pointer to the application defined callback function. For more information, see the EnumFontFamExProc function.

lParam [in]

An application defined value. The function passes this value to the callback function along with font information.

dwFlags

This parameter is not used and must be zero.

Return value

The return value is the last value returned by the callback function.
This value depends on which font families are available for the specified device.

Remarks

The EnumFontFamiliesEx function does not use tagged typeface names to identify character sets.
Instead, it always passes the correct typeface name and a separate character set value to the callback function.
The function enumerates fonts based on the values of the lfCharSet and lfFaceName members in the LOGFONT structure.

As with EnumFontFamiliesEnumFontFamiliesEx enumerates all font styles. Not all styles of a font cover the same character sets.
For example, Fontorama Bold might contain ANSI, Greek, and Cyrillic characters, but Fontorama Italic might contain only ANSI characters.
For this reason, it's best not to assume that a specified font covers a specific character set, even if it is the ANSI character set.
The following table shows the results of various combinations of values for lfCharSet andlfFaceName.

ValuesMeaning

lfCharSet = DEFAULT_CHARSET

lfFaceName = '\0'

Enumerates all uniquely-named fonts within all character sets.
If there are two fonts with the same name, only one is enumerated.

lfCharSet = DEFAULT_CHARSET

lfFaceName = a specific font

Enumerates all character sets and styles in a specific font.

lfCharSet =a specific character set

lfFaceName = '\0'

Enumerates all styles of all fonts in the specific character set.

lfCharSet =a specific character set

lfFaceName = a specific font

Enumerates all styles of a font in a specific character set.

 

The following code sample shows how these values are used.

// To enumerate all styles and charsets of all fonts: 
lf.lfFaceName[0] = '\0';
lf.lfCharSet = DEFAULT_CHARSET;
HRESULT hr;

// To enumerate all styles and character sets of the Arial font: 
hr = StringCchCopy( (LPSTR)lf.lfFaceName, LF_FACESIZE, "Arial" );
if (FAILED(hr))
{
// TODO: write error handler 
}

lf.lfCharSet = DEFAULT_CHARSET;



// To enumerate all styles of all fonts for the ANSI character set 
lf.lfFaceName[0] = '\0';
lf.lfCharSet = ANSI_CHARSET;

// To enumerate all styles of Arial font that cover the ANSI charset 
hr = StringCchCopy( (LPSTR)lf.lfFaceName, LF_FACESIZE, "Arial" );
if (FAILED(hr))
{
// TODO: write error handler 
}

lf.lfCharSet = ANSI_CHARSET;

 

Note, based on the values of lfCharSet and lfFaceNameEnumFontFamiliesEx will enumerate the same font as many times
as there are distinct character sets in the font. This can create an extensive list of fonts which can be burdensome to a user.
For example, the Century Schoolbook font can appear for the Baltic, Western, Greek, Turkish, and Cyrillic character sets.
To avoid this, an application should filter the list of fonts.

The fonts for many East Asian languages have two typeface names: an English name and a localized name. 
EnumFontsEnumFontFamilies, and EnumFontFamiliesEx return the English typeface name if the system locale does not match the language of the font.

When the graphics mode on the device context is set to GM_ADVANCED using the SetGraphicsMode function and
the DEVICE_FONTTYPE flag is passed to the FontType parameter, this function returns a list of type 1 and OpenType fonts on the system.
When the graphics mode is not set to GM_ADVANCED, this function returns a list of type 1, OpenType, and TrueType fonts on the system.

EnumFontFamExProc callback function

The EnumFontFamExProc function is an application defined callback function used with the EnumFontFamiliesEx function.
It is used to process the fonts. It is called once for each enumerated font.
The FONTENUMPROC type defines a pointer to this callback function. 
EnumFontFamExProc is a placeholder for the application defined function name.

int CALLBACK EnumFontFamExProc(
  const LOGFONT *lpelfe,
  const TEXTMETRIC *lpntme,
  DWORD FontType,
  LPARAM lParam
);

 

Parameters

lpelfe

A pointer to an LOGFONT structure that contains information about the logical attributes of the font.
To obtain additional information about the font, you can cast the result as an ENUMLOGFONTEX or ENUMLOGFONTEXDV structure.

lpntme

A pointer to a structure that contains information about the physical attributes of a font.
The function uses the NEWTEXTMETRICEX structure for TrueType fonts; and the TEXTMETRIC structure for other fonts.

This can be an ENUMTEXTMETRIC structure.

FontType

The type of the font. This parameter can be a combination of these values:

  { EnumFonts Masks }
  {$EXTERNALSYM RASTER_FONTTYPE}
  RASTER_FONTTYPE = 1;
  {$EXTERNALSYM DEVICE_FONTTYPE}
  DEVICE_FONTTYPE = 2;
  {$EXTERNALSYM TRUETYPE_FONTTYPE}
  TRUETYPE_FONTTYPE = 4;

 

RASTER_FONTTYPE TRUETYPE_FONTTYPE

如果RASTER_FONTTYPE位被设置,则该字体是一种光栅字体
如果TRUETYPE_FONTTYPE位被设置,该字体是一种TrueType字体
如果上述两位都未被设置,则该字体是一种向量字体

DEVICE_FONTTYPE
  The font is a device-based font. If this value is not set, the font is a GDI-based font.
当一种设备(如激光打印机)支持下载TrueType字体或该字体是一种驻留设备的字体,则DEVICE_FONTTYPE位被设置 1
当设备是一种显示设备、点阵打印机或其他光栅设备,则该位为0。

应用程序也可用DEVICE_FONTTYPE来区别图形设备接口(GDI)提供的光栅字体和设备提供的字体。
GDI可以为GDI提供的光栅字体模拟粗体、斜体、下划线和删除线(strikeout)属性,但却不支持设备提供的字体。
lParam

The application-defined data passed by the EnumFontFamiliesEx function.

Return value

The return value must be a nonzero value to continue enumeration; to stop enumeration, the return value must be zero.

Remarks

An application must register this callback function by passing its address to the EnumFontFamiliesEx function.

When the graphics mode on the device context is set to GM_ADVANCED using theSetGraphicsMode function and
the DEVICE_FONTTYPE flag is passed to the FontType parameter, this function returns a list of type 1 and OpenType fonts on the system.
When the graphics mode is not set to GM_ADVANCED, this function returns a list of type 1, OpenType, and TrueType fonts on the system.

Unlike the EnumFontFamProc callback function, EnumFontFamExProc receives extended information about a font.
The ENUMLOGFONTEX structure includes the localized name of the script (character set) and
the NEWTEXTMETRICEX structure includes a font-coverage signature.

 

The NEWTEXTMETRICEX structure contains information about a physical font.

typedef struct tagNEWTEXTMETRICEX {
  NEWTEXTMETRIC ntmTm; // A NEWTEXTMETRIC structure.
  FONTSIGNATURE ntmFontSig; // A FONTSIGNATURE structure indicating the coverage of the font.
} NEWTEXTMETRICEX;

A FONTSIGNATURE structure indicating the coverage of the font.

typedef struct tagFONTSIGNATURE {
  DWORD fsUsb[4];
  DWORD fsCsb[2];
} FONTSIGNATURE, *PFONTSIGNATURE;

Members

fsUsb

A 128-bit Unicode subset bitfield (USB) identifying up to 126 Unicode subranges.
Each bit, except the two most significant bits, represents a single subrange.
The most significant bit is always 1 and identifies the bitfield as a font signature;
the second most significant bit is reserved and must be 0.
Unicode subranges are numbered in accordance with the ISO 10646 standard.
For more information, see Unicode Subset Bitfields.

fsCsb

A 64-bit, code-page bitfield (CPB) that identifies a specific character set or code page.
Code pages are in the lower 32 bits of this bitfield.
The high 32 are used for non-Windows code pages.
For more information, see Code Page Bitfields.

Remarks

GDI relies on Windows code pages fitting within a 32-bit value.
Furthermore, the highest 2 bits within this value are reserved for GDI internal use and may not be assigned to code pages.

Code Page Bitfields

Note  All locales do not support code pages. The bitfields described in this topic do not apply to Unicode locales.
To determine supported scripts for a locale, your application can use the locale identifier constant LOCALE_SSCRIPTS with GetLocaleInfoEx.

Note  The presence of a bit in a code page bitfield does not necessarily mean that all strings for a locale
can be encoded in that code page without loss. To preserve data without loss, using Unicode UTF-8 or UTF-16 is recommended.

BitCode pageDescription
ANSI  
01252Latin 1
11250Latin 2: Central Europe
21251Cyrillic
31253Greek
41254Turkish
51255Hebrew
61256Arabic
71257Baltic
81258Vietnamese
9 - 15 Reserved for ANSI
ANSI and OEM  
16874Thai
17932Japanese, Shift-JIS
18936Simplified Chinese (PRC, Singapore)
19949Korean Unified Hangul Code (Hangul TongHabHyung Code)
20950Traditional Chinese (Taiwan; Hong Kong SAR, PRC)
211361Korean (Johab)
22 - 29 Reserved for alternate ANSI and OEM
30 - 31 Reserved by system.
OEM  
32 - 46 Reserved for OEM
471258Vietnamese
48869Modern Greek
49866Russian
50865Nordic
51864Arabic
52863Canadian French
53862 
54861Icelandic
55860Portuguese
56857Turkish
57855Cyrillic; primarily Russian
58852Latin 2
59775Baltic
60737Greek; formerly 437G
61708; 720Arabic; ASMO 708
62850Multilingual Latin 1
63437US

 

ANSI code pages can be different on different computers, or can be changed for a single computer, leading to data corruption. For the most consistent results, applications should use Unicode, such as UTF-8 or UTF-16, instead of a specific code page.

Identifier.NET NameAdditional information
037IBM037IBM EBCDIC US-Canada
437IBM437OEM United States
500IBM500IBM EBCDIC International
708ASMO-708Arabic (ASMO 708)
709 Arabic (ASMO-449+, BCON V4)
710 Arabic - Transparent Arabic
720DOS-720Arabic (Transparent ASMO); Arabic (DOS)
737ibm737OEM Greek (formerly 437G); Greek (DOS)
775ibm775OEM Baltic; Baltic (DOS)
850ibm850OEM Multilingual Latin 1; Western European (DOS)
852ibm852OEM Latin 2; Central European (DOS)
855IBM855OEM Cyrillic (primarily Russian)
857ibm857OEM Turkish; Turkish (DOS)
858IBM00858OEM Multilingual Latin 1 + Euro symbol
860IBM860OEM Portuguese; Portuguese (DOS)
861ibm861OEM Icelandic; Icelandic (DOS)
862DOS-862OEM Hebrew; Hebrew (DOS)
863IBM863OEM French Canadian; French Canadian (DOS)
864IBM864OEM Arabic; Arabic (864)
865IBM865OEM Nordic; Nordic (DOS)
866cp866OEM Russian; Cyrillic (DOS)
869ibm869OEM Modern Greek; Greek, Modern (DOS)
870IBM870IBM EBCDIC Multilingual/ROECE (Latin 2); IBM EBCDIC Multilingual Latin 2
874windows-874ANSI/OEM Thai (same as 28605, ISO 8859-15); Thai (Windows)
875cp875IBM EBCDIC Greek Modern
932shift_jisANSI/OEM Japanese; Japanese (Shift-JIS)
936gb2312ANSI/OEM Simplified Chinese (PRC, Singapore); Chinese Simplified (GB2312)
949ks_c_5601-1987ANSI/OEM Korean (Unified Hangul Code)
950big5ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC); Chinese Traditional (Big5)
1026IBM1026IBM EBCDIC Turkish (Latin 5)
1047IBM01047IBM EBCDIC Latin 1/Open System
1140IBM01140IBM EBCDIC US-Canada (037 + Euro symbol); IBM EBCDIC (US-Canada-Euro)
1141IBM01141IBM EBCDIC Germany (20273 + Euro symbol); IBM EBCDIC (Germany-Euro)
1142IBM01142IBM EBCDIC Denmark-Norway (20277 + Euro symbol); IBM EBCDIC (Denmark-Norway-Euro)
1143IBM01143IBM EBCDIC Finland-Sweden (20278 + Euro symbol); IBM EBCDIC (Finland-Sweden-Euro)
1144IBM01144IBM EBCDIC Italy (20280 + Euro symbol); IBM EBCDIC (Italy-Euro)
1145IBM01145IBM EBCDIC Latin America-Spain (20284 + Euro symbol); IBM EBCDIC (Spain-Euro)
1146IBM01146IBM EBCDIC United Kingdom (20285 + Euro symbol); IBM EBCDIC (UK-Euro)
1147IBM01147IBM EBCDIC France (20297 + Euro symbol); IBM EBCDIC (France-Euro)
1148IBM01148IBM EBCDIC International (500 + Euro symbol); IBM EBCDIC (International-Euro)
1149IBM01149IBM EBCDIC Icelandic (20871 + Euro symbol); IBM EBCDIC (Icelandic-Euro)
1200utf-16Unicode UTF-16, little endian byte order (BMP of ISO 10646); available only to managed applications
1201unicodeFFFEUnicode UTF-16, big endian byte order; available only to managed applications
1250windows-1250ANSI Central European; Central European (Windows)
1251windows-1251ANSI Cyrillic; Cyrillic (Windows)
1252windows-1252ANSI Latin 1; Western European (Windows)
1253windows-1253ANSI Greek; Greek (Windows)
1254windows-1254ANSI Turkish; Turkish (Windows)
1255windows-1255ANSI Hebrew; Hebrew (Windows)
1256windows-1256ANSI Arabic; Arabic (Windows)
1257windows-1257ANSI Baltic; Baltic (Windows)
1258windows-1258ANSI/OEM Vietnamese; Vietnamese (Windows)
1361JohabKorean (Johab)
10000macintoshMAC Roman; Western European (Mac)
10001x-mac-japaneseJapanese (Mac)
10002x-mac-chinesetradMAC Traditional Chinese (Big5); Chinese Traditional (Mac)
10003x-mac-koreanKorean (Mac)
10004x-mac-arabicArabic (Mac)
10005x-mac-hebrewHebrew (Mac)
10006x-mac-greekGreek (Mac)
10007x-mac-cyrillicCyrillic (Mac)
10008x-mac-chinesesimpMAC Simplified Chinese (GB 2312); Chinese Simplified (Mac)
10010x-mac-romanianRomanian (Mac)
10017x-mac-ukrainianUkrainian (Mac)
10021x-mac-thaiThai (Mac)
10029x-mac-ceMAC Latin 2; Central European (Mac)
10079x-mac-icelandicIcelandic (Mac)
10081x-mac-turkishTurkish (Mac)
10082x-mac-croatianCroatian (Mac)
12000utf-32Unicode UTF-32, little endian byte order; available only to managed applications
12001utf-32BEUnicode UTF-32, big endian byte order; available only to managed applications
20000x-Chinese_CNSCNS Taiwan; Chinese Traditional (CNS)
20001x-cp20001TCA Taiwan
20002x_Chinese-EtenEten Taiwan; Chinese Traditional (Eten)
20003x-cp20003IBM5550 Taiwan
20004x-cp20004TeleText Taiwan
20005x-cp20005Wang Taiwan
20105x-IA5IA5 (IRV International Alphabet No. 5, 7-bit); Western European (IA5)
20106x-IA5-GermanIA5 German (7-bit)
20107x-IA5-SwedishIA5 Swedish (7-bit)
20108x-IA5-NorwegianIA5 Norwegian (7-bit)
20127us-asciiUS-ASCII (7-bit)
20261x-cp20261T.61
20269x-cp20269ISO 6937 Non-Spacing Accent
20273IBM273IBM EBCDIC Germany
20277IBM277IBM EBCDIC Denmark-Norway
20278IBM278IBM EBCDIC Finland-Sweden
20280IBM280IBM EBCDIC Italy
20284IBM284IBM EBCDIC Latin America-Spain
20285IBM285IBM EBCDIC United Kingdom
20290IBM290IBM EBCDIC Japanese Katakana Extended
20297IBM297IBM EBCDIC France
20420IBM420IBM EBCDIC Arabic
20423IBM423IBM EBCDIC Greek
20424IBM424IBM EBCDIC Hebrew
20833x-EBCDIC-KoreanExtendedIBM EBCDIC Korean Extended
20838IBM-ThaiIBM EBCDIC Thai
20866koi8-rRussian (KOI8-R); Cyrillic (KOI8-R)
20871IBM871IBM EBCDIC Icelandic
20880IBM880IBM EBCDIC Cyrillic Russian
20905IBM905IBM EBCDIC Turkish
20924IBM00924IBM EBCDIC Latin 1/Open System (1047 + Euro symbol)
20932EUC-JPJapanese (JIS 0208-1990 and 0121-1990)
20936x-cp20936Simplified Chinese (GB2312); Chinese Simplified (GB2312-80)
20949x-cp20949Korean Wansung
21025cp1025IBM EBCDIC Cyrillic Serbian-Bulgarian
21027 (deprecated)
21866koi8-uUkrainian (KOI8-U); Cyrillic (KOI8-U)
28591iso-8859-1ISO 8859-1 Latin 1; Western European (ISO)
28592iso-8859-2ISO 8859-2 Central European; Central European (ISO)
28593iso-8859-3ISO 8859-3 Latin 3
28594iso-8859-4ISO 8859-4 Baltic
28595iso-8859-5ISO 8859-5 Cyrillic
28596iso-8859-6ISO 8859-6 Arabic
28597iso-8859-7ISO 8859-7 Greek
28598iso-8859-8ISO 8859-8 Hebrew; Hebrew (ISO-Visual)
28599iso-8859-9ISO 8859-9 Turkish
28603iso-8859-13ISO 8859-13 Estonian
28605iso-8859-15ISO 8859-15 Latin 9
29001x-EuropaEuropa 3
38598iso-8859-8-iISO 8859-8 Hebrew; Hebrew (ISO-Logical)
50220iso-2022-jpISO 2022 Japanese with no halfwidth Katakana; Japanese (JIS)
50221csISO2022JPISO 2022 Japanese with halfwidth Katakana; Japanese (JIS-Allow 1 byte Kana)
50222iso-2022-jpISO 2022 Japanese JIS X 0201-1989; Japanese (JIS-Allow 1 byte Kana - SO/SI)
50225iso-2022-krISO 2022 Korean
50227x-cp50227ISO 2022 Simplified Chinese; Chinese Simplified (ISO 2022)
50229 ISO 2022 Traditional Chinese
50930 EBCDIC Japanese (Katakana) Extended
50931 EBCDIC US-Canada and Japanese
50933 EBCDIC Korean Extended and Korean
50935 EBCDIC Simplified Chinese Extended and Simplified Chinese
50936 EBCDIC Simplified Chinese
50937 EBCDIC US-Canada and Traditional Chinese
50939 EBCDIC Japanese (Latin) Extended and Japanese
51932euc-jpEUC Japanese
51936EUC-CNEUC Simplified Chinese; Chinese Simplified (EUC)
51949euc-krEUC Korean
51950 EUC Traditional Chinese
52936hz-gb-2312HZ-GB2312 Simplified Chinese; Chinese Simplified (HZ)
54936GB18030Windows XP and later: GB18030 Simplified Chinese (4 byte); Chinese Simplified (GB18030)
57002x-iscii-deISCII Devanagari
57003x-iscii-beISCII Bengali
57004x-iscii-taISCII Tamil
57005x-iscii-teISCII Telugu
57006x-iscii-asISCII Assamese
57007x-iscii-orISCII Oriya
57008x-iscii-kaISCII Kannada
57009x-iscii-maISCII Malayalam
57010x-iscii-guISCII Gujarati
57011x-iscii-paISCII Punjabi
65000utf-7Unicode (UTF-7)
65001utf-8Unicode (UTF-8)

Unicode Subset Bitfields

Bit   Unicode subrange   Description
00000 - 007FBasic Latin
10080 - 00FFLatin-1 Supplement
20100 - 017FLatin Extended-A
30180 - 024FLatin Extended-B
40250 - 02AFIPA Extensions
1D00 - 1D7FPhonetic Extensions
1D80 - 1DBFPhonetic Extensions Supplement
502B0 - 02FFSpacing Modifier Letters
A700 - A71FModifier Tone Letters
60300 - 036FCombining Diacritical Marks
1DC0 - 1DFFCombining Diacritical Marks Supplement
70370 - 03FFGreek and Coptic
82C80 - 2CFFCoptic
90400 - 04FFCyrillic
0500 - 052FCyrillic Supplement
2DE0 - 2DFFCyrillic Extended-A
A640 - A69FCyrillic Extended-B
100530 - 058FArmenian
110590 - 05FFHebrew
12A500 - A63FVai
130600 - 06FFArabic
0750 - 077FArabic Supplement
1407C0 - 07FFNKo
150900 - 097FDevanagari
160980 - 09FFBengali
170A00 - 0A7FGurmukhi
180A80 - 0AFFGujarati
190B00 - 0B7FOriya
200B80 - 0BFFTamil
210C00 - 0C7FTelugu
220C80 - 0CFFKannada
230D00 - 0D7FMalayalam
240E00 - 0E7FThai
250E80 - 0EFFLao
2610A0 - 10FFGeorgian
2D00 - 2D2FGeorgian Supplement
271B00 - 1B7FBalinese
281100 - 11FFHangul Jamo
291E00 - 1EFFLatin Extended Additional
2C60 - 2C7FLatin Extended-C
A720 - A7FFLatin Extended-D
301F00 - 1FFFGreek Extended
312000 - 206FGeneral Punctuation
2E00 - 2E7FSupplemental Punctuation
322070 - 209FSuperscripts And Subscripts
3320A0 - 20CFCurrency Symbols
3420D0 - 20FFCombining Diacritical Marks For Symbols
352100 - 214FLetterlike Symbols
362150 - 218FNumber Forms
372190 - 21FFArrows
27F0 - 27FFSupplemental Arrows-A
2900 - 297FSupplemental Arrows-B
2B00 - 2BFFMiscellaneous Symbols and Arrows
382200 - 22FFMathematical Operators
27C0 - 27EFMiscellaneous Mathematical Symbols-A
2980 - 29FFMiscellaneous Mathematical Symbols-B
2A00 - 2AFFSupplemental Mathematical Operators
392300 - 23FFMiscellaneous Technical
402400 - 243FControl Pictures
412440 - 245FOptical Character Recognition
422460 - 24FFEnclosed Alphanumerics
432500 - 257FBox Drawing
442580 - 259FBlock Elements
4525A0 - 25FFGeometric Shapes
462600 - 26FFMiscellaneous Symbols
472700 - 27BFDingbats
483000 - 303FCJK Symbols And Punctuation
493040 - 309FHiragana
5030A0 - 30FFKatakana
31F0 - 31FFKatakana Phonetic Extensions
513100 - 312FBopomofo
31A0 - 31BFBopomofo Extended
523130 - 318FHangul Compatibility Jamo
53A840 - A87FPhags-pa
543200 - 32FFEnclosed CJK Letters And Months
553300 - 33FFCJK Compatibility
56AC00 - D7AFHangul Syllables
57D800 - DFFFNon-Plane 0.
Note that setting this bit implies that there is at least one supplementary code point
beyond the Basic Multilingual Plane (BMP)
that is supported by this font. See Surrogates and Supplementary Characters.
5810900 - 1091FPhoenician
592E80 - 2EFFCJK Radicals Supplement
2F00 - 2FDFKangxi Radicals
2FF0 - 2FFFIdeographic Description Characters
3190 - 319FKanbun
3400 - 4DBFCJK Unified Ideographs Extension A
4E00 - 9FFFCJK Unified Ideographs
20000 - 2A6DFCJK Unified Ideographs Extension B
60E000 - F8FFPrivate Use Area
6131C0 - 31EFCJK Strokes
F900 - FAFFCJK Compatibility Ideographs
2F800 - 2FA1FCJK Compatibility Ideographs Supplement
62FB00 - FB4FAlphabetic Presentation Forms
63FB50 - FDFFArabic Presentation Forms-A
64FE20 - FE2FCombining Half Marks
65FE10 - FE1FVertical Forms
FE30 - FE4FCJK Compatibility Forms
66FE50 - FE6FSmall Form Variants
67FE70 - FEFFArabic Presentation Forms-B
68FF00 - FFEFHalfwidth And Fullwidth Forms
69FFF0 - FFFFSpecials
700F00 - 0FFFTibetan
710700 - 074FSyriac
720780 - 07BFThaana
730D80 - 0DFFSinhala
741000 - 109FMyanmar
751200 - 137FEthiopic
1380 - 139FEthiopic Supplement
2D80 - 2DDFEthiopic Extended
7613A0 - 13FFCherokee
771400 - 167FUnified Canadian Aboriginal Syllabics
781680 - 169FOgham
7916A0 - 16FFRunic
801780 - 17FFKhmer
19E0 - 19FFKhmer Symbols
811800 - 18AFMongolian
822800 - 28FFBraille Patterns
83A000 - A48FYi Syllables
A490 - A4CFYi Radicals
841700 - 171FTagalog
1720 - 173FHanunoo
1740 - 175FBuhid
1760 - 177FTagbanwa
8510300 - 1032FOld Italic
8610330 - 1034FGothic
8710400 - 1044FDeseret
881D000 - 1D0FFByzantine Musical Symbols
1D100 - 1D1FFMusical Symbols
1D200 - 1D24FAncient Greek Musical Notation
891D400 - 1D7FFMathematical Alphanumeric Symbols
90FF000 - FFFFDPrivate Use (plane 15)
100000 - 10FFFDPrivate Use (plane 16)
91FE00 - FE0FVariation Selectors
E0100 - E01EFVariation Selectors Supplement
92E0000 - E007FTags
931900 - 194FLimbu
941950 - 197FTai Le
951980 - 19DFNew Tai Lue
961A00 - 1A1FBuginese
972C00 - 2C5FGlagolitic
982D30 - 2D7FTifinagh
994DC0 - 4DFFYijing Hexagram Symbols
100A800 - A82FSyloti Nagri
10110000 - 1007FLinear B Syllabary
10080 - 100FFLinear B Ideograms
10100 - 1013FAegean Numbers
10210140 - 1018FAncient Greek Numbers
10310380 - 1039FUgaritic
104103A0 - 103DFOld Persian
10510450 - 1047FShavian
10610480 - 104AFOsmanya
10710800 - 1083FCypriot Syllabary
10810A00 - 10A5FKharoshthi
1091D300 - 1D35FTai Xuan Jing Symbols
11012000 - 123FFCuneiform
12400 - 1247FCuneiform Numbers and Punctuation
1111D360 - 1D37FCounting Rod Numerals
1121B80 - 1BBFSundanese
1131C00 - 1C4FLepcha
1141C50 - 1C7FOl Chiki
115A880 - A8DFSaurashtra
116A900 - A92FKayah Li
117A930 - A95FRejang
118AA00 - AA5FCham
11910190 - 101CFAncient Symbols
120101D0 - 101FFPhaistos Disc
12110280 - 1029FLycian
102A0 - 102DFCarian
10920 - 1093FLydian
1221F000 - 1F02FMahjong Tiles
1F030 - 1F09FDomino Tiles
123 Windows 2000 and later: Layout progress, horizontal from right to left
124 Windows 2000 and later: Layout progress, vertical before horizontal
125 Windows 2000 and later: Layout progress, vertical bottom to top
126-127 Reserved for process-internal usage

The NEWTEXTMETRIC structure contains data that describes a physical font.

typedef struct tagNEWTEXTMETRIC {
  LONG  tmHeight;
  LONG  tmAscent;
  LONG  tmDescent;
  LONG  tmInternalLeading;
  LONG  tmExternalLeading;
  LONG  tmAveCharWidth;
  LONG  tmMaxCharWidth;
  LONG  tmWeight;
  LONG  tmOverhang;
  LONG  tmDigitizedAspectX;
  LONG  tmDigitizedAspectY;
  TCHAR tmFirstChar;
  TCHAR tmLastChar;
  TCHAR tmDefaultChar;
  TCHAR tmBreakChar;
  BYTE  tmItalic;
  BYTE  tmUnderlined;
  BYTE  tmStruckOut;
  BYTE  tmPitchAndFamily;
  BYTE  tmCharSet;
  DWORD ntmFlags;
  UINT  ntmSizeEM;
  UINT  ntmCellHeight;
  UINT  ntmAvgWidth;
} NEWTEXTMETRIC, *PNEWTEXTMETRIC;

 

Members

tmHeight

The height (ascent + descent) of characters.

tmAscent

The ascent (units above the base line) of characters.

tmDescent

The descent (units below the base line) of characters.

tmInternalLeading

The amount of leading (space) inside the bounds set by the tmHeight member.
Accent marks and other diacritical characters may occur in this area.
The designer may set this member to zero.

tmExternalLeading

The amount of extra leading (space) that the application adds between rows.
Since this area is outside the font, it contains no marks and
is not altered by text output calls in either OPAQUE or TRANSPARENT mode.
The designer may set this member to zero.

tmAveCharWidth

The average width of characters in the font (generally defined as the width of the letter x).
This value does not include overhang required for bold or italic characters.

tmMaxCharWidth

The width of the widest character in the font.

tmWeight

The weight of the font.

tmOverhang

The extra width per string that may be added to some synthesized fonts.
When synthesizing some attributes, such as bold or italic, graphics device interface (GDI) or
a device may have to add width to a string on both a per-character and per-string basis.
For example, GDI makes a string bold by expanding the spacing of each character and overstriking by an offset value;
it italicizes a font by shearing the string. In either case, there is an overhang past the basic string.
For bold strings, the overhang is the distance by which the overstrike is offset.
For italic strings, the overhang is the amount the top of the font is sheared past the bottom of the font.

The tmOverhang member enables the application to determine how much of the character width
returned by a GetTextExtentPoint32 function call on a single character is the actual character width
and how much is the per-string extra width. The actual width is the extent minus the overhang.

tmDigitizedAspectX

The horizontal aspect of the device for which the font was designed.

tmDigitizedAspectY

The vertical aspect of the device for which the font was designed.
The ratio of the tmDigitizedAspectX and tmDigitizedAspectY members
is the aspect ratio of the device for which the font was designed.

tmFirstChar

The value of the first character defined in the font.

tmLastChar

The value of the last character defined in the font.

tmDefaultChar

The value of the character to be substituted for characters that are not in the font.

tmBreakChar

The value of the character to be used to define word breaks for text justification.

tmItalic

An italic font if it is nonzero.

tmUnderlined

An underlined font if it is nonzero.

tmStruckOut

A strikeout font if it is nonzero.

tmPitchAndFamily

The pitch and family of the selected font.

The low-order bit (bit 0) specifies the pitch of the font.
If it is 1, the font is variable pitch (or proportional).
If it is 0, the font is fixed pitch (or monospace).

Bits 1 and 2 specify the font type.
If both bits are 0, the font is a raster font; ( 00 )
if bit 1 is 1 and bit 2 is 0, the font is a vector font; ( 01 ) 
if bit 1 is 0 and bit 2 is set, the font is some other type. ( 10 )
if both bits are 1, the font is some other type. ( 11 )

Bit 3 is 1 if the font is a device font; otherwise, it is 0.
If it is 1, the font is a device font. 
If it is 0, the font is not a device font. 

The four high-order bits designate the font family.
The tmPitchAndFamily member can be combined with the hexadecimal value 0xF0
by using the bitwise AND operator and can then be compared with the font family names
for an identical match. For more information about the font families, see LOGFONT.

  { tmPitchAndFamily flags }
  {$EXTERNALSYM TMPF_FIXED_PITCH}
  TMPF_FIXED_PITCH = 1;
  {$EXTERNALSYM TMPF_VECTOR}
  TMPF_VECTOR = 2;
  {$EXTERNALSYM TMPF_DEVICE}
  TMPF_DEVICE = 8;
  {$EXTERNALSYM TMPF_TRUETYPE}
  TMPF_TRUETYPE = 4;

 

tmCharSet

The character set of the font.

ntmFlags

Specifies whether the font is italic, underscored, outlined, bold, and so forth.
May be any reasonable combination of the following values.

BitNameMeaning
0NTM_ITALICitalic
5NTM_BOLDbold
8NTM_REGULARregular
16NTM_NONNEGATIVE_ACno glyph in a font at any size has a negative A or C space.
17NTM_PS_OPENTYPEPostScript OpenType font
18NTM_TT_OPENTYPETrueType OpenType font
19NTM_MULTIPLEMASTERmultiple master font
20NTM_TYPE1Type 1 font
21NTM_DSIGfont with a digital signature.
This allows traceability and ensures that the font has been tested and is not corrupted

 

ntmSizeEM

The size of the em square for the font.
This value is in notional units (that is, the units for which the font was designed).

ntmCellHeight

The height, in notional units, of the font. This value should be compared with the value of the ntmSizeEM member.

ntmAvgWidth

The average width of characters in the font, in notional units.
This value should be compared with the value of the ntmSizeEM member.

Remarks

The last four members of the NEWTEXTMETRIC structure are not included in the TEXTMETRIC structure;
in all other respects, the structures are identical.

The sizes in the NEWTEXTMETRIC structure are typically specified in logical units;
that is, they depend on the current mapping mode of the display context.

LOGFONT structure

The LOGFONT structure defines the attributes of a font.

typedef struct tagLOGFONT {
  LONG  lfHeight;
  LONG  lfWidth;
  LONG  lfEscapement;
  LONG  lfOrientation;
  LONG  lfWeight;
  BYTE  lfItalic;
  BYTE  lfUnderline;
  BYTE  lfStrikeOut;
  BYTE  lfCharSet;
  BYTE  lfOutPrecision;
  BYTE  lfClipPrecision;
  BYTE  lfQuality;
  BYTE  lfPitchAndFamily;
  TCHAR lfFaceName[LF_FACESIZE];
} LOGFONT, *PLOGFONT;

 

Members

lfHeight

The height, in logical units, of the font's character cell or character.
The character height value (also known as the em height) is the character cell height value minus the internal-leading value.
The font mapper interprets the value specified in lfHeight in the following manner.

ValueMeaning
> 0The font mapper transforms this value into device units and matches it against the cell height of the available fonts.
= 0The font mapper uses a default height value when it searches for a match.
< 0The font mapper transforms this value into device units and matches its absolute value against the character height of the available fonts.

 

For all height comparisons, the font mapper looks for the largest font that does not exceed the requested size.

This mapping occurs when the font is used for the first time.

For the MM_TEXT mapping mode, you can use the following formula to specify a height for a font with a specified point size:

lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);

lfWidth

The average width, in logical units, of characters in the font.
If lfWidth is zero, the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts
to find the closest match, determined by the absolute value of the difference.

lfEscapement

The angle, in tenths of degrees, between the escapement vector and the x-axis of the device.
The escapement vector is parallel to the base line of a row of text.

When the graphics mode is set to GM_ADVANCED, you can specify the escapement angle of the string
independently of the orientation angle of the string's characters.

When the graphics mode is set to GM_COMPATIBLE, lfEscapement specifies both the escapement and orientation.
You should set lfEscapement and lfOrientation to the same value.

lfOrientation

The angle, in tenths of degrees, between each character's base line and the x-axis of the device.

lfWeight

The weight of the font in the range 0 through 1000.
For example, 400 is normal and 700 is bold. If this value is zero, a default weight is used.

The following values are defined for convenience.

ValueWeight
FW_DONTCARE0
FW_THIN100
FW_EXTRALIGHT200
FW_ULTRALIGHT200
FW_LIGHT300
FW_NORMAL400
FW_REGULAR400
FW_MEDIUM500
FW_SEMIBOLD600
FW_DEMIBOLD600
FW_BOLD700
FW_EXTRABOLD800
FW_ULTRABOLD800
FW_HEAVY900
FW_BLACK900

 

lfItalic

An italic font if set to TRUE.

lfUnderline

An underlined font if set to TRUE.

lfStrikeOut

A strikeout font if set to TRUE.

lfCharSet

The character set. The following values are predefined. 

ANSI_CHARSET
BALTIC_CHARSET
CHINESEBIG5_CHARSET
DEFAULT_CHARSET
EASTEUROPE_CHARSET
GB2312_CHARSET
GREEK_CHARSET
HANGUL_CHARSET
MAC_CHARSET
OEM_CHARSET
RUSSIAN_CHARSET
SHIFTJIS_CHARSET
SYMBOL_CHARSET
TURKISH_CHARSET
VIETNAMESE_CHARSET

Korean language edition of Windows:

JOHAB_CHARSET

Middle East language edition of Windows:

ARABIC_CHARSET
HEBREW_CHARSET

Thai language edition of Windows:

THAI_CHARSET

The OEM_CHARSET value specifies a character set that is operating-system dependent.

DEFAULT_CHARSET is set to a value based on the current system locale.
For example, when the system locale is English (United States), it is set as ANSI_CHARSET.

Fonts with other character sets may exist in the operating system.
If an application uses a font with an unknown character set,
it should not attempt to translate or interpret strings that are rendered with that font.

This parameter is important in the font mapping process.
To ensure consistent results, specify a specific character set.
If you specify a typeface name in the lfFaceName member,
make sure that the lfCharSet value matches the character set of the typeface specified in lfFaceName.

lfOutPrecision

The output precision. The output precision defines how closely the output must match
the requested font's height, width, character orientation, escapement, pitch, and font type.
It can be one of the following values.

ValueMeaning
OUT_CHARACTER_PRECIS       Not used.
OUT_DEFAULT_PRECISSpecifies the default font mapper behavior.
OUT_DEVICE_PRECISInstructs the font mapper to choose a Device font when the system
contains multiple fonts with the same name.
OUT_OUTLINE_PRECISThis value instructs the font mapper to choose from TrueType and other outline-based fonts.
OUT_PS_ONLY_PRECISInstructs the font mapper to choose from only PostScript fonts.
If there are no PostScript fonts installed in the system, the font mapper returns to default behavior.
OUT_RASTER_PRECISInstructs the font mapper to choose a raster font when the system
contains multiple fonts with the same name.
OUT_STRING_PRECISThis value is not used by the font mapper, but it is returned when raster fonts are enumerated.
OUT_STROKE_PRECISThis value is not used by the font mapper, but it is returned when TrueType,
other outline-based fonts, and vector fonts are enumerated.
OUT_TT_ONLY_PRECISInstructs the font mapper to choose from only TrueType fonts.
If there are no TrueType fonts installed in the system,
the font mapper returns to default behavior.
OUT_TT_PRECISInstructs the font mapper to choose a TrueType font
when the system contains multiple fonts with the same name.

 

Applications can use the OUT_DEVICE_PRECIS, OUT_RASTER_PRECIS, OUT_TT_PRECIS, and OUT_PS_ONLY_PRECIS values
to control how the font mapper chooses a font when the operating system contains more than one font with a specified name.
For example, if an operating system contains a font named Symbol in raster and TrueType form,
specifying OUT_TT_PRECIS forces the font mapper to choose the TrueType version.
Specifying OUT_TT_ONLY_PRECIS forces the font mapper to choose a TrueType font,
even if it must substitute a TrueType font of another name.

lfClipPrecision

The clipping precision.
The clipping precision defines how to clip characters that are partially outside the clipping region.
It can be one or more of the following values.

For more information about the orientation of coordinate systems, see the description of the nOrientation parameter.

ValueMeaning
CLIP_CHARACTER_PRECIS     Not used.
CLIP_DEFAULT_PRECISSpecifies default clipping behavior.
CLIP_DFA_DISABLEWindows XP SP1: Turns off font association for the font. Note that this flag is not guaranteed to have any effect on any platform after Windows Server 2003.
CLIP_EMBEDDEDYou must specify this flag to use an embedded read-only font.
CLIP_LH_ANGLESWhen this value is used, the rotation for all fonts depends on whether the orientation of the coordinate system is left-handed or right-handed.

If not used, device fonts always rotate counterclockwise, but the rotation of other fonts is dependent on the orientation of the coordinate system.

CLIP_MASKNot used.
CLIP_DFA_OVERRIDETurns off font association for the font. This is identical to CLIP_DFA_DISABLE, but it can have problems in some situations; the recommended flag to use is CLIP_DFA_DISABLE.
CLIP_STROKE_PRECISNot used by the font mapper, but is returned when raster, vector, or TrueType fonts are enumerated.

For compatibility, this value is always returned when enumerating fonts.

CLIP_TT_ALWAYSNot used.

 

lfQuality

The output quality.
The output quality defines how carefully the graphics device interface (GDI) must attempt
to match the logical-font attributes to those of an actual physical font.
It can be one of the following values.

ValueMeaning
ANTIALIASED_QUALITYFont is always antialiased if the font supports it and the size of the font is not too small or too large.
CLEARTYPE_QUALITYIf set, text is rendered (when possible) using ClearType antialiasing method. See Remarks for more information.
DEFAULT_QUALITYAppearance of the font does not matter.
DRAFT_QUALITYAppearance of the font is less important than when PROOF_QUALITY is used. For GDI raster fonts,
scaling is enabled, which means that more font sizes are available, but the quality may be lower.
Bold, italic, underline, and strikeout fonts are synthesized if necessary.
NONANTIALIASED_QUALITYFont is never antialiased.
PROOF_QUALITYCharacter quality of the font is more important than exact matching of the logical-font attributes.
For GDI raster fonts, scaling is disabled and the font closest in size is chosen.
Although the chosen font size may not be mapped exactly when PROOF_QUALITY is used,
the quality of the font is high and there is no distortion of appearance.
Bold, italic, underline, and strikeout fonts are synthesized if necessary.

 

If neither ANTIALIASED_QUALITY nor NONANTIALIASED_QUALITY is selected,
the font is antialiased only if the user chooses smooth screen fonts in Control Panel.

lfPitchAndFamily

The pitch and family of the font.
The two low-order bits specify the pitch of the font and can be one of the following values.

  • DEFAULT_PITCH
  • FIXED_PITCH
  • VARIABLE_PITCH
  {$EXTERNALSYM DEFAULT_PITCH}
  DEFAULT_PITCH = 0;
  {$EXTERNALSYM FIXED_PITCH}
  FIXED_PITCH = 1;
  {$EXTERNALSYM VARIABLE_PITCH}
  VARIABLE_PITCH = 2;
  {$EXTERNALSYM MONO_FONT}
  MONO_FONT = 8;

 

Bits 4 through 7 of the member specify the font family and can be one of the following values.

  • FF_DECORATIVE
  • FF_DONTCARE
  • FF_MODERN
  • FF_ROMAN
  • FF_SCRIPT
  • FF_SWISS

The proper value can be obtained by using the Boolean OR operator to join one pitch constant with one family constant.

Font families describe the look of a font in a general way.
They are intended for specifying fonts when the exact typeface desired is not available.
The values for font families are as follows.

ValueMeaning
FF_DECORATIVENovelty fonts. Old English is an example.
FF_DONTCAREUse default font.
FF_MODERNFonts with constant stroke width (monospace), with or without serifs.
Monospace fonts are usually modern. Pica, Elite, and CourierNew are examples.
FF_ROMANFonts with variable stroke width (proportional) and with serifs. MS Serif is an example.
FF_SCRIPTFonts designed to look like handwriting. Script and Cursive are examples.
FF_SWISSFonts with variable stroke width (proportional) and without serifs. MS Sans Serif is an example.

 

lfFaceName

A null-terminated string that specifies the typeface name of the font.
The length of this string must not exceed 32 TCHAR values, including the terminating NULL.
The EnumFontFamiliesEx function can be used to enumerate the typeface names of all currently available fonts.
If lfFaceName is an empty string, GDI uses the first font that matches the other specified attributes.

Remarks

The following situations do not support ClearType antialiasing:

  • Text is rendered on a printer.
  • Display set for 256 colors or less.
  • Text is rendered to a terminal server client.
  • The font is not a TrueType font or an OpenType font with TrueType outlines.
    For example, the following do not support ClearType antialiasing:

    Type 1 fonts,
    Postscript OpenType fonts without TrueType outlines,
    bitmap fonts,
    vector fonts, and
    device fonts.
  • The font has tuned embedded bitmaps, for any font sizes that contain the embedded bitmaps.
    For example, this occurs commonly in East Asian fonts.

信息: 完成枚举系统字体

http://support.microsoft.com/kb/99672/zh-cn

完整枚举系统字体是一个两阶段的过程。作为家族名称以枚举系统中的所有字体的字体名称,应用程序应首先调用 EnumFontfamilies 用 NULL。
然后,应用程序应采用每个字体名称,并调用 EnumFontFamilies 再次以获取样式名称 (对于 TrueType 字体) 或 (对于光栅字体) 的受支持的磅值。
光栅和向量字体不支持样式的名称。由于 TrueType 和矢量字体是可连续缩放,不会枚举字体的磅值。

下面的步骤详细说明了枚举:

    1. 若要列出每个可用的字体系列中的一种字体系列名称 (lpszFamily) 中调用 EnumFontFamilies 用 NULL。

    2. EnumFontFamProc 回调函数中,查看 nFontType 参数。

    3. 如果 nFontType 设置了 TRUETYPE_FONTTYPE 标志,然后调用 EnumFontFamilies 系列名称将设置为字体的类型名 ( ENUMLOGFONT结构的 lfFaceName)。
      对于每个样式名称调用一次回调函数。此枚举是所关注的应用程序中查找具有特定样式名称 (如"大纲") TrueType 字体的情况下非常有用。
      TrueType 字体可以不断扩展,因为它不需要枚举给定的字体的磅值。应用程序可以使用任何所需的点大小。
      如果应用程序列出枚举的 TrueType 字体,它可以只是在给定范围中选择一些具有代表性的磅值。
      所建议的"Windows 界面: 应用程序设计指南"(第 159,部分 8.4.1.4 页) 的点大小是
      8、 9、 10、 11、 12、 14、 16、 18、 20、 22、 24、 26、 28、 36、 48 和 72。
      使应用程序可确定该字体将出现相同的显示和打印机上显示和打印机),提供了所有 TrueType 字体。

    4. 如果 nFontType 设置了 RASTER_FONTTYPE 标志,然后调用 EnumFontFamilies 系列名称将设置为字体的类型名。为每个可用的字号大小调用一次回调函数。光栅字体的可用磅值的倍数仅在可调整。缩放的光栅字体通常是由于不吸引用户,应用程序可以选择将自己限制到可用的大小。因为 Microsoft Windows 版本 3.1 未定义为光栅字体的样式名,没有必要进行枚举的样式名称。

      如果 nFontType 也有设置了 DEVICE_FONTTYPE 标志,则当前的字体是光栅字体到打印机使用的打印机驱动程序可用。
      打印机可能这些字体,在硬件中也能够下载它们在必要的时候。使用这种字体的应用程序应该知道相似的光栅字体可能不可用,在显示设备上。
      反过来也是如此。

      如果未设置 DEVICE_FONTTYPE 标志,应用程序应注意一个相似的字体可能不是打印机上可用。
      为设备字体列出字体生成的字体软件包 (例如 Adobe 类型管理器 (ATM)。

    5. 如果 nFontType TRUETYPE_FONTTYPE 和 RASTER_FONTTYPE 标志集都没有,然后枚举的字体为矢量字体。
      矢量字体也是可连续缩放,因此没有要枚举的点大小。因为 Windows 3.1 不支持矢量字体的样式名称,但它们之间没有必要来枚举它们的样式名称。
      矢量字体通常使用的设备,如打印机不支持光栅字体。这些字体通常有一个较差的外观光栅设备上时,很多应用程序避免它们。

 

 

磅和字号的关系:  

磅    字号

5     八号

5.5   七号

6.5   小六号

7.5   六号

9     小五号

10.5  五号

12    小四号

14    四号

15    小三号

16    三号

18    小二号

22    二号

24    小一号

26    一号

36    小初号

42    初号

 

转载于:https://www.cnblogs.com/shangdawei/archive/2013/05/12/3073886.html

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值