0 out of 1 rated this helpful - Rate this topic

OUTLINETEXTMETRIC structure

Applies to: desktop apps only

The OUTLINETEXTMETRIC structure contains metrics describing a TrueType font.

Syntax

typedef struct _OUTLINETEXTMETRIC {
  UINT       otmSize;
  TEXTMETRIC otmTextMetrics;
  BYTE       otmFiller;
  PANOSE     otmPanoseNumber;
  UINT       otmfsSelection;
  UINT       otmfsType;
  int        otmsCharSlopeRise;
  int        otmsCharSlopeRun;
  int        otmItalicAngle;
  UINT       otmEMSquare;
  int        otmAscent;
  int        otmDescent;
  UINT       otmLineGap;
  UINT       otmsCapEmHeight;
  UINT       otmsXHeight;
  RECT       otmrcFontBox;
  int        otmMacAscent;
  int        otmMacDescent;
  UINT       otmMacLineGap;
  UINT       otmusMinimumPPEM;
  POINT      otmptSubscriptSize;
  POINT      otmptSubscriptOffset;
  POINT      otmptSuperscriptSize;
  POINT      otmptSuperscriptOffset;
  UINT       otmsStrikeoutSize;
  int        otmsStrikeoutPosition;
  int        otmsUnderscoreSize;
  int        otmsUnderscorePosition;
  PSTR       otmpFamilyName;
  PSTR       otmpFaceName;
  PSTR       otmpStyleName;
  PSTR       otmpFullName;
} OUTLINETEXTMETRIC, *POUTLINETEXTMETRIC;

Members

otmSize

The size, in bytes, of the OUTLINETEXTMETRIC structure.

otmTextMetrics

A TEXTMETRIC structure containing further information about the font.

otmFiller

A value that causes the structure to be byte-aligned.

otmPanoseNumber

The PANOSE number for this font.

otmfsSelection

The nature of the font pattern. This member can be a combination of the following bits.

BitMeaning
0Italic
1Underscore
2Negative
3Outline
4Strikeout
5Bold

 

otmfsType

Indicates whether the font is licensed. Licensed fonts must not be modified or exchanged. If bit 1 is set, the font may not be embedded in a document. If bit 1 is clear, the font can be embedded. If bit 2 is set, the embedding is read-only.

otmsCharSlopeRise

The slope of the cursor. This value is 1 if the slope is vertical. Applications can use this value and the value of the otmsCharSlopeRun member to create an italic cursor that has the same slope as the main italic angle (specified by the otmItalicAngle member).

otmsCharSlopeRun

The slope of the cursor. This value is zero if the slope is vertical. Applications can use this value and the value of the otmsCharSlopeRise member to create an italic cursor that has the same slope as the main italic angle (specified by the otmItalicAngle member).

otmItalicAngle

The main italic angle of the font, in tenths of a degree counterclockwise from vertical. Regular (roman) fonts have a value of zero. Italic fonts typically have a negative italic angle (that is, they lean to the right).

otmEMSquare

The number of logical units defining the x- or y-dimension of the em square for this font. (The number of units in the x- and y-directions are always the same for an em square.)

otmAscent

The maximum distance characters in this font extend above the base line. This is the typographic ascent for the font.

otmDescent

The maximum distance characters in this font extend below the base line. This is the typographic descent for the font.

otmLineGap

The typographic line spacing.

otmsCapEmHeight

Not supported.

otmsXHeight

Not supported.

otmrcFontBox

The bounding box for the font.

otmMacAscent

The maximum distance characters in this font extend above the base line for the Macintosh computer.

otmMacDescent

The maximum distance characters in this font extend below the base line for the Macintosh computer.

otmMacLineGap

The line-spacing information for the Macintosh computer.

otmusMinimumPPEM

The smallest recommended size for this font, in pixels per em-square.

otmptSubscriptSize

The recommended horizontal and vertical size for subscripts in this font.

otmptSubscriptOffset

The recommended horizontal and vertical offset for subscripts in this font. The subscript offset is measured from the character origin to the origin of the subscript character.

otmptSuperscriptSize

The recommended horizontal and vertical size for superscripts in this font.

otmptSuperscriptOffset

The recommended horizontal and vertical offset for superscripts in this font. The superscript offset is measured from the character base line to the base line of the superscript character.

otmsStrikeoutSize

The width of the strikeout stroke for this font. Typically, this is the width of the em dash for the font.

otmsStrikeoutPosition

The position of the strikeout stroke relative to the base line for this font. Positive values are above the base line and negative values are below.

otmsUnderscoreSize

The thickness of the underscore character for this font.

otmsUnderscorePosition

The position of the underscore character for this font.

otmpFamilyName

The offset from the beginning of the structure to a string specifying the family name for the font.

otmpFaceName

The offset from the beginning of the structure to a string specifying the typeface name for the font. (This typeface name corresponds to the name specified in the LOGFONT structure.)

otmpStyleName

The offset from the beginning of the structure to a string specifying the style name for the font.

otmpFullName

The offset from the beginning of the structure to a string specifying the full name for the font. This name is unique for the font and often contains a version number or other identifying information.

Remarks

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

Note, OUTLINETEXTMETRIC is defined using the current pack setting. To avoid problems, make sure that the application is built using the platform default packing. For example, 32-bit Windows uses a default of 8-byte packing. For more information, see the MSDN topic "C-Compiler Packing Issues".

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Wingdi.h (include Windows.h)

Unicode and ANSI names

OUTLINETEXTMETRICW (Unicode) and OUTLINETEXTMETRICA (ANSI)

See also

Fonts and Text Overview
Font and Text Structures
GetOutlineTextMetrics
LOGFONT
TEXTMETRIC

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Update: Structure Improperly Defined
Ok,
Having been convinced that this is an alignment or packing issue, I decided to dig deeper.
I also wrote some additional test code to verify the results.
I explicitly set these fields to 0 prior to calling GetOutlineTextMetrics.
After the call, the structure members have various different values on different runs.

I found some text by Feng Yuan that describes the issue rather well:

"The second field of OUTLINETEXTMETRIC is a TEXTMETRIC structure, which is 4n + 1 bytes in size. The original designer of the data structure added a single-byte filler (otmFiller) to make sure the PANOSE structure following it would be on the WORD boundary. Note that this structure was first designed in the Windows 3.1 Win16 API, when TrueType fonts were first introduced to Windows. It seems that when Microsoft's GDI source code is compiled, structure member alignment is set at 4 bytes. The embedded TEXTMETRIC structure is now padded to be a multiple of DWORDs (the largest of its members), which adds three bytes before the otmFiller field. Now otmFiler is on the DWORD boundary; the PANOSE structure follows without any padding, because all its members are BYTEs. But the PANOSE structure is 10 bytes long, and the next DWORD size otmfsSelection field needs to start a DWORD boundary, so two extra bytes are added."

I have to say, it was more fun when we were using otmMysteryBytes and otmMysteryByte  ;)
Structure Improperly Defined
The incorrect definition in the document causes improper offsets.
This corrected version uses the names "otmMysteryBytes" and "otmMysteryByte", as they are non-zero values when filled.
Filler bytes would normally remain zero.
Also, it is worth noting that the otmSize value need not be filled prior to calling the function as with the "cbSize" member of many structures.

typedef struct _OUTLINETEXTMETRIC {
  UINT       otmSize;
  TEXTMETRIC otmTextMetrics;
  BYTE       otmMysteryBytes[4];
  PANOSE     otmPanoseNumber;
  BYTE       otmMysteryByte;
  UINT       otmfsSelection;
  UINT       otmfsType;
  int        otmsCharSlopeRise;
  int        otmsCharSlopeRun;
  int        otmItalicAngle;
  UINT       otmEMSquare;
  int        otmAscent;
  int        otmDescent;
  UINT       otmLineGap;
  UINT       otmsCapEmHeight;
  UINT       otmsXHeight;
  RECT       otmrcFontBox;
  int        otmMacAscent;
  int        otmMacDescent;
  UINT       otmMacLineGap;
  UINT       otmusMinimumPPEM;
  POINT      otmptSubscriptSize;
  POINT      otmptSubscriptOffset;
  POINT      otmptSuperscriptSize;
  POINT      otmptSuperscriptOffset;
  UINT       otmsStrikeoutSize;
  int        otmsStrikeoutPosition;
  int        otmsUnderscoreSize;
  int        otmsUnderscorePosition;
  PSTR       otmpFamilyName;
  PSTR       otmpFaceName;
  PSTR       otmpStyleName;
  PSTR       otmpFullName;
} OUTLINETEXTMETRIC, *POUTLINETEXTMETRIC;

---------------------------------

ANSI, lfHeight = 11
---------------------------------

00000103                                                                                           - otmSize dword

0000000D 0000000B 00000002 00000002 00000000 00000005 00000015 00000190 00000000 00000060 00000060 - TEXTMETRIC dwords (11)
1E FF 1F 20                                                                                        - TEXTMETRIC ANSI tchars (4)
00 00 00 27 00                                                                                     - TEXTMETRIC bytes (5)

00 00 00 68                                                                                        - mystery bytes (4)
02 0B 06 04 03 05 04 04 02 04                                                                      - PANOSE bytes (10)
00                                                                                                 - mystery byte (1)

00000040                                                                                           - otmfsSelection dword
00000008 00000001 00000000 00000000 00000800 00000008 FFFFFFFE 00000000 00000006 00000003          - misc dwords (30)
FFFFFFF9 0000000B 0000000F FFFFFFFE 0000000B FFFFFFFE 00000000 00000009 00000008 00000007
00000000 00000002 00000008 00000007 00000000 00000005 00000001 00000004 00000001 FFFFFFFF

000000D4 000000DB 000000E2 000000EA                                                                - string offsets (4)

54 61 68 6F 6D 61 00                                                                               - ANSI sz strings (4)
54 61 68 6F 6D 61 00
52 65 67 75 6C 61 72 00
4D 69 63 72 6F 73 6F 66 74 20 54 61 68 6F 6D 61 20 52 65 67 75 6C 61 72 00

---------------------------------
ANSI, lfHeight = 22
---------------------------------

00000103                                                                                           - otmSize dword

0000001B 00000016 00000005 00000005 00000000 0000000A 0000002B 00000190 00000000 00000060 00000060 - TEXTMETRIC dwords (11)
1E FF 1F 20                                                                                        - TEXTMETRIC ANSI tchars (4)
00 00 00 27 00                                                                                     - TEXTMETRIC bytes (5)

4A 14 00 68                                                                                        - mystery bytes (4)
02 0B 06 04 03 05 04 04 02 04                                                                      - PANOSE bytes (10)
02                                                                                                 - mystery byte (1)

00000040                                                                                           - otmfsSelection dword
00000008 00000001 00000000 00000000 00000800 00000011 FFFFFFFB 00000001 0000000B 00000006          - misc dwords (30)
FFFFFFF3 00000017 0000001D FFFFFFFB 00000016 FFFFFFFB 00000000 00000009 0000000F 0000000E
00000000 00000003 0000000F 0000000E 00000000 0000000A 00000001 00000007 00000001 FFFFFFFE

000000D4 000000DB 000000E2 000000EA                                                                - string offsets (4)

54 61 68 6F 6D 61 00                                                                               - ANSI sz strings (4)
54 61 68 6F 6D 61 00
52 65 67 75 6C 61 72 00
4D 69 63 72 6F 73 6F 66 74 20 54 61 68 6F 6D 61 20 52 65 67 75 6C 61 72 00

---------------------------------
UNICODE, lfHeight = 11
---------------------------------

00000136                                                                                           - otmSize dword

0000000D 0000000B 00000002 00000002 00000000 00000005 00000015 00000190 00000000 00000060 00000060 - TEXTMETRIC dwords (11)
0020 FFFC 001F 0020                                                                                - TEXTMETRIC UNICODE tchars (4)
00 00 00 27 00                                                                                     - TEXTMETRIC bytes (5)

00 00 00 68                                                                                        - mystery bytes (4)
02 0B 06 04 03 05 04 04 02 04                                                                      - PANOSE bytes (10)
00                                                                                                 - mystery byte (1)

00000040                                                                                           - otmfsSelection dword
00000008 00000001 00000000 00000000 00000800 00000008 FFFFFFFE 00000000 00000006 00000003          - misc dwords (30)
FFFFFFF9 0000000B 0000000F FFFFFFFE 0000000B FFFFFFFE 00000000 00000009 00000008 00000007
00000000 00000002 00000008 00000007 00000000 00000005 00000001 00000004 00000001 FFFFFFFF

000000D8 000000E6 000000F4 00000104                                                                - string offsets (4)

54 00 61 00 68 00 6F 00 6D 00 61 00 00 00                                                          - UNICODE sz strings (4)
54 00 61 00 68 00 6F 00 6D 00 61 00 00 00
52 00 65 00 67 00 75 00 6C 00 61 00 72 00 00 00
4D 00 69 00 63 00 72 00 6F 00 73 00 6F 00 66 00 74 00 20 00 54 00 61 00 68 00 6F 00 6D 00 61 00 20 00 52 00 65 00 67 00 75 00 6C 00 61 00 72 00 00 00

---------------------------------
UNICODE, lfHeight = 22
---------------------------------

00000136                                                                                           - otmSize dword

0000001B 00000016 00000005 00000005 00000000 0000000A 0000002B 00000190 00000000 00000060 00000060 - TEXTMETRIC dwords (11)
0020 FFFC 001F 0020                                                                                - TEXTMETRIC UNICODE tchars (4)
00 00 00 27 00                                                                                     - TEXTMETRIC bytes (5)

00 00 00 68                                                                                        - mystery bytes (4)
02 0B 06 04 03 05 04 04 02 04                                                                      - PANOSE bytes (10)
00                                                                                                 - mystery byte (1)

00000040                                                                                           - otmfsSelection dword
00000008 00000001 00000000 00000000 00000800 00000011 FFFFFFFB 00000001 0000000B 00000006          - misc dwords (30)
FFFFFFF3 00000017 0000001D FFFFFFFB 00000016 FFFFFFFB 00000000 00000009 0000000F 0000000E
00000000 00000003 0000000F 0000000E 00000000 0000000A 00000001 00000007 00000001 FFFFFFFE

000000D8 000000E6 000000F4 00000104                                                                - string offsets (4)

54 00 61 00 68 00 6F 00 6D 00 61 00 00 00                                                          - UNICODE sz strings (4)
54 00 61 00 68 00 6F 00 6D 00 61 00 00 00
52 00 65 00 67 00 75 00 6C 00 61 00 72 00 00 00
4D 00 69 00 63 00 72 00 6F 00 73 00 6F 00 66 00 74 00 20 00 54 00 61 00 68 00 6F 00 6D 00 61 00 20 00 52 00 65 00 67 00 75 00 6C 00 61 00 72 00 00 00

---------------------------------
Dave Sheldon - DednDave
no constants defined for otmfsSelection and otmfsType

there are no official constants defined for the otmfsSelection and otmfsType fields, i have the following constants defined for these fields:

// bits of otmfsSelection in OUTLINETEXTMETRIC structure
#define OLM_SELECTION_ITALIC 0x00000001
#define OLM_SELECTION_UNDERSCORE 0x00000002
#define OLM_SELECTION_NEGATIVE 0x00000004
#define OLM_SELECTION_OUTLINE 0x00000008
#define OLM_SELECTION_STRIKEOUT 0x00000010
#define OLM_SELECTION_BOLD 0x00000020
#define OLM_SELECTION_REGULAR      0x00000040

// bits of otmfsType in OUTLINETEXTMETRIC structure
#define OLM_LICTYPE_NOEMBEDDING 0x00000001
#define OLM_LICTYPE_EMBEDREADONLY 0x00000002



watch out for paddingbytes

there is an extra paddingbyte between otmPanoseNumber and otmfsSelection.

sizeof(OUTLINETEXTMETRICW) should be 216 bytes

this goes wrong if you set the packing of your project to something else then 4 bytes

reason is a bug in the WinGDI.h where the "pshpack4.h" for OUTLINETEXTMETRICA/OUTLINETEXTMETRICW is only included if _MAC is defined. This while on other places the "pshpack4.h" is included without the check for _MAC. Solution is to remove the #ifdef _MAC

(btw also TEXTMETRICSW has 3 padding bytes, but this is always correct becasuse pshpack4 is included)

the sdk used is Microsoft Platform SDK 2009-08 Windows7

missing bit 6 definition for otmfsSelection
bit 6 = regular