using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;
using Vanara.Extensions;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Gdi32
{
/// Mask for GetFontLanguageInfo results.
public const ushort FLI_MASK = 0x103B;
/// Font weight value.
public const int FW_BOLD = 700;
/// Font weight value.
public const int FW_DONTCARE = 0;
/// Font weight value.
public const int FW_EXTRABOLD = 800;
/// Font weight value.
public const int FW_EXTRALIGHT = 200;
/// Font weight value.
public const int FW_HEAVY = 900;
/// Font weight value.
public const int FW_LIGHT = 300;
/// Font weight value.
public const int FW_MEDIUM = 500;
/// Font weight value.
public const int FW_NORMAL = 400;
/// Font weight value.
public const int FW_SEMIBOLD = 600;
/// Font weight value.
public const int FW_THIN = 100;
/// Error value for some functions.
public const uint GCP_ERROR = 0x8000;
/// Value for .lpGlyph field.
public const ushort GCPGLYPH_LINKAFTER = 0x4000;
/// Value for .lpGlyph field.
public const ushort GCPGLYPH_LINKBEFORE = 0x8000;
/// Represents a generic GDI error.
public const uint GDI_ERROR = 0xFFFFFFFF;
/// This function enables or disables support for end-user-defined characters (EUDC).
/// Boolean that is set to TRUE to enable EUDC, and to FALSE to disable EUDC.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
/// If EUDC is disabled, trying to display EUDC characters will result in missing or bad glyphs.
/// During multi-session, this function affects the current session only.
/// It is recommended that you use this function with Windows XP SP2 or later.
///
// https://docs.microsoft.com/en-us/windows/win32/gdi/enableeudc
// BOOL EnableEUDC( _In_ HDC BOOL fEnableEUDC );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("", MSDNShortId = "9e531d8c-6008-4189-ae25-cda707be5e2c")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnableEUDC([MarshalAs(UnmanagedType.Bool)] bool fEnableEUDC);
///
/// 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.
///
///
/// 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.
///
///
///
/// 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.
///
///
/// The type of the font. This parameter can be a combination of these values:
/// DEVICE_FONTTYPE
/// RASTER_FONTTYPE
/// TRUETYPE_FONTTYPE
///
/// The application-defined data passed by the EnumFontFamiliesEx function.
///
/// The return value must be a nonzero value to continue enumeration; to stop enumeration, the return value must be zero.
///
///
/// 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 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.
///
///
/// 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.
///
///
// https://docs.microsoft.com/en-us/previous-versions/dd162618(v=vs.85) int CALLBACK EnumFontFamExProc( const LOGFONT *lpelfe, const
// TEXTMETRIC *lpntme, DWORD FontType, LPARAM lParam );
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
[PInvokeData("Wingdi.h")]
public delegate int EnumFontFamExProc(in ENUMLOGFONTEXDV lpelfe, in ENUMTEXTMETRIC lpntme, FontType FontType, IntPtr lParam);
///
///
/// The EnumFontFamProc function is an application defined callback function used with the EnumFontFamilies function.
/// It receives data describing the available fonts. The FONTENUMPROC type defines a pointer to this callback function.
/// EnumFontFamProc is a placeholder for the application definedfunction name.
///
///
/// Note This function is provided only for compatibility with 16-bit versions of Windows. Applications should call the
/// EnumFontFamiliesEx function.
///
///
///
/// [in]
///
/// A pointer to an ENUMLOGFONT structure that contains information about the logical attributes of the font. This structure
/// is locally defined.
///
/// This can be an ENUMLOGFONTEXDV structure.
///
///
/// [in]
///
/// A pointer to a NEWTEXTMETRIC structure that contains information about the physical attributes of the font, if the font is
/// a TrueType font. If the font is not a TrueType font, this parameter is a pointer to a TEXTMETRIC structure.
///
/// This can be an ENUMTEXTMETRIC structure.
///
///
/// [in]
/// The type of the font. This parameter can be a combination of the following values:
/// DEVICE_FONTTYPE
/// RASTER_FONTTYPE
/// TRUETYPE_FONTTYPE
///
///
/// [in]
/// A pointer to the application-defined data passed by the EnumFontFamilies function.
///
/// The return value must be a nonzero value to continue enumeration; to stop enumeration, it must return zero.
///
/// An application must register this callback function by passing its address to the EnumFontFamilies function.
///
/// 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 AND (&) operator can be used with the RASTER_FONTTYPE, DEVICE_FONTTYPE, and TRUETYPE_FONTTYPE constants to determine the
/// font type. 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. DEVICE_FONTTYPE is set when a device (for example, a laser
/// printer) supports downloading TrueType fonts or when the font is a device-resident font; it is zero if the device is a display
/// adapter, dot-matrix printer, or other raster device. An application can also use DEVICE_FONTTYPE to distinguish graphics device
/// interface (GDI)-supplied raster fonts from device-supplied fonts. GDI can simulate bold, italic, underline, and strikeout
/// attributes for GDI-supplied raster fonts, but not for device-supplied fonts.
///
///
// https://docs.microsoft.com/en-us/previous-versions/dd162621%28v%3dvs.85%29 int CALLBACK EnumFontFamProc( _In_ ENUMLOGFONT *lpelf,
// _In_ NEWTEXTMETRIC *lpntm, _In_ DWORD FontType, _In_ LPARAM lParam );
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("Wingdi.h")]
public delegate int EnumFontFamProc(in ENUMLOGFONT lpelf, in NEWTEXTMETRIC lpntm, uint FontType, IntPtr lParam);
///
///
/// The EnumFontsProc function is an application definedcallback function that processes font data from the EnumFonts
/// function. The FONTENUMPROC type defines a pointer to this callback function. EnumFontsProc is a placeholder for the
/// application definedfunction name.
///
///
/// Note This function is provided only for compatibility with 16-bit versions of Windows. Applications should call the
/// EnumFontFamiliesEx function.
///
///
///
/// [in]
/// A pointer to a LOGFONT structure that contains information about the logical attributes of the font.
/// This can be an ENUMLOGFONTEXDV structure.
///
///
/// [in]
/// A pointer to a TEXTMETRIC structure that contains information about the physical attributes of the font.
/// This can be an ENUMTEXTMETRIC structure.
///
///
/// [in]
/// The type of the font. This parameter can be a combination of the following values:
/// DEVICE_FONTTYPE
/// RASTER_FONTTYPE
/// TRUETYPE_FONTTYPE
///
///
/// [in]
/// A pointer to the application-defined data passed by EnumFonts.
///
/// The return value must be a nonzero value to continue enumeration; to stop enumeration, it must be zero.
///
///
/// 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.
///
///
/// If the device is capable of text transformations (scaling, italicizing, and so on) only the base font is enumerated. The user
/// must inquire into the device's text-transformation abilities to determine which additional fonts are available directly from the device.
///
/// An application must register the EnumFontsProc function by passing its address to the EnumFonts function.
///
// https://docs.microsoft.com/en-us/previous-versions/dd162623(v=vs.85) int CALLBACK EnumFontsProc( _In_ const LOGFONT *lplf, _In_
// const TEXTMETRIC *lptm, _In_ DWORD dwType, _In_ LPARAM lpData );
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("Wingdi.h")]
public delegate int EnumFontsProc(in LOGFONT lplf, in TEXTMETRIC lptm, uint dwType, IntPtr lpData);
/// The character set (4-bytes).
[PInvokeData("Wingdi.h", MSDNShortId = "dd145037")]
public enum CharacterSetUint : uint
{
/// Specifies the English character set.
ANSI_CHARSET = 0,
///
/// Specifies a character set based on the current system locale; for example, when the system locale is United States English,
/// the default character set is ANSI_CHARSET.
///
DEFAULT_CHARSET = 1,
/// Specifies a character set of symbols.
SYMBOL_CHARSET = 2,
/// Specifies the Japanese character set.
SHIFTJIS_CHARSET = 128,
/// Specifies the Hangul Korean character set.
HANGEUL_CHARSET = 129,
/// Also spelled "Hangeul". Specifies the Hangul Korean character set.
HANGUL_CHARSET = 129,
/// Specifies the "simplified" Chinese character set for People's Republic of China.
GB2312_CHARSET = 134,
///
/// Specifies the "traditional" Chinese character set, used mostly in Taiwan and in the Hong Kong and Macao Special
/// Administrative Regions.
///
CHINESEBIG5_CHARSET = 136,
/// Specifies a mapping to one of the OEM code pages, according to the current system locale setting.
OEM_CHARSET = 255,
/// Also spelled "Johap". Specifies the Johab Korean character set.
JOHAB_CHARSET = 130,
/// Specifies the Hebrew character set.
HEBREW_CHARSET = 177,
/// Specifies the Arabic character set.
ARABIC_CHARSET = 178,
/// Specifies the Greek character set.
GREEK_CHARSET = 161,
/// Specifies the Turkish character set.
TURKISH_CHARSET = 162,
/// Specifies the Vietnamese character set.
VIETNAMESE_CHARSET = 163,
/// Specifies the Thai character set.
THAI_CHARSET = 222,
/// Specifies a Eastern European character set.
EASTEUROPE_CHARSET = 238,
/// Specifies the Russian Cyrillic character set.
RUSSIAN_CHARSET = 204,
/// Specifies the Apple Macintosh character set.
MAC_CHARSET = 77,
/// Specifies the Baltic (Northeastern European) character set.
BALTIC_CHARSET = 186
}
/// The clipping precision defines how to clip characters that are partially outside the clipping region.
[PInvokeData("Wingdi.h", MSDNShortId = "dd145037")]
public enum ClippingPrecision : byte
{
/// Not used.
CLIP_CHARACTER_PRECIS = 1,
/// Specifies default clipping behavior.
CLIP_DEFAULT_PRECIS = 0,
///
/// Windows 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_DFA_DISABLE = 4 << 4,
///
/// Turns 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_DFA_OVERRIDE = 64,
/// You must specify this flag to use an embedded read-only font.
CLIP_EMBEDDED = 8 << 4,
///
/// When 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_LH_ANGLES = 1 << 4,
/// Not used.
CLIP_MASK = 0xf,
///
/// Not 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_STROKE_PRECIS = 2,
/// Not used.
CLIP_TT_ALWAYS = 2 << 4,
}
/// Options for .
[PInvokeData("wingdi.h", MSDNShortId = "74f8fcb8-8ad4-47f2-a330-fa56713bdb37")]
[Flags]
public enum ETO
{
/// The current background color should be used to fill the rectangle.
ETO_OPAQUE = 0x0002,
/// The text will be clipped to the rectangle.
ETO_CLIPPED = 0x0004,
///
/// The lpString array refers to an array returned from GetCharacterPlacement and should be parsed directly by GDI as no further
/// language-specific processing is required. Glyph indexing only applies to TrueType fonts, but the flag can be used for bitmap
/// and vector fonts to indicate that no further language processing is necessary and GDI should process the string directly.
/// Note that all glyph indexes are 16-bit values even though the string is assumed to be an array of 8-bit values for raster
/// fonts. For ExtTextOutW, the glyph indexes are saved to a metafile. However, to display the correct characters the metafile
/// must be played back using the same font. For ExtTextOutA, the glyph indexes are not saved.
///
ETO_GLYPH_INDEX = 0x0010,
///
/// Middle East language edition of Windows: If this value is specified and a Hebrew or Arabic font is selected into the device
/// context, the string is output using right-to-left reading order. If this value is not specified, the string is output in
/// left-to-right order. The same effect can be achieved by setting the TA_RTLREADING value in SetTextAlign. This value is
/// preserved for backward compatibility.
///
ETO_RTLREADING = 0x0080,
/// To display numbers, use digits appropriate to the locale.
ETO_NUMERICSLOCAL = 0x0400,
/// To display numbers, use European digits.
ETO_NUMERICSLATIN = 0x0800,
///
/// Reserved for system use. If an application sets this flag, it loses international scripting support and in some cases it may
/// display no text at all.
///
ETO_IGNORELANGUAGE = 0x1000,
///
/// When this is set, the array pointed to by lpDx contains pairs of values. The first value of each pair is, as usual, the
/// distance between origins of adjacent character cells, but the second value is the displacement along the vertical direction
/// of the font.
///
ETO_PDY = 0x2000,
/// Reserved and SHOULD NOT be used.
ETO_REVERSE_INDEX_MAP = 0x10000,
}
/// Font type.
[PInvokeData("Wingdi.h")]
public enum FontType
{
///
DEVICE_FONTTYPE,
///
RASTER_FONTTYPE,
///
TRUETYPE_FONTTYPE
}
/// Flags for .
[PInvokeData("wingdi.h", MSDNShortId = "eaf8ebf0-1b06-4a09-a842-83540245a117")]
[Flags]
public enum FR
{
///
/// Specifies that only the process that called the AddFontResourceEx function can use this font. When the font name matches a
/// public font, the private font will be chosen. When the process terminates, the system will remove all fonts installed by the
/// process with the AddFontResourceEx function.
///
FR_PRIVATE = 0x10,
///
/// Specifies that no process, including the process that called the AddFontResourceEx function, can enumerate this font.
///
FR_NOT_ENUM = 0x20,
}
/// Flags for and .
[PInvokeData("wingdi.h", MSDNShortId = "80d3f4b3-503b-4abb-826c-e5c09972ba2f")]
[Flags]
public enum GCP : uint
{
///
/// 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.
///
FLI_GLYPHS = 0x00040000,
///
/// Specifies that the lpClass array contains preset classifications for characters. The classifications may be the same as on
/// output. If the particular classification for a character is not known, the corresponding location in the array must be set to
/// zero. for more information about the classifications, see GCP_RESULTS. This is useful only if GetFontLanguageInfo returned
/// the GCP_REORDER flag.
///
GCP_CLASSIN = 0x00080000,
/// The character set is DBCS.
GCP_DBCS = 0x0001,
///
/// Determines how diacritics in the string are handled. If this value is not set, diacritics are treated as zero-width
/// characters. For example, a Hebrew string may contain diacritics, but you may not want to display them. Use
/// GetFontLanguageInfo to determine whether a font supports diacritics. If it does, you can use or not use the GCP_DIACRITIC
/// flag in the call to GetCharacterPlacement, depending on the needs of your application.
///
GCP_DIACRITIC = 0x0100,
///
/// For languages that need reordering or different glyph shapes depending on the positions of the characters within a word,
/// nondisplayable characters often appear in the code page. For example, in the Hebrew code page, there are Left-To-Right and
/// Right-To-Left markers, to help determine the final positioning of characters within the output strings. Normally these are
/// not displayed and are removed from the lpGlyphs and lpDx arrays. You can use the GCP_DISPLAYZWG flag to display these characters.
///
GCP_DISPLAYZWG = 0x00400000,
///
/// Specifies that some or all characters in the string are to be displayed using shapes other than the standard shapes defined
/// in the currently selected font for the current code page. Some languages, such as Arabic, cannot support glyph creation
/// unless this value is specified. As a general rule, if GetFontLanguageInfo returns this value for a string, this value must be
/// used with GetCharacterPlacement.
///
GCP_GLYPHSHAPE = 0x0010,
///
/// Adjusts the extents in the lpDx array so that the string length is the same as nMaxExtent. GCP_JUSTIFY may only be used in
/// conjunction with GCP_MAXEXTENT.
///
GCP_JUSTIFY = 0x00010000,
///
GCP_JUSTIFYIN = 0x00200000,
///
/// Use Kashidas as well as, or instead of, adjusted extents to modify the length of the string so that it is equal to the value
/// specified by nMaxExtent. In the lpDx array, a Kashida is indicated by a negative justification index. GCP_KASHIDA may be used
/// only in conjunction with GCP_JUSTIFY and only if the font (and language) support Kashidas. Use GetFontLanguageInfo to
/// determine whether the current font supports Kashidas. Using Kashidas to justify the string can result in the number of glyphs
/// required being greater than the number of characters in the input string. Because of this, when Kashidas are used, the
/// application cannot assume that setting the arrays to be the size of the input string will be sufficient. (The maximum
/// possible will be approximately dxPageWidth/dxAveCharWidth, where dxPageWidth is the width of the document and dxAveCharWidth
/// is the average character width as returned from a GetTextMetrics call). Note that just because GetFontLanguageInfo returns
/// the GCP_KASHIDA flag does not mean that it has to be used in the call to GetCharacterPlacement, just that the option is available.
///
GCP_KASHIDA = 0x0400,
///
/// Use ligations wherever characters ligate. A ligation occurs where one glyph is used for two or more characters. For example,
/// the letters a and e can ligate to ?. For this to be used, however, both the language support and the font must support the
/// required glyphs (the example will not be processed by default in English). Use GetFontLanguageInfo to determine whether the
/// current font supports ligation. If it does and a specific maximum is required for the number of characters that will ligate,
/// set the number in the first element of the lpGlyphs array. If normal ligation is required, set this value to zero. If
/// GCP_LIGATE is not specified, no ligation will take place. See GCP_RESULTS for more information. If the GCP_REORDER value is
/// usually required for the character set but is not specified, the output will be meaningless unless the string being passed in
/// is already in visual ordering (that is, the result that gets put into lpGcpResults->lpOutString in one call to
/// GetCharacterPlacement is the input string of a second call). Note that just because GetFontLanguageInfo returns the
/// GCP_LIGATE flag does not mean that it has to be used in the call to GetCharacterPlacement, just that the option is available.
///
GCP_LIGATE = 0x0020,
///
/// Compute extents of the string only as long as the resulting extent, in logical units, does not exceed the values specified by
/// the nMaxExtent parameter.
///
GCP_MAXEXTENT = 0x00100000,
///
/// Certain languages only. Override the normal handling of neutrals and treat them as strong characters that match the strings
/// reading order. Useful only with the GCP_REORDER flag.
///
GCP_NEUTRALOVERRIDE = 0x02000000,
///
/// Certain languages only. Override the normal handling of numerics and treat them as strong characters that match the strings
/// reading order. Useful only with the GCP_REORDER flag.
///
GCP_NUMERICOVERRIDE = 0x01000000,
///
/// Arabic/Thai only. Use standard Latin glyphs for numbers and override the system default. To determine if this option is
/// available in the language of the font, use GetStringTypeEx to see if the language supports more than one number format.
///
GCP_NUMERICSLATIN = 0x04000000,
///
/// Arabic/Thai only. Use local glyphs for numeric characters and override the system default. To determine if this option is
/// available in the language of the font, use GetStringTypeEx to see if the language supports more than one number format.
///
GCP_NUMERICSLOCAL = 0x08000000,
///
/// Reorder the string. Use for languages that are not SBCS and left-to-right reading order. If this value is not specified, the
/// string is assumed to be in display order already. If this flag is set for Semitic languages and the lpClass array is used,
/// the first two elements of the array are used to specify the reading order beyond the bounds of the string.
/// GCP_CLASS_PREBOUNDRTL and GCP_CLASS_PREBOUNDLTR can be used to set the order. If no preset order is required, set the values
/// to zero. These values can be combined with other values if the GCPCLASSIN flag is set. If the GCP_REORDER value is not
/// specified, the lpString parameter is taken to be visual ordered for languages where this is used, and the lpOutString and
/// lpOrder fields are ignored. Use GetFontLanguageInfo to determine whether the current font supports reordering.
///
GCP_REORDER = 0x0002,
///
/// Semitic languages only. Specifies that swappable characters are not reset. For example, in a right-to-left string, the '('
/// and ')' are not reversed.
///
GCP_SYMSWAPOFF = 0x00800000,
///
/// Use kerning pairs in the font (if any) when creating the widths arrays. Use GetFontLanguageInfo to determine whether the
/// current font supports kerning pairs. Note that just because GetFontLanguageInfo returns the GCP_USEKERNING flag does not mean
/// that it has to be used in the call to GetCharacterPlacement, just that the option is available. Most TrueType fonts have a
/// kerning table, but you do not have to use it.
///
GCP_USEKERNING = 0x0008,
}
/// Values for .lpClass field.
[PInvokeData("wingdi.h", MSDNShortId = "7692637e-963a-4e0a-8a04-e05a6d01c417")]
[Flags]
public enum GCPCLASS : byte
{
/// Character from a Latin or other single-byte character set for a left-to-right language.
GCPCLASS_LATIN = 1,
/// Hebrew character.
GCPCLASS_HEBREW = 2,
/// Arabic character.
GCPCLASS_ARABIC = 2,
/// Input only. Character has no specific classification.
GCPCLASS_NEUTRAL = 3,
/// Digit from the character set associated with the current font.
GCPCLASS_LOCALNUMBER = 4,
/// Digit from a Latin or other single-byte character set for a left-to-right language.
GCPCLASS_LATINNUMBER = 5,
/// Input only. Character used to terminate Latin digits, such as a plus or minus sign.
GCPCLASS_LATINNUMERICTERMINATOR = 6,
/// Input only. Character used to separate Latin digits, such as a comma or decimal point.
GCPCLASS_LATINNUMERICSEPARATOR = 7,
/// Input only. Character used to separate digits, such as a comma or decimal point.
GCPCLASS_NUMERICSEPARATOR = 8,
/// Set lpClass[0] to GCPCLASS_PREBOUNDLTR to bind the string to left-to-right reading order before the string.
GCPCLASS_PREBOUNDLTR = 0x80,
/// Set lpClass[0] to GCPCLASS_PREBOUNDRTL to bind the string to right-to-left reading order before the string.
GCPCLASS_PREBOUNDRTL = 0x40,
/// Set lpClass[0] to GCPCLASS_POSTBOUNDLTR to bind the string to left-to-right reading order after the string.
GCPCLASS_POSTBOUNDLTR = 0x20,
/// Set lpClass[0] to GCPCLASS_POSTBOUNDRTL to bind the string to right-to-left reading order after the string.
GCPCLASS_POSTBOUNDRTL = 0x10,
}
/// Specifies how glyphs should be handled if they are not supported.
[PInvokeData("wingdi.h", MSDNShortId = "7abfee7a-dd5d-4f33-96f1-b38364ba5afd")]
[Flags]
public enum GGI
{
/// Marks unsupported glyphs with the hexadecimal value 0xffff.
GGI_MARK_NONEXISTING_GLYPHS = 1
}
/// The format of the data that retrieves.
[PInvokeData("wingdi.h", MSDNShortId = "08f06007-5b21-44ab-b234-21a58c94ed4e")]
public enum GGO
{
///
/// The function only retrieves the GLYPHMETRICS structure specified by lpgm. The lpvBuffer is ignored. This value affects the
/// meaning of the function's return value upon failure; see the Return Values section.
///
GGO_METRICS = 0,
///
/// The function retrieves the glyph bitmap. For information about memory allocation, see the following Remarks section.
///
GGO_BITMAP = 1,
/// The function retrieves the curve data points in the rasterizer's native format and uses the font's design units.
GGO_NATIVE = 2,
/// The function retrieves the curve data as a cubic Bézier spline (not in quadratic spline format).
GGO_BEZIER = 3,
/// The function retrieves a glyph bitmap that contains five levels of gray.
GGO_GRAY2_BITMAP = 4,
/// The function retrieves a glyph bitmap that contains 17 levels of gray.
GGO_GRAY4_BITMAP = 5,
/// The function retrieves a glyph bitmap that contains 65 levels of gray.
GGO_GRAY8_BITMAP = 6,
///
/// Indicates that the uChar parameter is a TrueType Glyph Index rather than a character code. See the ExtTextOut function for
/// additional remarks on Glyph Indexing.
///
GGO_GLYPH_INDEX = 0x0080,
/// The function only returns unhinted outlines. This flag only works in conjunction with GGO_BEZIER and GGO_NATIVE.
GGO_UNHINTED = 0x0100,
}
/// Flags describing the maximum size of the glyph indices.
public enum GSISize : uint
{
/// Treat glyph indices as 16-bit wide values.
GS_16BIT_INDICES = 0,
/// Treat glyph indices as 8-bit wide values.
GS_8BIT_INDICES = 1
}
///
/// 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.
///
[PInvokeData("Wingdi.h", MSDNShortId = "dd145037")]
public enum OutputPrecision : byte
{
/// Not used.
OUT_CHARACTER_PRECIS = 2,
/// Specifies the default font mapper behavior.
OUT_DEFAULT_PRECIS = 0,
/// Instructs the font mapper to choose a Device font when the system contains multiple fonts with the same name.
OUT_DEVICE_PRECIS = 5,
/// This value instructs the font mapper to choose from TrueType and other outline-based fonts.
OUT_OUTLINE_PRECIS = 8,
///
/// Instructs 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_PS_ONLY_PRECIS = 10,
/// Instructs the font mapper to choose a raster font when the system contains multiple fonts with the same name.
OUT_RASTER_PRECIS = 6,
/// A value that specifies a preference for TrueType and other outline fonts.
OUT_SCREEN_OUTLINE_PRECIS = 9,
/// This value is not used by the font mapper, but it is returned when raster fonts are enumerated.
OUT_STRING_PRECIS = 1,
///
/// This value is not used by the font mapper, but it is returned when TrueType, other outline-based fonts, and vector fonts are enumerated.
///
OUT_STROKE_PRECIS = 3,
///
/// Instructs 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_ONLY_PRECIS = 7,
/// Instructs the font mapper to choose a TrueType font when the system contains multiple fonts with the same name.
OUT_TT_PRECIS = 4,
}
///
/// 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.
///
[PInvokeData("Wingdi.h", MSDNShortId = "dd145037")]
public enum OutputQuality : byte
{
/// Appearance of the font does not matter.
DEFAULT_QUALITY = 0,
///
/// Appearance 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.
///
DRAFT_QUALITY = 1,
///
/// Character 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.
///
PROOF_QUALITY = 2,
/// Font is never antialiased.
NONANTIALIASED_QUALITY = 3,
/// Font is always antialiased if the font supports it and the size of the font is not too small or too large.
ANTIALIASED_QUALITY = 4,
///
/// If set, text is rendered (when possible) using ClearType antialiasing method. The font quality is given less importance than
/// maintaining the text size.
///
CLEARTYPE_QUALITY = 5,
///
/// If set, text is rendered (when possible) using ClearType antialiasing method. The font quality is given more importance than
/// maintaining the text size.
///
CLEARTYPE_NATURAL_QUALITY = 6
}
/// PANOSE font-classification values for a TrueType font.
[PInvokeData("wingdi.h", MSDNShortId = "18aa4a36-8e47-4e35-973f-376d412ed923")]
public enum PAN_ARMS : byte
{
/// Any
PAN_ANY = 0,
/// No Fit
PAN_NO_FIT = 1,
/// Straight Arms/Horizontal
PAN_STRAIGHT_ARMS_HORZ = 2,
/// Straight Arms/Wedge
PAN_STRAIGHT_ARMS_WEDGE = 3,
/// Straight Arms/Vertical
PAN_STRAIGHT_ARMS_VERT = 4,
/// Straight Arms/Single-Serif
PAN_STRAIGHT_ARMS_SINGLE_SERIF = 5,
/// Straight Arms/Double-Serif
PAN_STRAIGHT_ARMS_DOUBLE_SERIF = 6,
/// Non-Straight Arms/Horizontal
PAN_BENT_ARMS_HORZ = 7,
/// Non-Straight Arms/Wedge
PAN_BENT_ARMS_WEDGE = 8,
/// Non-Straight Arms/Vertical
PAN_BENT_ARMS_VERT = 9,
/// Non-Straight Arms/Single-Serif
PAN_BENT_ARMS_SINGLE_SERIF = 10,
/// Non-Straight Arms/Double-Serif
PAN_BENT_ARMS_DOUBLE_SERIF = 11,
}
/// PANOSE font-classification values for a TrueType font.
[PInvokeData("wingdi.h", MSDNShortId = "18aa4a36-8e47-4e35-973f-376d412ed923")]
public enum PAN_CONTRAST : byte
{
/// Any
PAN_ANY = 0,
/// No Fit
PAN_NO_FIT = 1,
/// None
PAN_CONTRAST_NONE = 2,
/// Very Low
PAN_CONTRAST_VERY_LOW = 3,
/// Low
PAN_CONTRAST_LOW = 4,
/// Medium Low
PAN_CONTRAST_MEDIUM_LOW = 5,
/// Medium
PAN_CONTRAST_MEDIUM = 6,
/// Mediim High
PAN_CONTRAST_MEDIUM_HIGH = 7,
/// High
PAN_CONTRAST_HIGH = 8,
/// Very High
PAN_CONTRAST_VERY_HIGH = 9,
}
/// PANOSE font-classification values for a TrueType font.
[PInvokeData("wingdi.h", MSDNShortId = "18aa4a36-8e47-4e35-973f-376d412ed923")]
public enum PAN_FAMILY : byte
{
/// Any
PAN_ANY = 0,
/// No Fit
PAN_NO_FIT = 1,
/// Text and Display
PAN_FAMILY_TEXT_DISPLAY = 2,
/// Script
PAN_FAMILY_SCRIPT = 3,
/// Decorative
PAN_FAMILY_DECORATIVE = 4,
/// Pictorial
PAN_FAMILY_PICTORIAL = 5,
}
/// PANOSE font-classification values for a TrueType font.
[PInvokeData("wingdi.h", MSDNShortId = "18aa4a36-8e47-4e35-973f-376d412ed923")]
public enum PAN_LETT : byte
{
/// Any
PAN_ANY = 0,
/// No Fit
PAN_NO_FIT = 1,
/// Normal/Contact
PAN_LETT_NORMAL_CONTACT = 2,
/// Normal/Weighted
PAN_LETT_NORMAL_WEIGHTED = 3,
/// Normal/Boxed
PAN_LETT_NORMAL_BOXED = 4,
/// Normal/Flattened
PAN_LETT_NORMAL_FLATTENED = 5,
/// Normal/Rounded
PAN_LETT_NORMAL_ROUNDED = 6,
/// Normal/Off Center
PAN_LETT_NORMAL_OFF_CENTER = 7,
/// Normal/Square
PAN_LETT_NORMAL_SQUARE = 8,
/// Oblique/Contact
PAN_LETT_OBLIQUE_CONTACT = 9,
/// Oblique/Weighted
PAN_LETT_OBLIQUE_WEIGHTED = 10,
/// Oblique/Boxed
PAN_LETT_OBLIQUE_BOXED = 11,
/// Oblique/Flattened
PAN_LETT_OBLIQUE_FLATTENED = 12,
/// Oblique/Rounded
PAN_LETT_OBLIQUE_ROUNDED = 13,
/// Oblique/Off Center
PAN_LETT_OBLIQUE_OFF_CENTER = 14,
/// Oblique/Square
PAN_LETT_OBLIQUE_SQUARE = 15,
}
/// PANOSE font-classification values for a TrueType font.
[PInvokeData("wingdi.h", MSDNShortId = "18aa4a36-8e47-4e35-973f-376d412ed923")]
public enum PAN_MIDLINE : byte
{
/// Any
PAN_ANY = 0,
/// No Fit
PAN_NO_FIT = 1,
/// Standard/Trimmed
PAN_MIDLINE_STANDARD_TRIMMED = 2,
/// Standard/Pointed
PAN_MIDLINE_STANDARD_POINTED = 3,
/// Standard/Serifed
PAN_MIDLINE_STANDARD_SERIFED = 4,
/// High/Trimmed
PAN_MIDLINE_HIGH_TRIMMED = 5,
/// High/Pointed
PAN_MIDLINE_HIGH_POINTED = 6,
/// High/Serifed
PAN_MIDLINE_HIGH_SERIFED = 7,
/// Constant/Trimmed
PAN_MIDLINE_CONSTANT_TRIMMED = 8,
/// Constant/Pointed
PAN_MIDLINE_CONSTANT_POINTED = 9,
/// Constant/Serifed
PAN_MIDLINE_CONSTANT_SERIFED = 10,
/// Low/Trimmed
PAN_MIDLINE_LOW_TRIMMED = 11,
/// Low/Pointed
PAN_MIDLINE_LOW_POINTED = 12,
/// Low/Serifed
PAN_MIDLINE_LOW_SERIFED = 13,
}
/// PANOSE font-classification values for a TrueType font.
[PInvokeData("wingdi.h", MSDNShortId = "18aa4a36-8e47-4e35-973f-376d412ed923")]
public enum PAN_PROP : byte
{
/// Any
PAN_ANY = 0,
/// No Fit
PAN_NO_FIT = 1,
/// Old Style
PAN_PROP_OLD_STYLE = 2,
/// Modern
PAN_PROP_MODERN = 3,
/// Even Width
PAN_PROP_EVEN_WIDTH = 4,
/// Expanded
PAN_PROP_EXPANDED = 5,
/// Condensed
PAN_PROP_CONDENSED = 6,
/// Very Expanded
PAN_PROP_VERY_EXPANDED = 7,
/// Very Condensed
PAN_PROP_VERY_CONDENSED = 8,
/// Monospaced
PAN_PROP_MONOSPACED = 9,
}
/// PANOSE font-classification values for a TrueType font.
[PInvokeData("wingdi.h", MSDNShortId = "18aa4a36-8e47-4e35-973f-376d412ed923")]
public enum PAN_SERIF : byte
{
/// Any
PAN_ANY = 0,
/// No Fit
PAN_NO_FIT = 1,
/// Cove
PAN_SERIF_COVE = 2,
/// Obtuse Cove
PAN_SERIF_OBTUSE_COVE = 3,
/// Square Cove
PAN_SERIF_SQUARE_COVE = 4,
/// Obtuse Square Cove
PAN_SERIF_OBTUSE_SQUARE_COVE = 5,
/// Square
PAN_SERIF_SQUARE = 6,
/// Thin
PAN_SERIF_THIN = 7,
/// Bone
PAN_SERIF_BONE = 8,
/// Exaggerated
PAN_SERIF_EXAGGERATED = 9,
/// Triangle
PAN_SERIF_TRIANGLE = 10,
/// Normal Sans
PAN_SERIF_NORMAL_SANS = 11,
/// Obtuse Sans
PAN_SERIF_OBTUSE_SANS = 12,
/// Prep Sans
PAN_SERIF_PERP_SANS = 13,
/// Flared
PAN_SERIF_FLARED = 14,
/// Rounded
PAN_SERIF_ROUNDED = 15,
}
/// PANOSE font-classification values for a TrueType font.
[PInvokeData("wingdi.h", MSDNShortId = "18aa4a36-8e47-4e35-973f-376d412ed923")]
public enum PAN_STROKE : byte
{
/// Any
PAN_ANY = 0,
/// No Fit
PAN_NO_FIT = 1,
/// Gradual/Diagonal
PAN_STROKE_GRADUAL_DIAG = 2,
/// Gradual/Transitional
PAN_STROKE_GRADUAL_TRAN = 3,
/// Gradual/Vertical
PAN_STROKE_GRADUAL_VERT = 4,
/// Gradual/Horizontal
PAN_STROKE_GRADUAL_HORZ = 5,
/// Rapid/Vertical
PAN_STROKE_RAPID_VERT = 6,
/// Rapid/Horizontal
PAN_STROKE_RAPID_HORZ = 7,
/// Instant/Vertical
PAN_STROKE_INSTANT_VERT = 8,
}
/// PANOSE font-classification values for a TrueType font.
[PInvokeData("wingdi.h", MSDNShortId = "18aa4a36-8e47-4e35-973f-376d412ed923")]
public enum PAN_WEIGHT : byte
{
/// Any
PAN_ANY = 0,
/// No Fit
PAN_NO_FIT = 1,
/// Very Light
PAN_WEIGHT_VERY_LIGHT = 2,
/// Light
PAN_WEIGHT_LIGHT = 3,
/// Thin
PAN_WEIGHT_THIN = 4,
/// Book
PAN_WEIGHT_BOOK = 5,
/// Medium
PAN_WEIGHT_MEDIUM = 6,
/// Demi
PAN_WEIGHT_DEMI = 7,
/// Bold
PAN_WEIGHT_BOLD = 8,
/// Heavy
PAN_WEIGHT_HEAVY = 9,
/// Black
PAN_WEIGHT_BLACK = 10,
/// Nord
PAN_WEIGHT_NORD = 11,
}
/// PANOSE font-classification values for a TrueType font.
[PInvokeData("wingdi.h", MSDNShortId = "18aa4a36-8e47-4e35-973f-376d412ed923")]
public enum PAN_XHEIGHT : byte
{
/// Any
PAN_ANY = 0,
/// No Fit
PAN_NO_FIT = 1,
/// Constant/Small
PAN_XHEIGHT_CONSTANT_SMALL = 2,
/// Constant/Standard
PAN_XHEIGHT_CONSTANT_STD = 3,
/// Constant/Large
PAN_XHEIGHT_CONSTANT_LARGE = 4,
/// Ducking/Small
PAN_XHEIGHT_DUCKING_SMALL = 5,
/// Ducking/Standard
PAN_XHEIGHT_DUCKING_STD = 6,
/// Ducking/Large
PAN_XHEIGHT_DUCKING_LARGE = 7,
}
/// Flags specifying pitch and family for fonts.
[PInvokeData("wingdi.h", MSDNShortId = "373bac6e-5d4d-4909-8096-2f0e909d2f1d")]
[Flags]
public enum PitchAndFamily : uint
{
/// The default pitch, which is implementation-dependent.
DEFAULT_PITCH = 0,
/// A fixed pitch, which means that all the characters in the font occupy the same width when output in a string.
FIXED_PITCH = 1,
///
/// A variable pitch, which means that the characters in the font occupy widths that are proportional to the actual widths of the
/// glyphs when output in a string. For example, the "i" and space characters usually have much smaller widths than a "W" or "O" character.
///
VARIABLE_PITCH = 2,
/// The mono font/
MONO_FONT = 8,
///
/// If this bit is set the font is a variable pitch font. If this bit is clear the font is a fixed pitch font. Note very
/// carefully that those meanings are the opposite of what the constant name implies.
///
TMPF_FIXED_PITCH = 0x01,
/// If this bit is set the font is a vector font.
TMPF_VECTOR = 0x02,
/// If this bit is set the font is a TrueType font.
TMPF_TRUETYPE = 0x04,
/// If this bit is set the font is a device font.
TMPF_DEVICE = 0x08,
/// Use default font.
FF_DONTCARE = 0 << 4,
/// Fonts with variable stroke width (proportional) and with serifs. MS Serif is an example.
FF_ROMAN = 1 << 4,
/// Fonts with variable stroke width (proportional) and without serifs. MS Sans Serif is an example.
FF_SWISS = 2 << 4,
///
/// Fonts with constant stroke width (monospace), with or without serifs. Monospace fonts are usually modern. Pica, Elite, and
/// CourierNew are examples.
///
FF_MODERN = 3 << 4,
/// Fonts designed to look like handwriting. Script and Cursive are examples.
FF_SCRIPT = 4 << 4,
/// Novelty fonts. Old English is an example.
FF_DECORATIVE = 5 << 4,
}
/// Text-alignment settings for a device context.
[PInvokeData("wingdi.h", MSDNShortId = "d3ec0350-2eb8-4843-88bb-d72cece710e7")]
[Flags]
public enum TextAlign : uint
{
/// The current position is not updated after each text output call.
TA_NOUPDATECP = 0,
/// The current position is updated after each text output call.
TA_UPDATECP = 1,
/// The reference point is on the left edge of the bounding rectangle.
TA_LEFT = 0,
/// The reference point is on the right edge of the bounding rectangle.
TA_RIGHT = 2,
/// The reference point is aligned horizontally with the center of the bounding rectangle.
TA_CENTER = 6,
/// The reference point is on the top edge of the bounding rectangle.
TA_TOP = 0,
/// The reference point is on the bottom edge of the bounding rectangle.
TA_BOTTOM = 8,
/// The reference point is on the base line of the text.
TA_BASELINE = 24,
///
/// Middle East language edition of Windows: The text is laid out in right to left reading order, as opposed to the default left
/// to right order. This only applies when the font selected into the device context is either Hebrew or Arabic.
///
TA_RTLREADING = 256,
}
/// Flags regarding TrueType status.
[PInvokeData("wingdi.h", MSDNShortId = "40bb4b59-90a4-4780-ae5f-fef8a6fa62cb")]
[Flags]
public enum TT : short
{
/// TrueType is available.
TT_AVAILABLE = 1,
/// TrueType is enabled.
TT_ENABLED = 2
}
/// The AddFontMemResourceEx function adds the font resource from a memory image to the system.
/// A pointer to a font resource.
/// The number of bytes in the font resource that is pointed to by pbFont.
/// Reserved. Must be 0.
/// A pointer to a variable that specifies the number of fonts installed.
///
/// If the function succeeds, the return value specifies the handle to the font added. This handle uniquely identifies the fonts that
/// were installed on the system. If the function fails, the return value is zero. No extended error information is available.
///
///
///
/// This function allows an application to get a font that is embedded in a document or a webpage. A font that is added by
/// AddFontMemResourceEx is always private to the process that made the call and is not enumerable.
///
///
/// A memory image can contain more than one font. When this function succeeds, pcFonts is a pointer to a DWORD whose value is
/// the number of fonts added to the system as a result of this call. For example, this number could be 2 for the vertical and
/// horizontal faces of an Asian font.
///
///
/// When the function succeeds, the caller of this function can free the memory pointed to by pbFont because the system has made its
/// own copy of the memory. To remove the fonts that were installed, call RemoveFontMemResourceEx. However, when the process goes
/// away, the system will unload the fonts even if the process did not call RemoveFontMemResource.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-addfontmemresourceex HANDLE AddFontMemResourceEx( PVOID
// pFileView, DWORD cjSize, PVOID pvResrved, DWORD *pNumFonts );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "ad5153ba-fa9d-4a07-9be3-a07b524c1539")]
public static extern HANDLE AddFontMemResourceEx(IntPtr pFileView, uint cjSize, [Optional] IntPtr pvResrved, in uint pNumFonts);
///
///
/// The AddFontResource function adds the font resource from the specified file to the system font table. The font can
/// subsequently be used for text output by any application.
///
/// To mark a font as private or not enumerable, use the AddFontResourceEx function.
///
///
///
/// A pointer to a null-terminated character string that contains a valid font file name. This parameter can specify any of the
/// following files.
///
///
///
/// File Extension
/// Meaning
///
/// -
/// .fon
/// Font resource file.
///
/// -
/// .fnt
/// Raw bitmap font file.
///
/// -
/// .ttf
/// Raw TrueType file.
///
/// -
/// .ttc
/// East Asian Windows: TrueType font collection.
///
/// -
/// .fot
/// TrueType resource file.
///
/// -
/// .otf
/// PostScript OpenType font.
///
/// -
/// .mmm
/// Multiple master Type1 font resource file. It must be used with .pfm and .pfb files.
///
/// -
/// .pfb
/// Type 1 font bits file. It is used with a .pfm file.
///
/// -
/// .pfm
/// Type 1 font metrics file. It is used with a .pfb file.
///
///
///
/// To add a font whose information comes from several resource files, have lpszFileName point to a string with the file names
/// separated by a "|" --for example, abcxxxxx.pfm | abcxxxxx.pfb.
///
///
///
/// If the function succeeds, the return value specifies the number of fonts added.
/// If the function fails, the return value is zero. No extended error information is available.
///
///
///
/// Any application that adds or removes fonts from the system font table should notify other windows of the change by sending a
/// WM_FONTCHANGE message to all top-level windows in the operating system. The application should send this message by calling the
/// SendMessage function and setting the hwnd parameter to HWND_BROADCAST.
///
///
/// When an application no longer needs a font resource that it loaded by calling the AddFontResource function, it must remove
/// that resource by calling the RemoveFontResource function.
///
///
/// This function installs the font only for the current session. When the system restarts, the font will not be present. To have the
/// font installed even after restarting the system, the font must be listed in the registry.
///
///
/// A font listed in the registry and installed to a location other than the %windir%\fonts\ folder cannot be modified, deleted, or
/// replaced as long as it is loaded in any session. In order to change one of these fonts, it must first be removed by calling
/// RemoveFontResource, removed from the font registry ( HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
/// NT\CurrentVersion\Fonts), and the system restarted. After restarting the system, the font will no longer be loaded and can be changed.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-addfontresourcea int AddFontResourceA( LPCSTR Arg1 );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "e553a25a-f281-4ddc-8e95-1f61ed8238f9")]
public static extern int AddFontResource(string Arg1);
///
/// The AddFontResourceEx function adds the font resource from the specified file to the system. Fonts added with the
/// AddFontResourceEx function can be marked as private and not enumerable.
///
///
///
/// A pointer to a null-terminated character string that contains a valid font file name. This parameter can specify any of the
/// following files.
///
///
///
/// File Extension
/// Meaning
///
/// -
/// .fon
/// Font resource file.
///
/// -
/// .fnt
/// Raw bitmap font file.
///
/// -
/// .ttf
/// Raw TrueType file.
///
/// -
/// .ttc
/// East Asian Windows: TrueType font collection.
///
/// -
/// .fot
/// TrueType resource file.
///
/// -
/// .otf
/// PostScript OpenType font.
///
/// -
/// .mmm
/// multiple master Type1 font resource file. It must be used with .pfm and .pfb files.
///
/// -
/// .pfb
/// Type 1 font bits file. It is used with a .pfm file.
///
/// -
/// .pfm
/// Type 1 font metrics file. It is used with a .pfb file.
///
///
///
/// To add a font whose information comes from several resource files, point lpszFileName to a string with the file names separated
/// by a | --for example, abcxxxxx.pfm | abcxxxxx.pfb.
///
///
///
/// The characteristics of the font to be added to the system. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// FR_PRIVATE
///
/// Specifies that only the process that called the AddFontResourceEx function can use this font. When the font name matches a public
/// font, the private font will be chosen. When the process terminates, the system will remove all fonts installed by the process
/// with the AddFontResourceEx function.
///
///
/// -
/// FR_NOT_ENUM
/// Specifies that no process, including the process that called the AddFontResourceEx function, can enumerate this font.
///
///
///
/// Reserved. Must be zero.
///
/// If the function succeeds, the return value specifies the number of fonts added.
/// If the function fails, the return value is zero. No extended error information is available.
///
///
/// This function allows a process to use fonts without allowing other processes access to the fonts.
///
/// When an application no longer needs a font resource it loaded by calling the AddFontResourceEx function, it must remove
/// the resource by calling the RemoveFontResourceEx function.
///
///
/// This function installs the font only for the current session. When the system restarts, the font will not be present. To have the
/// font installed even after restarting the system, the font must be listed in the registry.
///
///
/// A font listed in the registry and installed to a location other than the %windir%\fonts\ folder cannot be modified, deleted, or
/// replaced as long as it is loaded in any session. In order to change one of these fonts, it must first be removed by calling
/// RemoveFontResource, removed from the font registry ( HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
/// NT\CurrentVersion\Fonts), and the system restarted. After restarting the system, the font will no longer be loaded and can be changed.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-addfontresourceexa int AddFontResourceExA( LPCSTR name, DWORD
// fl, PVOID res );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "eaf8ebf0-1b06-4a09-a842-83540245a117")]
public static extern int AddFontResourceEx(string name, FR fl, IntPtr res = default);
///
/// The CreateFont function creates a logical font with the specified characteristics. The logical font can subsequently be
/// selected as the font for any device.
///
///
///
/// 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 nHeight in
/// the following manner.
///
///
///
/// Value
/// Meaning
///
/// -
/// > 0
/// The font mapper transforms this value into device units and matches it against the cell height of the available fonts.
///
/// -
/// 0
/// The font mapper uses a default height value when it searches for a match.
///
/// -
/// < 0
///
/// The 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:
///
/// nHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
///
///
/// The average width, in logical units, of characters in the requested font. If this value is zero, the font mapper chooses a
/// closest match value. The closest match value is determined by comparing the absolute values of the difference between the current
/// device's aspect ratio and the digitized aspect ratio of available fonts.
///
///
///
/// 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, nEscapement specifies both the escapement and orientation. You should set
/// nEscapement and nOrientation to the same value.
///
///
/// The angle, in tenths of degrees, between each character's base line and the x-axis of the device.
///
///
/// 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.
///
///
/// Weight
/// Value
///
/// -
/// FW_DONTCARE
/// 0
///
/// -
/// FW_THIN
/// 100
///
/// -
/// FW_EXTRALIGHT
/// 200
///
/// -
/// FW_ULTRALIGHT
/// 200
///
/// -
/// FW_LIGHT
/// 300
///
/// -
/// FW_NORMAL
/// 400
///
/// -
/// FW_REGULAR
/// 400
///
/// -
/// FW_MEDIUM
/// 500
///
/// -
/// FW_SEMIBOLD
/// 600
///
/// -
/// FW_DEMIBOLD
/// 600
///
/// -
/// FW_BOLD
/// 700
///
/// -
/// FW_EXTRABOLD
/// 800
///
/// -
/// FW_ULTRABOLD
/// 800
///
/// -
/// FW_HEAVY
/// 900
///
/// -
/// FW_BLACK
/// 900
///
///
///
/// Specifies an italic font if set to TRUE.
/// Specifies an underlined font if set to TRUE.
/// A strikeout font if set to TRUE.
///
/// 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.
///
///
/// To ensure consistent results when creating a font, do not specify OEM_CHARSET or DEFAULT_CHARSET. If you specify a typeface name
/// in the lpszFace parameter, make sure that the fdwCharSet value matches the character set of the typeface specified in lpszFace.
///
///
///
///
/// 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.
///
///
///
/// Value
/// Meaning
///
/// -
/// OUT_CHARACTER_PRECIS
/// Not used.
///
/// -
/// OUT_DEFAULT_PRECIS
/// The default font mapper behavior.
///
/// -
/// OUT_DEVICE_PRECIS
/// Instructs the font mapper to choose a Device font when the system contains multiple fonts with the same name.
///
/// -
/// OUT_OUTLINE_PRECIS
/// This value instructs the font mapper to choose from TrueType and other outline-based fonts.
///
/// -
/// OUT_PS_ONLY_PRECIS
///
/// Instructs 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_PRECIS
/// Instructs the font mapper to choose a raster font when the system contains multiple fonts with the same name.
///
/// -
/// OUT_STRING_PRECIS
/// This value is not used by the font mapper, but it is returned when raster fonts are enumerated.
///
/// -
/// OUT_STROKE_PRECIS
///
/// This 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_PRECIS
///
/// Instructs 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_PRECIS
/// Instructs 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.
///
///
///
///
/// 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.
///
///
///
/// Value
/// Meaning
///
/// -
/// CLIP_CHARACTER_PRECIS
/// Not used.
///
/// -
/// CLIP_DEFAULT_PRECIS
/// Specifies default clipping behavior.
///
/// -
/// CLIP_DFA_DISABLE
///
/// Windows 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_EMBEDDED
/// You must specify this flag to use an embedded read-only font.
///
/// -
/// CLIP_LH_ANGLES
///
/// When 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. For more information about the orientation of coordinate systems, see the description of
/// the nOrientation parameter
///
///
/// -
/// CLIP_MASK
/// Not used.
///
/// -
/// CLIP_DFA_OVERRIDE
///
/// Turns 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_PRECIS
///
/// Not 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_ALWAYS
/// Not used.
///
///
///
///
///
/// The output quality. The output quality defines how carefully GDI must attempt to match the logical-font attributes to those of an
/// actual physical font. It can be one of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// ANTIALIASED_QUALITY
/// Font is antialiased, or smoothed, if the font supports it and the size of the font is not too small or too large.
///
/// -
/// CLEARTYPE_QUALITY
/// If set, text is rendered (when possible) using ClearType antialiasing method. See Remarks for more information.
///
/// -
/// DEFAULT_QUALITY
/// Appearance of the font does not matter.
///
/// -
/// DRAFT_QUALITY
///
/// Appearance of the font is less important than when the PROOF_QUALITY value 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_QUALITY
/// Font is never antialiased, that is, font smoothing is not done.
///
/// -
/// PROOF_QUALITY
///
/// Character 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 the output quality is DEFAULT_QUALITY, DRAFT_QUALITY, or PROOF_QUALITY, then the font is antialiased if the
/// SPI_GETFONTSMOOTHING system parameter is TRUE. Users can control this system parameter from the Control Panel. (The
/// precise wording of the setting in the Control panel depends on the version of Windows, but it will be words to the effect of
/// "Smooth edges of screen fonts".)
///
///
///
///
/// 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
///
///
/// The four high-order bits specify the font family and can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// FF_DECORATIVE
/// Novelty fonts. Old English is an example.
///
/// -
/// FF_DONTCARE
/// Use default font.
///
/// -
/// FF_MODERN
/// Fonts with constant stroke width, with or without serifs. Pica, Elite, and Courier New are examples.
///
/// -
/// FF_ROMAN
/// Fonts with variable stroke width and with serifs. MS Serif is an example.
///
/// -
/// FF_SCRIPT
/// Fonts designed to look like handwriting. Script and Cursive are examples.
///
/// -
/// FF_SWISS
/// Fonts with variable stroke width and without serifs. MS?Sans Serif is an example.
///
///
///
/// An application can specify a value for the fdwPitchAndFamily parameter by using the Boolean OR operator to join a pitch constant
/// with a family constant.
///
///
/// Font families describe the look of a font in a general way. They are intended for specifying fonts when the exact typeface
/// requested is not available.
///
///
///
///
/// A pointer to a null-terminated string that specifies the typeface name of the font. The length of this string must not exceed 32
/// characters, including the terminating null character. The EnumFontFamilies function can be used to enumerate the typeface names
/// of all currently available fonts. For more information, see the Remarks.
///
/// If lpszFace is NULL or empty string, GDI uses the first font that matches the other specified attributes.
///
///
/// If the function succeeds, the return value is a handle to a logical font.
/// If the function fails, the return value is NULL.
///
///
/// When you no longer need the font, call the DeleteObject function to delete it.
///
/// To help protect the copyrights of vendors who provide fonts for Windows, applications should always report the exact name of a
/// selected font. Because available fonts can vary from system to system, do not assume that the selected font is always the same as
/// the requested font. For example, if you request a font named Palatino, but no such font is available on the system, the font
/// mapper will substitute a font that has similar attributes but a different name. Always report the name of the selected font to
/// the user.
///
///
/// To get the appropriate font on different language versions of the OS, call EnumFontFamiliesEx with the desired font
/// characteristics in the LOGFONT structure, then retrieve the appropriate typeface name and create the font using CreateFont
/// or CreateFontIndirect.
///
///
/// The font mapper for CreateFont,CreateFontIndirect, and CreateFontIndirectEx recognizes both the English and the localized
/// typeface name, regardless of locale.
///
/// The following situations do not support ClearType antialiasing:
///
/// -
/// Text rendered on a printer.
///
/// -
/// A display set for 256 colors or less.
///
/// -
/// Text 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, only for the font sizes that contain the embedded bitmaps. For example, this occurs commonly
/// in East Asian fonts.
///
///
///
/// Examples
/// For another example, see "Setting Fonts for Menu-Item Text Strings" in Using Menus.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createfonta HFONT CreateFontA( int cHeight, int cWidth, int
// cEscapement, int cOrientation, int cWeight, DWORD bItalic, DWORD bUnderline, DWORD bStrikeOut, DWORD iCharSet, DWORD
// iOutPrecision, DWORD iClipPrecision, DWORD iQuality, DWORD iPitchAndFamily, LPCSTR pszFaceName );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "373bac6e-5d4d-4909-8096-2f0e909d2f1d")]
public static extern SafeHFONT CreateFont([Optional] int cHeight, [Optional] int cWidth, [Optional] int cEscapement, [Optional] int cOrientation,
[Optional] int cWeight, [Optional, MarshalAs(UnmanagedType.Bool)] bool bItalic, [Optional, MarshalAs(UnmanagedType.Bool)] bool bUnderline,
[Optional, MarshalAs(UnmanagedType.Bool)] bool bStrikeOut, CharacterSet iCharSet = CharacterSet.DEFAULT_CHARSET,
OutputPrecision iOutPrecision = OutputPrecision.OUT_DEFAULT_PRECIS, ClippingPrecision iClipPrecision = ClippingPrecision.CLIP_DEFAULT_PRECIS,
OutputQuality iQuality = OutputQuality.DEFAULT_QUALITY, PitchAndFamily iPitchAndFamily = PitchAndFamily.FF_DONTCARE, string pszFaceName = null);
///
/// The CreateFontIndirect function creates a logical font that has the specified characteristics. The font can subsequently
/// be selected as the current font for any device context.
///
/// A pointer to a LOGFONT structure that defines the characteristics of the logical font.
///
/// If the function succeeds, the return value is a handle to a logical font.
/// If the function fails, the return value is NULL.
///
///
///
/// The CreateFontIndirect function creates a logical font with the characteristics specified in the LOGFONT structure. When
/// this font is selected by using the SelectObject function, GDI's font mapper attempts to match the logical font with an existing
/// physical font. If it fails to find an exact match, it provides an alternative whose characteristics match as many of the
/// requested characteristics as possible.
///
///
/// To get the appropriate font on different language versions of the OS, call EnumFontFamiliesEx with the desired font
/// characteristics in the LOGFONT structure, retrieve the appropriate typeface name, and create the font using CreateFont or CreateFontIndirect.
///
/// When you no longer need the font, call the DeleteObject function to delete it.
///
/// The fonts for many East Asian languages have two typeface names: an English name and a localized name. CreateFont and
/// CreateFontIndirect take the localized typeface name only on a system locale that matches the language, while they take the
/// English typeface name on all other system locales. The best method is to try one name and, on failure, try the other. Note that
/// EnumFonts, EnumFontFamilies, and EnumFontFamiliesEx return the English typeface name if the system locale does not match the
/// language of the font.
///
///
/// The font mapper for CreateFont, CreateFontIndirect, and CreateFontIndirectEx recognizes both the English and the localized
/// typeface name, regardless of locale.
///
/// Examples
/// For an example, see Creating a Logical Font.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createfontindirecta HFONT CreateFontIndirectA( const LOGFONTA
// *lplf );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "b7919fb6-8515-4f1b-af9c-dc7eac381b90")]
public static extern SafeHFONT CreateFontIndirect(in LOGFONT lplf);
///
/// The CreateFontIndirectEx function specifies a logical font that has the characteristics in the specified structure. The
/// font can subsequently be selected as the current font for any device context.
///
///
/// Pointer to an ENUMLOGFONTEXDV structure that defines the characteristics of a multiple master font.
/// Note, this function ignores the elfDesignVector member in ENUMLOGFONTEXDV.
///
///
/// If the function succeeds, the return value is the handle to the new ENUMLOGFONTEXDV structure.
/// If the function fails, the return value is zero. No extended error information is available.
///
///
///
/// The CreateFontIndirectEx function creates a logical font with the characteristics specified in the ENUMLOGFONTEXDV
/// structure. When this font is selected by using the SelectObject function, GDI's font mapper attempts to match the logical font
/// with an existing physical font. If it fails to find an exact match, it provides an alternative whose characteristics match as
/// many of the requested characteristics as possible.
///
/// When you no longer need the font, call the DeleteObject function to delete it.
///
/// The font mapper for CreateFont, CreateFontIndirect, and CreateFontIndirectEx recognizes both the English and the localized
/// typeface name, regardless of locale.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createfontindirectexa HFONT CreateFontIndirectExA( const
// ENUMLOGFONTEXDVA *Arg1 );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "1161b79e-f9c8-4073-97c4-1ccc1a78279b")]
public static extern SafeHFONT CreateFontIndirectEx(in ENUMLOGFONTEXDV Arg1);
///
///
/// [The CreateScalableFontResource function is available for use in the operating systems specified in the Requirements
/// section. It may be
///
/// altered or unavailable in subsequent versions.]
/// The CreateScalableFontResource function creates a font resource file for a scalable font.
///
///
/// Specifies whether the font is a read-only font. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// 0
/// The font has read/write permission.
///
/// -
/// 1
///
/// The font has read-only permission and should be hidden from other applications in the system. When this flag is set, the font is
/// not enumerated by the EnumFonts or EnumFontFamilies function.
///
///
///
///
///
/// A pointer to a null-terminated string specifying the name of the font resource file to create. If this parameter specifies an
/// existing font resource file, the function fails.
///
///
/// A pointer to a null-terminated string specifying the name of the scalable font file that this function uses to create the font
/// resource file.
///
/// A pointer to a null-terminated string specifying the path to the scalable font file.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
/// If lpszFontRes specifies an existing font file, GetLastError returns ERROR_FILE_EXISTS
///
///
///
/// The CreateScalableFontResource function is used by applications that install TrueType fonts. An application uses the
/// CreateScalableFontResource function to create a font resource file (typically with a .fot file name extension) and then
/// uses the AddFontResource function to install the font. The TrueType font file (typically with a .ttf file name extension) must be
/// in the System subdirectory of the Windows directory to be used by the AddFontResource function.
///
/// The CreateScalableFontResource function currently supports only TrueType-technology scalable fonts.
///
/// When the lpszFontFile parameter specifies only a file name and extension, the lpszCurrentPath parameter must specify a path. When
/// the lpszFontFile parameter specifies a full path, the lpszCurrentPath parameter must be NULL or a pointer to NULL.
///
///
/// When only a file name and extension are specified in the lpszFontFile parameter and a path is specified in the lpszCurrentPath
/// parameter, the string in lpszFontFile is copied into the .fot file as the .ttf file that belongs to this resource. When the
/// AddFontResource function is called, the operating system assumes that the .ttf file has been copied into the System directory (or
/// into the main Windows directory in the case of a network installation). The .ttf file need not be in this directory when the
/// CreateScalableFontResource function is called, because the lpszCurrentPath parameter contains the directory information. A
/// resource created in this manner does not contain absolute path information and can be used in any installation.
///
///
/// When a path is specified in the lpszFontFile parameter and NULL is specified in the lpszCurrentPath parameter, the string
/// in lpszFontFile is copied into the .fot file. In this case, when the AddFontResource function is called, the .ttf file must be at
/// the location specified in the lpszFontFile parameter when the CreateScalableFontResource function was called; the
/// lpszCurrentPath parameter is not needed. A resource created in this manner contains absolute references to paths and drives and
/// does not work if the .ttf file is moved to a different location.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createscalablefontresourcea BOOL CreateScalableFontResourceA(
// DWORD fdwHidden, LPCSTR lpszFont, LPCSTR lpszFile, LPCSTR lpszPath );
[DllImport(Lib.Gdi32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "9a43a254-4cf4-46de-80b2-a83838871fd7")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CreateScalableFontResource(uint fdwHidden, string lpszFont, string lpszFile, string lpszPath);
///
///
/// 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.
///
///
/// A handle to the device context from which to enumerate the fonts.
///
/// A pointer to a null-terminated string that specifies the family name of the desired fonts. If lpszFamily is NULL,
/// EnumFontFamilies selects and enumerates one font of each available type family.
///
/// A pointer to the application defined callback function. For information, see EnumFontFamProc.
///
/// A pointer to application-supplied data. The data is passed to the callback function along with the font information.
///
/// The return value is the last value returned by the callback function. Its meaning is implementation specific.
///
///
/// 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. EnumFonts,
/// EnumFontFamilies, and EnumFontFamiliesEx return the English typeface name if the system locale does not match the language
/// of the font.
///
/// Examples
/// For examples, see Enumerating the Installed Fonts.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-enumfontfamiliesa int EnumFontFamiliesA( HDC hdc, LPCSTR
// lpLogfont, FONTENUMPROCA lpProc, LPARAM lParam );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "4960afbb-eeba-4030-ac89-d1ff077bb2f3")]
public static extern int EnumFontFamilies(HDC hdc, string lpLogfont, EnumFontFamProc lpProc, [Optional] IntPtr lParam);
///
/// 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.
///
/// A handle to the device context from which to enumerate the fonts.
///
///
/// 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.
///
///
///
///
/// A pointer to the application defined callback function. For more information, see the EnumFontFamExProc function.
///
///
/// An application defined value. The function passes this value to the callback function along with font information.
///
/// This parameter is not used and must be zero.
///
/// 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.
///
///
///
/// 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 EnumFontFamilies, EnumFontFamiliesEx 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 and lfFaceName.
///
///
///
/// Values
/// Meaning
///
/// -
/// 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.
///
/// The callback functions for EnumFontFamilies and EnumFontFamiliesEx are very similar. The main difference is that the
/// ENUMLOGFONTEX structure includes a script field.
///
///
/// Note, based on the values of lfCharSet and lfFaceName, EnumFontFamiliesEx 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. EnumFonts,
/// EnumFontFamilies, 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.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-enumfontfamiliesexa int EnumFontFamiliesExA( HDC hdc,
// LPLOGFONTA lpLogfont, FONTENUMPROCA lpProc, LPARAM lParam, DWORD dwFlags );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "4d70906d-8005-4c4a-869e-16dd3e6fa3f2")]
public static extern int EnumFontFamiliesEx(HDC hdc, in LOGFONT lpLogfont, EnumFontFamExProc lpProc, [Optional] IntPtr lParam, uint dwFlags = 0);
///
/// 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.
///
/// A handle to the device context from which to enumerate the fonts.
/// The character set.
///
/// 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.
///
/// A sequence of tuples that contain the ENUMLOGFONTEXDV, ENUMTEXTMETRIC and FontType for each font family.
[PInvokeData("wingdi.h", MSDNShortId = "4d70906d-8005-4c4a-869e-16dd3e6fa3f2")]
public static IEnumerable<(ENUMLOGFONTEXDV lpelfe, ENUMTEXTMETRIC lpntme, FontType FontType)> EnumFontFamiliesEx(HDC hdc, PInvoke.CharacterSet lfCharSet = PInvoke.CharacterSet.ANSI_CHARSET, string lfFaceName = "")
{
var lf = default(LOGFONT);
lf.lfCharSet = lfCharSet;
lf.lfFaceName = lfFaceName;
var l = new List<(ENUMLOGFONTEXDV lpelfe, ENUMTEXTMETRIC lpntme, FontType FontType)>();
EnumFontFamiliesEx(hdc, lf, EnumProc);
return l;
int EnumProc(in ENUMLOGFONTEXDV lpelfe, in ENUMTEXTMETRIC lpntme, FontType FontType, IntPtr lParam)
{
l.Add((lpelfe, lpntme, FontType));
return 1;
}
}
///
///
/// 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.
///
///
/// A handle to the device context from which to enumerate the fonts.
///
/// A pointer to a null-terminated string that specifies the typeface name of the desired fonts. If lpFaceName is NULL,
/// EnumFonts randomly selects and enumerates one font of each available typeface.
///
/// A pointer to the application definedcallback function. For more information, see EnumFontsProc.
///
/// A pointer to any application-defined data. The data is passed to the callback function along with the font information.
///
/// The return value is the last value returned by the callback function. Its meaning is defined by the application.
///
///
/// 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. EnumFonts,
/// EnumFontFamilies, and EnumFontFamiliesEx return the English typeface name if the system locale does not match the language of the font.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-enumfontsa int EnumFontsA( HDC hdc, LPCSTR lpLogfont,
// FONTENUMPROCA lpProc, LPARAM lParam );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "b5dfc38d-c400-4900-a15b-f251815ee346")]
public static extern int EnumFonts(HDC hdc, string lpLogfont, EnumFontsProc lpProc, [Optional] IntPtr lParam);
///
/// The ExtTextOut function draws text using the currently selected font, background color, and text color. You can optionally
/// provide dimensions to be used for clipping, opaquing, or both.
///
/// A handle to the device context.
/// The x-coordinate, in logical coordinates, of the reference point used to position the string.
/// The y-coordinate, in logical coordinates, of the reference point used to position the string.
///
/// Specifies how to use the application-defined rectangle. This parameter can be one or more of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// ETO_CLIPPED
/// The text will be clipped to the rectangle.
///
/// -
/// ETO_GLYPH_INDEX
///
/// The lpString array refers to an array returned from GetCharacterPlacement and should be parsed directly by GDI as no further
/// language-specific processing is required. Glyph indexing only applies to TrueType fonts, but the flag can be used for bitmap and
/// vector fonts to indicate that no further language processing is necessary and GDI should process the string directly. Note that
/// all glyph indexes are 16-bit values even though the string is assumed to be an array of 8-bit values for raster fonts. For
/// ExtTextOutW, the glyph indexes are saved to a metafile. However, to display the correct characters the metafile must be played
/// back using the same font. For ExtTextOutA, the glyph indexes are not saved.
///
///
/// -
/// ETO_IGNORELANGUAGE
///
/// Reserved for system use. If an application sets this flag, it loses international scripting support and in some cases it may
/// display no text at all.
///
///
/// -
/// ETO_NUMERICSLATIN
/// To display numbers, use European digits.
///
/// -
/// ETO_NUMERICSLOCAL
/// To display numbers, use digits appropriate to the locale.
///
/// -
/// ETO_OPAQUE
/// The current background color should be used to fill the rectangle.
///
/// -
/// ETO_PDY
///
/// When this is set, the array pointed to by lpDx contains pairs of values. The first value of each pair is, as usual, the distance
/// between origins of adjacent character cells, but the second value is the displacement along the vertical direction of the font.
///
///
/// -
/// ETO_RTLREADING
///
/// Middle East language edition of Windows: If this value is specified and a Hebrew or Arabic font is selected into the device
/// context, the string is output using right-to-left reading order. If this value is not specified, the string is output in
/// left-to-right order. The same effect can be achieved by setting the TA_RTLREADING value in SetTextAlign. This value is preserved
/// for backward compatibility.
///
///
///
///
/// The ETO_GLYPH_INDEX and ETO_RTLREADING values cannot be used together. Because ETO_GLYPH_INDEX implies that all language
/// processing has been completed, the function ignores the ETO_RTLREADING flag if also specified.
///
///
///
/// A pointer to an optional RECT structure that specifies the dimensions, in logical coordinates, of a rectangle that is used for
/// clipping, opaquing, or both.
///
///
/// A pointer to a string that specifies the text to be drawn. The string does not need to be zero-terminated, since cbCount
/// specifies the length of the string.
///
///
/// The length of the string pointed to by lpString.
/// This value may not exceed 8192.
///
///
/// A pointer to an optional array of values that indicate the distance between origins of adjacent character cells. For example,
/// lpDx[i] logical units separate the origins of character cell i and character cell i + 1.
///
///
///
/// If the string is drawn, the return value is nonzero. However, if the ANSI version of ExtTextOut is called with
/// ETO_GLYPH_INDEX, the function returns TRUE even though the function does nothing.
///
/// If the function fails, the return value is zero.
///
///
///
/// The current text-alignment settings for the specified device context determine how the reference point is used to position the
/// text. The text-alignment settings are retrieved by calling the GetTextAlign function. The text-alignment settings are altered by
/// calling the SetTextAlign function. You can use the following values for text alignment. Only one flag can be chosen from those
/// that affect horizontal and vertical alignment. In addition, only one of the two flags that alter the current position can be chosen.
///
///
///
/// Term
/// Description
///
/// -
/// TA_BASELINE
/// The reference point will be on the base line of the text.
///
/// -
/// TA_BOTTOM
/// The reference point will be on the bottom edge of the bounding rectangle.
///
/// -
/// TA_TOP
/// The reference point will be on the top edge of the bounding rectangle.
///
/// -
/// TA_CENTER
/// The reference point will be aligned horizontally with the center of the bounding rectangle.
///
/// -
/// TA_LEFT
/// The reference point will be on the left edge of the bounding rectangle.
///
/// -
/// TA_RIGHT
/// The reference point will be on the right edge of the bounding rectangle.
///
/// -
/// TA_NOUPDATECP
/// The current position is not updated after each text output call. The reference point is passed to the text output function.
///
/// -
/// TA_RTLREADING
///
/// Middle East language edition of Windows: The text is laid out in right to left reading order, as opposed to the default left to
/// right order. This applies only when the font selected into the device context is either Hebrew or Arabic.
///
///
/// -
/// TA_UPDATECP
/// The current position is updated after each text output call. The current position is used as the reference point.
///
///
///
/// If the lpDx parameter is NULL, the ExtTextOut function uses the default spacing between characters. The
/// character-cell origins and the contents of the array pointed to by the lpDx parameter are specified in logical units. A
/// character-cell origin is defined as the upper-left corner of the character cell.
///
///
/// By default, the current position is not used or updated by this function. However, an application can call the SetTextAlign
/// function with the fMode parameter set to TA_UPDATECP to permit the system to use and update the current position each time the
/// application calls ExtTextOut for a specified device context. When this flag is set, the system ignores the X and Y
/// parameters on subsequent ExtTextOut calls.
///
///
/// For the ANSI version of ExtTextOut, the lpDx array has the same number of INT values as there are bytes in lpString. For
/// DBCS characters, you can apportion the dx in the lpDx entries between the lead byte and the trail byte, as long as the sum of the
/// two bytes adds up to the desired dx. For DBCS characters with the Unicode version of ExtTextOut, each Unicode glyph gets a
/// single pdx entry.
///
///
/// Note, the alpDx values from GetTextExtentExPoint are not the same as the lpDx values for ExtTextOut. To use the alpDx
/// values in lpDx, you must first process them.
///
/// Examples
/// For an example, see "Setting Fonts for Menu-Item Text Strings" in Using Menus.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-exttextouta BOOL ExtTextOutA( HDC hdc, int x, int y, UINT
// options, const RECT *lprect, LPCSTR lpString, UINT c, const INT *lpDx );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "74f8fcb8-8ad4-47f2-a330-fa56713bdb37")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ExtTextOut(HDC hdc, int x, int y, ETO options, [In, Optional] PRECT lprect, string lpString, uint c, [In, Optional] int[] lpDx);
/// The GetAspectRatioFilterEx function retrieves the setting for the current aspect-ratio filter.
/// Handle to a device context.
/// Pointer to a SIZE structure that receives the current aspect-ratio filter.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
/// The aspect ratio is the ratio formed by the width and height of a pixel on a specified device.
///
/// The system provides a special filter, the aspect-ratio filter, to select fonts that were designed for a particular device. An
/// application can specify that the system should only retrieve fonts matching the specified aspect ratio by calling the
/// SetMapperFlags function.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getaspectratiofilterex BOOL GetAspectRatioFilterEx( HDC hdc,
// LPSIZE lpsize );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "3f2dd47d-08bf-4848-897f-5ae506fba342")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetAspectRatioFilterEx(HDC hdc, out SIZE lpsize);
///
/// The GetCharABCWidths function retrieves the widths, in logical units, of consecutive characters in a specified range from
/// the current TrueType font. This function succeeds only with TrueType fonts.
///
/// A handle to the device context.
/// The first character in the group of consecutive characters from the current font.
/// The last character in the group of consecutive characters from the current font.
///
/// A pointer to an array of ABC structures that receives the character widths, in logical units. This array must contain at least as
/// many ABC structures as there are characters in the range specified by the uFirstChar and uLastChar parameters.
///
///
/// If the function succeeds, the return value is nonzero
/// If the function fails, the return value is zero.
///
///
///
/// The TrueType rasterizer provides ABC character spacing after a specific point size has been selected. A spacing is the distance
/// added to the current position before placing the glyph. B spacing is the width of the black part of the glyph. C spacing is the
/// distance added to the current position to provide white space to the right of the glyph. The total advanced width is specified by A+B+C.
///
///
/// When the GetCharABCWidths function retrieves negative A or C widths for a character, that character includes underhangs or overhangs.
///
///
/// To convert the ABC widths to font design units, an application should use the value stored in the otmEMSquare member of a
/// OUTLINETEXTMETRIC structure. This value can be retrieved by calling the GetOutlineTextMetrics function.
///
/// The ABC widths of the default character are used for characters outside the range of the currently selected font.
/// To retrieve the widths of characters in non-TrueType fonts, applications should use the GetCharWidth function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getcharabcwidthsa BOOL GetCharABCWidthsA( HDC hdc, UINT
// wFirst, UINT wLast, LPABC lpABC );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "b48ab66d-ff0a-48d9-b7dd-28610bf69d51")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCharABCWidths(HDC hdc, uint wFirst, uint wLast, [In, Out] ABC[] lpABC);
///
/// The GetCharABCWidthsFloat function retrieves the widths, in logical units, of consecutive characters in a specified range
/// from the current font.
///
/// Handle to the device context.
///
/// Specifies the code point of the first character in the group of consecutive characters where the ABC widths are seeked.
///
///
/// Specifies the code point of the last character in the group of consecutive characters where the ABC widths are seeked. This range
/// is inclusive. An error is returned if the specified last character precedes the specified first character.
///
/// Pointer to an array of ABCFLOAT structures that receives the character widths, in logical units.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// Unlike the GetCharABCWidths function that returns widths only for TrueType fonts, the GetCharABCWidthsFloat function
/// retrieves widths for any font. The widths returned by this function are in the IEEE floating-point format.
///
///
/// If the current world-to-device transformation is not identified, the returned widths may be noninteger values, even if the
/// corresponding values in the device space are integers.
///
///
/// A spacing is the distance added to the current position before placing the glyph. B spacing is the width of the black part of the
/// glyph. C spacing is the distance added to the current position to provide white space to the right of the glyph. The total
/// advanced width is specified by A+B+C.
///
/// The ABC spaces are measured along the character base line of the selected font.
/// The ABC widths of the default character are used for characters outside the range of the currently selected font.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getcharabcwidthsfloata BOOL GetCharABCWidthsFloatA( HDC hdc,
// UINT iFirst, UINT iLast, LPABCFLOAT lpABC );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "552942c9-e2a6-43f9-901f-3aba1e2523e5")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCharABCWidthsFloat(HDC hdc, uint iFirst, uint iLast, [In, Out] ABCFLOAT[] lpABC);
///
/// The GetCharABCWidthsI function retrieves the widths, in logical units, of consecutive glyph indices in a specified range
/// from the current TrueType font. This function succeeds only with TrueType fonts.
///
/// A handle to the device context.
///
/// The first glyph index in the group of consecutive glyph indices from the current font. This parameter is only used if the pgi
/// parameter is NULL.
///
/// The number of glyph indices.
///
/// A pointer to an array that contains glyph indices. If this parameter is NULL, the giFirst parameter is used instead. The
/// cgi parameter specifies the number of glyph indices in this array.
///
///
/// A pointer to an array of ABC structures that receives the character widths, in logical units. This array must contain at least as
/// many ABC structures as there are glyph indices specified by the cgi parameter.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// The TrueType rasterizer provides ABC character spacing after a specific point size has been selected. A spacing is the distance
/// added to the current position before placing the glyph. B spacing is the width of the black part of the glyph. C spacing is the
/// distance added to the current position to provide white space to the right of the glyph. The total advanced width is specified by A+B+C.
///
///
/// When the GetCharABCWidthsI function retrieves negative A or C widths for a character, that character includes underhangs
/// or overhangs.
///
///
/// To convert the ABC widths to font design units, an application should use the value stored in the otmEMSquare member of a
/// OUTLINETEXTMETRIC structure. This value can be retrieved by calling the GetOutlineTextMetrics function.
///
/// The ABC widths of the default character are used for characters outside the range of the currently selected font.
/// To retrieve the widths of glyph indices in non-TrueType fonts, applications should use the GetCharWidthI function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getcharabcwidthsi BOOL GetCharABCWidthsI( HDC hdc, UINT
// giFirst, UINT cgi, LPWORD pgi, LPABC pabc );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "7d1210ee-42b7-4f2e-9e89-fb1543d76290")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCharABCWidthsI(HDC hdc, uint giFirst, uint cgi, [In, Optional] ushort[] pgi, [In, Out] ABC[] pabc);
///
///
/// The GetCharacterPlacement function retrieves information about a character string, such as character widths, caret
/// positioning, ordering within the string, and glyph rendering. The type of information returned depends on the dwFlags parameter
/// and is based on the currently selected font in the specified display context. The function copies the information to the
/// specified GCP_RESULTS structure or to one or more arrays specified by the structure.
///
///
/// Although this function was once adequate for working with character strings, a need to work with an increasing number of
/// languages and scripts has rendered it obsolete. It has been superseded by the functionality of the Uniscribe module. For more
/// information, see Uniscribe.
///
///
/// It is recommended that an application use the GetFontLanguageInfo function to determine whether the GCP_DIACRITIC, GCP_DBCS,
/// GCP_USEKERNING, GCP_LIGATE, GCP_REORDER, GCP_GLYPHSHAPE, and GCP_KASHIDA values are valid for the currently selected font. If not
/// valid, GetCharacterPlacement ignores the value.
///
/// The GCP_NODIACRITICS value is no longer defined and should not be used.
///
/// A handle to the device context.
///
/// A pointer to the character string to process. The string does not need to be zero-terminated, since nCount specifies the length
/// of the string.
///
/// The length of the string pointed to by lpString.
///
/// The maximum extent (in logical units) to which the string is processed. Characters that, if processed, would exceed this extent
/// are ignored. Computations for any required ordering or glyph arrays apply only to the included characters. This parameter is used
/// only if the GCP_MAXEXTENT value is specified in the dwFlags parameter. As the function processes the input string, each character
/// and its extent is added to the output, extent, and other arrays only if the total extent has not yet exceeded the maximum. Once
/// the limit is reached, processing will stop.
///
/// A pointer to a GCP_RESULTS structure that receives the results of the function.
///
/// Specifies how to process the string into the required arrays. This parameter can be one or more of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// GCP_CLASSIN
///
/// Specifies that the lpClass array contains preset classifications for characters. The classifications may be the same as on
/// output. If the particular classification for a character is not known, the corresponding location in the array must be set to
/// zero. for more information about the classifications, see GCP_RESULTS. This is useful only if GetFontLanguageInfo returned the
/// GCP_REORDER flag.
///
///
/// -
/// GCP_DIACRITIC
///
/// Determines how diacritics in the string are handled. If this value is not set, diacritics are treated as zero-width characters.
/// For example, a Hebrew string may contain diacritics, but you may not want to display them. Use GetFontLanguageInfo to determine
/// whether a font supports diacritics. If it does, you can use or not use the GCP_DIACRITIC flag in the call to
/// GetCharacterPlacement, depending on the needs of your application.
///
///
/// -
/// GCP_DISPLAYZWG
///
/// For languages that need reordering or different glyph shapes depending on the positions of the characters within a word,
/// nondisplayable characters often appear in the code page. For example, in the Hebrew code page, there are Left-To-Right and
/// Right-To-Left markers, to help determine the final positioning of characters within the output strings. Normally these are not
/// displayed and are removed from the lpGlyphs and lpDx arrays. You can use the GCP_DISPLAYZWG flag to display these characters.
///
///
/// -
/// GCP_GLYPHSHAPE
///
/// Specifies that some or all characters in the string are to be displayed using shapes other than the standard shapes defined in
/// the currently selected font for the current code page. Some languages, such as Arabic, cannot support glyph creation unless this
/// value is specified. As a general rule, if GetFontLanguageInfo returns this value for a string, this value must be used with GetCharacterPlacement.
///
///
/// -
/// GCP_JUSTIFY
///
/// Adjusts the extents in the lpDx array so that the string length is the same as nMaxExtent. GCP_JUSTIFY may only be used in
/// conjunction with GCP_MAXEXTENT.
///
///
/// -
/// GCP_KASHIDA
///
/// Use Kashidas as well as, or instead of, adjusted extents to modify the length of the string so that it is equal to the value
/// specified by nMaxExtent. In the lpDx array, a Kashida is indicated by a negative justification index. GCP_KASHIDA may be used
/// only in conjunction with GCP_JUSTIFY and only if the font (and language) support Kashidas. Use GetFontLanguageInfo to determine
/// whether the current font supports Kashidas. Using Kashidas to justify the string can result in the number of glyphs required
/// being greater than the number of characters in the input string. Because of this, when Kashidas are used, the application cannot
/// assume that setting the arrays to be the size of the input string will be sufficient. (The maximum possible will be approximately
/// dxPageWidth/dxAveCharWidth, where dxPageWidth is the width of the document and dxAveCharWidth is the average character width as
/// returned from a GetTextMetrics call). Note that just because GetFontLanguageInfo returns the GCP_KASHIDA flag does not mean that
/// it has to be used in the call to GetCharacterPlacement, just that the option is available.
///
///
/// -
/// GCP_LIGATE
///
/// Use ligations wherever characters ligate. A ligation occurs where one glyph is used for two or more characters. For example, the
/// letters a and e can ligate to ?. For this to be used, however, both the language support and the font must support the required
/// glyphs (the example will not be processed by default in English). Use GetFontLanguageInfo to determine whether the current font
/// supports ligation. If it does and a specific maximum is required for the number of characters that will ligate, set the number in
/// the first element of the lpGlyphs array. If normal ligation is required, set this value to zero. If GCP_LIGATE is not specified,
/// no ligation will take place. See GCP_RESULTS for more information. If the GCP_REORDER value is usually required for the character
/// set but is not specified, the output will be meaningless unless the string being passed in is already in visual ordering (that
/// is, the result that gets put into lpGcpResults->lpOutString in one call to GetCharacterPlacement is the input string of a
/// second call). Note that just because GetFontLanguageInfo returns the GCP_LIGATE flag does not mean that it has to be used in the
/// call to GetCharacterPlacement, just that the option is available.
///
///
/// -
/// GCP_MAXEXTENT
///
/// Compute extents of the string only as long as the resulting extent, in logical units, does not exceed the values specified by the
/// nMaxExtent parameter.
///
///
/// -
/// GCP_NEUTRALOVERRIDE
///
/// Certain languages only. Override the normal handling of neutrals and treat them as strong characters that match the strings
/// reading order. Useful only with the GCP_REORDER flag.
///
///
/// -
/// GCP_NUMERICOVERRIDE
///
/// Certain languages only. Override the normal handling of numerics and treat them as strong characters that match the strings
/// reading order. Useful only with the GCP_REORDER flag.
///
///
/// -
/// GCP_NUMERICSLATIN
///
/// Arabic/Thai only. Use standard Latin glyphs for numbers and override the system default. To determine if this option is available
/// in the language of the font, use GetStringTypeEx to see if the language supports more than one number format.
///
///
/// -
/// GCP_NUMERICSLOCAL
///
/// Arabic/Thai only. Use local glyphs for numeric characters and override the system default. To determine if this option is
/// available in the language of the font, use GetStringTypeEx to see if the language supports more than one number format.
///
///
/// -
/// GCP_REORDER
///
/// Reorder the string. Use for languages that are not SBCS and left-to-right reading order. If this value is not specified, the
/// string is assumed to be in display order already. If this flag is set for Semitic languages and the lpClass array is used, the
/// first two elements of the array are used to specify the reading order beyond the bounds of the string. GCP_CLASS_PREBOUNDRTL and
/// GCP_CLASS_PREBOUNDLTR can be used to set the order. If no preset order is required, set the values to zero. These values can be
/// combined with other values if the GCPCLASSIN flag is set. If the GCP_REORDER value is not specified, the lpString parameter is
/// taken to be visual ordered for languages where this is used, and the lpOutString and lpOrder fields are ignored. Use
/// GetFontLanguageInfo to determine whether the current font supports reordering.
///
///
/// -
/// GCP_SYMSWAPOFF
///
/// Semitic languages only. Specifies that swappable characters are not reset. For example, in a right-to-left string, the '(' and
/// ')' are not reversed.
///
///
/// -
/// GCP_USEKERNING
///
/// Use kerning pairs in the font (if any) when creating the widths arrays. Use GetFontLanguageInfo to determine whether the current
/// font supports kerning pairs. Note that just because GetFontLanguageInfo returns the GCP_USEKERNING flag does not mean that it has
/// to be used in the call to GetCharacterPlacement, just that the option is available. Most TrueType fonts have a kerning table, but
/// you do not have to use it.
///
///
///
///
/// It is recommended that an application use the GetFontLanguageInfo function to determine whether the GCP_DIACRITIC, GCP_DBCS,
/// GCP_USEKERNING, GCP_LIGATE, GCP_REORDER, GCP_GLYPHSHAPE, and GCP_KASHIDA values are valid for the currently selected font. If not
/// valid, GetCharacterPlacement ignores the value.
///
/// The GCP_NODIACRITICS value is no longer defined and should not be used.
///
///
///
/// If the function succeeds, the return value is the width and height of the string in logical units. The width is the low-order
/// word and the height is the high-order word.
///
/// If the function fails, the return value is zero.
///
///
///
/// GetCharacterPlacement ensures that an application can correctly process text regardless of the international setting and
/// type of fonts available. Applications use this function before using the ExtTextOut function and in place of the
/// GetTextExtentPoint32 function (and occasionally in place of the GetCharWidth32 and GetCharABCWidths functions).
///
///
/// Using GetCharacterPlacement to retrieve intercharacter spacing and index arrays is not always necessary unless
/// justification or kerning is required. For non-Latin fonts, applications can improve the speed at which the ExtTextOut function
/// renders text by using GetCharacterPlacement to retrieve the intercharacter spacing and index arrays before calling
/// ExtTextOut. This is especially useful when rendering the same text repeatedly or when using intercharacter spacing to
/// position the caret. If the lpGlyphs output array is used in the call to ExtTextOut, the ETO_GLYPH_INDEX flag must
/// be set.
///
///
/// GetCharacterPlacement checks the lpOrder, lpDX, lpCaretPos, lpOutString, and lpGlyphs
/// members of the GCP_RESULTS structure and fills the corresponding arrays if these members are not set to NULL. If
/// GetCharacterPlacement cannot fill an array, it sets the corresponding member to NULL. To ensure retrieval of valid
/// information, the application is responsible for setting the member to a valid address before calling the function and for
/// checking the value of the member after the call. If the GCP_JUSTIFY or GCP_USEKERNING values are specified, the lpDX
/// and/or lpCaretPos members must have valid addresses.
///
///
/// Note that the glyph indexes returned in GCP_RESULTS.lpGlyphs are specific to the current font in the device context and should
/// only be used to draw text in the device context while that font remains selected.
///
///
/// When computing justification, if the trailing characters in the string are spaces, the function reduces the length of the string
/// and removes the spaces prior to computing the justification. If the array consists of only spaces, the function returns an error.
///
///
/// ExtTextOut expects an lpDX entry for each byte of a DBCS string, whereas GetCharacterPlacement assigns an
/// lpDX entry for each glyph. To correct this mismatch when using this combination of functions, either use GetGlyphIndices
/// or expand the lpDX array with zero-width entries for the corresponding second byte of a DBCS byte pair.
///
///
/// If the logical width is less than the width of the leading character in the input string, GCP_RESULTS.nMaxFit returns a bad
/// value. For this case, call GetCharacterPlacement for glyph indexes and the lpDX array. Then use the lpDX
/// array to do the extent calculation using the advance width of each character, where nMaxFit is the number of characters
/// whose glyph indexes advance width is less than the width of the leading character.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getcharacterplacementa DWORD GetCharacterPlacementA( HDC hdc,
// LPCSTR lpString, int nCount, int nMexExtent, LPGCP_RESULTSA lpResults, DWORD dwFlags );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "80d3f4b3-503b-4abb-826c-e5c09972ba2f")]
public static extern uint GetCharacterPlacement(HDC hdc, string lpString, int nCount, int nMexExtent, out GCP_RESULTS lpResults, GCP dwFlags);
///
/// The GetCharWidth32 function retrieves the widths, in logical coordinates, of consecutive characters in a specified range
/// from the current font.
///
/// A handle to the device context.
/// The first character in the group of consecutive characters.
/// The last character in the group of consecutive characters, which must not precede the specified first character.
/// A pointer to a buffer that receives the character widths, in logical coordinates.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
/// GetCharWidth32 cannot be used on TrueType fonts. To retrieve character widths for TrueType fonts, use GetCharABCWidths.
///
/// The range is inclusive; that is, the returned widths include the widths of the characters specified by the iFirstChar and
/// iLastChar parameters.
///
/// If a character does not exist in the current font, it is assigned the width of the default character.
/// Examples
/// For an example, see "Displaying Keyboard Input" in Using Keyboard Input.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getcharwidth32a BOOL GetCharWidth32A( HDC hdc, UINT iFirst,
// UINT iLast, LPINT lpBuffer );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "f7d6e9b3-72aa-42d8-8346-b230b9e98237")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCharWidth32(HDC hdc, uint iFirst, uint iLast, [Out] int[] lpBuffer);
///
/// The GetCharWidthFloat function retrieves the fractional widths of consecutive characters in a specified range from the
/// current font.
///
/// A handle to the device context.
/// The code point of the first character in the group of consecutive characters.
/// The code point of the last character in the group of consecutive characters.
/// A pointer to a buffer that receives the character widths, in logical units.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// The returned widths are in the 32-bit IEEE floating-point format. (The widths are measured along the base line of the characters.)
///
///
/// If the iFirstChar parameter specifies the letter a and the iLastChar parameter specifies the letter z, GetCharWidthFloat
/// retrieves the widths of all lowercase characters.
///
/// If a character does not exist in the current font, it is assigned the width of the default character.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getcharwidthfloata BOOL GetCharWidthFloatA( HDC hdc, UINT
// iFirst, UINT iLast, PFLOAT lpBuffer );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "7a90b701-63f9-41e5-9069-10d344edfe02")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCharWidthFloat(HDC hdc, uint iFirst, uint iLast, [Out] float[] lpBuffer);
///
/// The GetCharWidthI function retrieves the widths, in logical coordinates, of consecutive glyph indices in a specified range
/// from the current font.
///
/// A handle to the device context.
/// The first glyph index in the group of consecutive glyph indices.
/// The number of glyph indices.
///
/// A pointer to an array of glyph indices. If this parameter is not NULL, it is used instead of the giFirst parameter.
///
/// A pointer to a buffer that receives the widths, in logical coordinates.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// The GetCharWidthI function processes a consecutive glyph indices if the pgi parameter is NULL with the giFirst
/// parameter indicating the first glyph index to process and the cgi parameter indicating how many glyph indices to process.
/// Otherwise the GetCharWidthI function processes the array of glyph indices pointed to by the pgi parameter with the cgi
/// parameter indicating how many glyph indices to process.
///
/// If a character does not exist in the current font, it is assigned the width of the default character.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getcharwidthi BOOL GetCharWidthI( HDC hdc, UINT giFirst, UINT
// cgi, LPWORD pgi, LPINT piWidths );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "5f532149-7c2f-4972-9900-68c2f185d255")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCharWidthI(HDC hdc, uint giFirst, uint cgi, [In, Optional] ushort[] pgi, [Out] int[] piWidths);
/// The GetFontData function retrieves font metric data for a TrueType font.
/// A handle to the device context.
///
/// 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).
///
///
/// 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.
///
///
/// A 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.
///
///
/// 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.
///
///
/// If the function succeeds, the return value is the number of bytes returned.
/// If the function fails, the return value is GDI_ERROR.
///
///
///
/// 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.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getfontdata DWORD GetFontData( HDC hdc, DWORD dwTable, DWORD
// dwOffset, PVOID pvBuffer, DWORD cjBuffer );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "ec716ad8-bdc2-4f61-968e-f86288123cec")]
public static extern uint GetFontData(HDC hdc, [Optional] uint dwTable, [Optional] uint dwOffset, [Optional] IntPtr pvBuffer, [Optional] uint cjBuffer);
///
/// 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.
///
/// Handle to a display device context.
///
///
/// 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.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getfontlanguageinfo DWORD GetFontLanguageInfo( HDC hdc );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "c2f19423-4410-44dd-83f1-5b858852051d")]
public static extern GCP GetFontLanguageInfo(HDC hdc);
///
/// The GetFontUnicodeRanges function returns information about which Unicode characters are supported by a font. The
/// information is returned as a GLYPHSET structure.
///
/// A handle to the device context.
///
/// A pointer to a GLYPHSET structure that receives the glyph set information. If this parameter is NULL, the function returns
/// the size of the GLYPHSET structure required to store the information.
///
///
///
/// If the function succeeds, it returns number of bytes written to the GLYPHSET structure or, if the lpgs parameter is NULL,
/// it returns the size of the GLYPHSET structure required to store the information.
///
/// If the function fails, it returns zero. No extended error information is available.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getfontunicoderanges DWORD GetFontUnicodeRanges( HDC hdc,
// LPGLYPHSET lpgs );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "51b0ab12-c467-4a89-8173-fdc513868aae")]
public static extern uint GetFontUnicodeRanges(HDC hdc, IntPtr lpgs);
///
/// The GetFontUnicodeRanges function returns information about which Unicode characters are supported by a font. The
/// information is returned as a GLYPHSET structure.
///
/// A handle to the device context.
/// A structure with the glyph set information.
/// An unspecified error has occurred.
public static GLYPHSET GetFontUnicodeRanges(HDC hdc)
{
var l = GetFontUnicodeRanges(hdc, IntPtr.Zero);
if (l == 0) throw new Exception();
using var mem = new SafeAnysizeStruct(l, nameof(GLYPHSET.cRanges));
mem.DangerousGetHandle().Write(l); // Set cbThis
if (0 == GetFontUnicodeRanges(hdc, mem))
throw new Exception();
return mem.Value;
}
///
/// The GetGlyphIndices function translates a string into an array of glyph indices. The function can be used to determine
/// whether a glyph exists in a font.
///
/// A handle to the device context.
/// A pointer to the string to be converted.
///
/// The length of both the length of the string pointed to by lpstr and the size (in WORDs) of the buffer pointed to by pgi.
///
///
/// This buffer must be of dimension c. On successful return, contains an array of glyph indices corresponding to the characters in
/// the string.
///
///
/// Specifies how glyphs should be handled if they are not supported. This parameter can be the following value.
///
///
/// Value
/// Meaning
///
/// -
/// GGI_MARK_NONEXISTING_GLYPHS
/// Marks unsupported glyphs with the hexadecimal value 0xffff.
///
///
///
///
/// If the function succeeds, it returns the number of bytes (for the ANSI function) or WORDs (for the Unicode function) converted.
/// If the function fails, the return value is GDI_ERROR.
///
///
/// This function attempts to identify a single-glyph representation for each character in the string pointed to by lpstr. While this
/// is useful for certain low-level purposes (such as manipulating font files), higher-level applications that wish to map a string
/// to glyphs will typically wish to use the Uniscribe functions.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getglyphindicesa DWORD GetGlyphIndicesA( HDC hdc, LPCSTR
// lpstr, int c, LPWORD pgi, DWORD fl );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "7abfee7a-dd5d-4f33-96f1-b38364ba5afd")]
public static extern uint GetGlyphIndices(HDC hdc, string lpstr, int c, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] ushort[] pgi, GGI fl = GGI.GGI_MARK_NONEXISTING_GLYPHS);
///
/// The GetGlyphOutline function retrieves the outline or bitmap for a character in the TrueType font that is selected into
/// the specified device context.
///
/// A handle to the device context.
/// The character for which data is to be returned.
///
/// The format of the data that the function retrieves. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// GGO_BEZIER
/// The function retrieves the curve data as a cubic Bézier spline (not in quadratic spline format).
///
/// -
/// GGO_BITMAP
/// The function retrieves the glyph bitmap. For information about memory allocation, see the following Remarks section.
///
/// -
/// GGO_GLYPH_INDEX
///
/// Indicates that the uChar parameter is a TrueType Glyph Index rather than a character code. See the ExtTextOut function for
/// additional remarks on Glyph Indexing.
///
///
/// -
/// GGO_GRAY2_BITMAP
/// The function retrieves a glyph bitmap that contains five levels of gray.
///
/// -
/// GGO_GRAY4_BITMAP
/// The function retrieves a glyph bitmap that contains 17 levels of gray.
///
/// -
/// GGO_GRAY8_BITMAP
/// The function retrieves a glyph bitmap that contains 65 levels of gray.
///
/// -
/// GGO_METRICS
///
/// The function only retrieves the GLYPHMETRICS structure specified by lpgm. The lpvBuffer is ignored. This value affects the
/// meaning of the function's return value upon failure; see the Return Values section.
///
///
/// -
/// GGO_NATIVE
/// The function retrieves the curve data points in the rasterizer's native format and uses the font's design units.
///
/// -
/// GGO_UNHINTED
/// The function only returns unhinted outlines. This flag only works in conjunction with GGO_BEZIER and GGO_NATIVE.
///
///
///
/// Note that, for the GGO_GRAYn_BITMAP values, the function retrieves a glyph bitmap that contains n^2+1 (n squared plus one) levels
/// of gray.
///
///
/// A pointer to the GLYPHMETRICS structure describing the placement of the glyph in the character cell.
///
/// The size, in bytes, of the buffer (*lpvBuffer) where the function is to copy information about the outline character. If this
/// value is zero, the function returns the required size of the buffer.
///
///
/// A pointer to the buffer that receives information about the outline character. If this value is NULL, the function returns
/// the required size of the buffer.
///
/// A pointer to a MAT2 structure specifying a transformation matrix for the character.
///
///
/// If GGO_BITMAP, GGO_GRAY2_BITMAP, GGO_GRAY4_BITMAP, GGO_GRAY8_BITMAP, or GGO_NATIVE is specified and the function succeeds, the
/// return value is greater than zero; otherwise, the return value is GDI_ERROR. If one of these flags is specified and the buffer
/// size or address is zero, the return value specifies the required buffer size, in bytes.
///
/// If GGO_METRICS is specified and the function fails, the return value is GDI_ERROR.
///
///
///
/// The glyph outline returned by the GetGlyphOutline function is for a grid-fitted glyph. (A grid-fitted glyph is a glyph
/// that has been modified so that its bitmapped image conforms as closely as possible to the original design of the glyph.) If an
/// application needs an unmodified glyph outline, it can request the glyph outline for a character in a font whose size is equal to
/// the font's em unit. The value for a font's em unit is stored in the otmEMSquare member of the OUTLINETEXTMETRIC structure.
///
///
/// The glyph bitmap returned by GetGlyphOutline when GGO_BITMAP is specified is a DWORD-aligned, row-oriented, monochrome
/// bitmap. When GGO_GRAY2_BITMAP is specified, the bitmap returned is a DWORD-aligned, row-oriented array of bytes whose values
/// range from 0 to 4. When GGO_GRAY4_BITMAP is specified, the bitmap returned is a DWORD-aligned, row-oriented array of bytes whose
/// values range from 0 to 16. When GGO_GRAY8_BITMAP is specified, the bitmap returned is a DWORD-aligned, row-oriented array of
/// bytes whose values range from 0 to 64.
///
///
/// The native buffer returned by GetGlyphOutline when GGO_NATIVE is specified is a glyph outline. A glyph outline is returned
/// as a series of one or more contours defined by a TTPOLYGONHEADER structure followed by one or more curves. Each curve in the
/// contour is defined by a TTPOLYCURVE structure followed by a number of POINTFX data points. POINTFX points are absolute
/// positions, not relative moves. The starting point of a contour is given by the pfxStart member of the
/// TTPOLYGONHEADER structure. The starting point of each curve is the last point of the previous curve or the starting point
/// of the contour. The count of data points in a curve is stored in the cpfx member of TTPOLYCURVE structure. The size
/// of each contour in the buffer, in bytes, is stored in the cb member of TTPOLYGONHEADER structure. Additional curve
/// definitions are packed into the buffer following preceding curves and additional contours are packed into the buffer following
/// preceding contours. The buffer contains as many contours as fit within the buffer returned by GetGlyphOutline.
///
///
/// The GLYPHMETRICS structure specifies the width of the character cell and the location of a glyph within the character cell. The
/// origin of the character cell is located at the left side of the cell at the baseline of the font. The location of the glyph
/// origin is relative to the character cell origin. The height of a character cell, the baseline, and other metrics global to the
/// font are given by the OUTLINETEXTMETRIC structure.
///
///
/// An application can alter the characters retrieved in bitmap or native format by specifying a 2-by-2 transformation matrix in the
/// lpMatrix parameter. For example the glyph can be modified by shear, rotation, scaling, or any combination of the three using
/// matrix multiplication.
///
/// Additional information on a glyph outlines is located in the TrueType and the OpenType technical specifications.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getglyphoutlinea DWORD GetGlyphOutlineA( HDC hdc, UINT uChar,
// UINT fuFormat, LPGLYPHMETRICS lpgm, DWORD cjBuffer, LPVOID pvBuffer, const MAT2 *lpmat2 );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "08f06007-5b21-44ab-b234-21a58c94ed4e")]
public static extern uint GetGlyphOutline(HDC hdc, uint uChar, GGO fuFormat, out GLYPHMETRICS lpgm, uint cjBuffer, IntPtr pvBuffer, in MAT2 lpmat2);
///
/// The GetKerningPairs function retrieves the character-kerning pairs for the currently selected font for the specified
/// device context.
///
/// A handle to the device context.
///
/// The number of pairs in the lpkrnpair array. If the font has more than nNumPairs kerning pairs, the function returns an error.
///
///
/// A pointer to an array of KERNINGPAIR structures that receives the kerning pairs. The array must contain at least as many
/// structures as specified by the nNumPairs parameter. If this parameter is NULL, the function returns the total number of
/// kerning pairs for the font.
///
///
/// If the function succeeds, the return value is the number of kerning pairs returned.
/// If the function fails, the return value is zero.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getkerningpairsa DWORD GetKerningPairsA( HDC hdc, DWORD
// nPairs, LPKERNINGPAIR lpKernPair );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "9aba629f-afab-4ef3-8e1d-d0b90e122e94")]
public static extern uint GetKerningPairs(HDC hdc, uint nPairs, [Out] KERNINGPAIR[] lpKernPair);
/// The GetOutlineTextMetrics function retrieves text metrics for TrueType fonts.
/// A handle to the device context.
/// The size, in bytes, of the array that receives the text metrics.
///
/// A pointer to an OUTLINETEXTMETRIC structure. If this parameter is NULL, the function returns the size of the buffer
/// required for the retrieved metric data.
///
///
/// If the function succeeds, the return value is nonzero or the size of the required buffer.
/// If the function fails, the return value is zero.
///
///
/// The OUTLINETEXTMETRIC structure contains most of the text metric information provided for TrueType fonts (including a TEXTMETRIC
/// structure). The sizes returned in OUTLINETEXTMETRIC are in logical units; they depend on the current mapping mode.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getoutlinetextmetricsa UINT GetOutlineTextMetricsA( HDC hdc,
// UINT cjCopy, LPOUTLINETEXTMETRICA potm );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "b8c7a557-ca35-41a4-9043-8496e5b01564")]
public static extern uint GetOutlineTextMetrics(HDC hdc, uint cjCopy, IntPtr potm);
/// The GetRasterizerCaps function returns flags indicating whether TrueType fonts are installed in the system.
/// A pointer to a RASTERIZER_STATUS structure that receives information about the rasterizer.
/// The number of bytes to be copied into the structure pointed to by the lprs parameter.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// The GetRasterizerCaps function enables applications and printer drivers to determine whether TrueType fonts are installed.
///
///
/// If the TT_AVAILABLE flag is set in the wFlags member of the RASTERIZER_STATUS structure, at least one TrueType font is
/// installed. If the TT_ENABLED flag is set, TrueType is enabled for the system.
///
///
/// The actual number of bytes copied is either the member specified in the cb parameter or the length of the RASTERIZER_STATUS
/// structure, whichever is less.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getrasterizercaps BOOL GetRasterizerCaps( LPRASTERIZER_STATUS
// lpraststat, UINT cjBytes );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "0898d1c0-5480-4bd2-aa45-918340172a05")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetRasterizerCaps(out RASTERIZER_STATUS lpraststat, uint cjBytes);
/// The GetTextAlign function retrieves the text-alignment setting for the specified device context.
/// A handle to the device context.
///
///
/// If the function succeeds, the return value is the status of the text-alignment flags. For more information about the return
/// value, see the Remarks section. The return value is a combination of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// TA_BASELINE
/// The reference point is on the base line of the text.
///
/// -
/// TA_BOTTOM
/// The reference point is on the bottom edge of the bounding rectangle.
///
/// -
/// TA_TOP
/// The reference point is on the top edge of the bounding rectangle.
///
/// -
/// TA_CENTER
/// The reference point is aligned horizontally with the center of the bounding rectangle.
///
/// -
/// TA_LEFT
/// The reference point is on the left edge of the bounding rectangle.
///
/// -
/// TA_RIGHT
/// The reference point is on the right edge of the bounding rectangle.
///
/// -
/// TA_RTLREADING
///
/// Middle East language edition of Windows: The text is laid out in right to left reading order, as opposed to the default left to
/// right order. This only applies when the font selected into the device context is either Hebrew or Arabic.
///
///
/// -
/// TA_NOUPDATECP
/// The current position is not updated after each text output call.
///
/// -
/// TA_UPDATECP
/// The current position is updated after each text output call.
///
///
///
/// When the current font has a vertical default base line (as with Kanji), the following values are used instead of TA_BASELINE and TA_CENTER.
///
///
///
/// Value
/// Meaning
///
/// -
/// VTA_BASELINE
/// The reference point is on the base line of the text.
///
/// -
/// VTA_CENTER
/// The reference point is aligned vertically with the center of the bounding rectangle.
///
///
/// If the function fails, the return value is GDI_ERROR.
///
///
///
/// The bounding rectangle is a rectangle bounding all of the character cells in a string of text. Its dimensions can be obtained by
/// calling the GetTextExtentPoint32 function.
///
///
/// The text-alignment flags determine how the TextOut and ExtTextOut functions align a string of text in relation to the string's
/// reference point provided to TextOut or ExtTextOut.
///
///
/// The text-alignment flags are not necessarily single bit flags and may be equal to zero. The flags must be examined in groups of
/// related flags, as shown in the following list.
///
///
/// -
/// TA_LEFT, TA_RIGHT, and TA_CENTER
///
/// -
/// TA_BOTTOM, TA_TOP, and TA_BASELINE
///
/// -
/// TA_NOUPDATECP and TA_UPDATECP
///
///
/// If the current font has a vertical default base line, the related flags are as shown in the following list.
///
/// -
/// TA_LEFT, TA_RIGHT, and VTA_BASELINE
///
/// -
/// TA_BOTTOM, TA_TOP, and VTA_CENTER
///
/// -
/// TA_NOUPDATECP and TA_UPDATECP
///
///
/// To verify that a particular flag is set in the return value of this function:
///
/// -
/// Apply the bitwise OR operator to the flag and its related flags.
///
/// -
/// Apply the bitwise AND operator to the result and the return value.
///
/// -
/// Test for the equality of this result and the flag.
///
///
/// Examples
/// For an example, see Setting the Text Alignment.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gettextalign UINT GetTextAlign( HDC hdc );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "d3ec0350-2eb8-4843-88bb-d72cece710e7")]
public static extern TextAlign GetTextAlign(HDC hdc);
///
/// The GetTextCharacterExtra function retrieves the current intercharacter spacing for the specified device context.
///
/// Handle to the device context.
///
/// If the function succeeds, the return value is the current intercharacter spacing, in logical coordinates.
/// If the function fails, the return value is 0x8000000.
///
///
/// The intercharacter spacing defines the extra space, in logical units along the base line, that the TextOut or ExtTextOut
/// functions add to each character as a line is written. The spacing is used to expand lines of text.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gettextcharacterextra int GetTextCharacterExtra( HDC hdc );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "44d5145d-1c42-429e-89c4-dc31d275bc73")]
public static extern int GetTextCharacterExtra(HDC hdc);
/// The GetTextColor function retrieves the current text color for the specified device context.
/// Handle to the device context.
///
/// If the function succeeds, the return value is the current text color as a COLORREF value.
/// If the function fails, the return value is CLR_INVALID. No extended error information is available.
///
/// The text color defines the foreground color of characters drawn by using the TextOut or ExtTextOut function.
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gettextcolor COLORREF GetTextColor( HDC hdc );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "d3d91b86-5143-431a-ba18-b951b832d7b6")]
public static extern COLORREF GetTextColor(HDC hdc);
///
/// The GetTextExtentExPoint function retrieves the number of characters in a specified string that will fit within a
/// specified space and fills an array with the text extent for each of those characters. (A text extent is the distance between the
/// beginning of the space and a character that will fit in the space.) This information is useful for word-wrapping calculations.
///
/// A handle to the device context.
/// A pointer to the null-terminated string for which extents are to be retrieved.
///
/// The number of characters in the string pointed to by the lpszStr parameter. For an ANSI call it specifies the string length in
/// bytes and for a Unicode it specifies the string length in WORDs. Note that for the ANSI function, characters in SBCS code pages
/// take one byte each, while most characters in DBCS code pages take two bytes; for the Unicode function, most currently defined
/// Unicode characters (those in the Basic Multilingual Plane (BMP)) are one WORD while Unicode surrogates are two WORDs.
///
/// The maximum allowable width, in logical units, of the formatted string.
///
/// A pointer to an integer that receives a count of the maximum number of characters that will fit in the space specified by the
/// nMaxExtent parameter. When the lpnFit parameter is NULL, the nMaxExtent parameter is ignored.
///
///
///
/// A pointer to an array of integers that receives partial string extents. Each element in the array gives the distance, in logical
/// units, between the beginning of the string and one of the characters that fits in the space specified by the nMaxExtent
/// parameter. This array must have at least as many elements as characters specified by the cchString parameter because the entire
/// array is used internally. The function fills the array with valid extents for as many characters as are specified by the lpnFit
/// parameter. Any values in the rest of the array should be ignored. If alpDx is NULL, the function does not compute partial
/// string widths.
///
///
/// For complex scripts, where a sequence of characters may be represented by any number of glyphs, the values in the alpDx array up
/// to the number specified by the lpnFit parameter match one-to-one with code points. Again, you should ignore the rest of the
/// values in the alpDx array.
///
///
///
/// A pointer to a SIZE structure that receives the dimensions of the string, in logical units. This parameter cannot be NULL.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// If both the lpnFit and alpDx parameters are NULL, calling the GetTextExtentExPoint function is equivalent to
/// calling the GetTextExtentPoint function.
///
///
/// For the ANSI version of GetTextExtentExPoint, the lpDx array has the same number of INT values as there are bytes in
/// lpString. The INT values that correspond to the two bytes of a DBCS character are each the extent of the entire composite character.
///
///
/// Note, the alpDx values for GetTextExtentExPoint are not the same as the lpDx values for ExtTextOut. To use the alpDx
/// values in lpDx, you must first process them.
///
///
/// When this function returns the text extent, it assumes that the text is horizontal, that is, that the escapement is always 0.
/// This is true for both the horizontal and vertical measurements of the text. Even if you use a font that specifies a nonzero
/// escapement, this function doesn't use the angle while it computes the text extent. The app must convert it explicitly. However,
/// when the graphics mode is set to GM_ADVANCED and the character orientation is 90 degrees from the print orientation, the values
/// that this function return do not follow this rule. When the character orientation and the print orientation match for a given
/// string, this function returns the dimensions of the string in the SIZE structure as { cx : 116, cy : 18 }. When the character
/// orientation and the print orientation are 90 degrees apart for the same string, this function returns the dimensions of the
/// string in the SIZE structure as { cx : 18, cy : 116 }.
///
///
/// This function returns the extent of each successive character in a string. When these are rounded to logical units, you get
/// different results than what is returned from the GetCharWidth, which returns the width of each individual character rounded to
/// logical units.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gettextextentexpointa BOOL GetTextExtentExPointA( HDC hdc,
// LPCSTR lpszString, int cchString, int nMaxExtent, LPINT lpnFit, LPINT lpnDx, LPSIZE lpSize );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "b873a059-5aa3-47d0-b109-7acd542c7d79")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetTextExtentExPoint(HDC hdc, string lpszString, int cchString, int nMaxExtent, out int lpnFit, [Out] int[] lpnDx, out SIZE lpSize);
///
/// The GetTextExtentExPointI function retrieves the number of characters in a specified string that will fit within a
/// specified space and fills an array with the text extent for each of those characters. (A text extent is the distance between the
/// beginning of the space and a character that will fit in the space.) This information is useful for word-wrapping calculations.
///
/// A handle to the device context.
/// A pointer to an array of glyph indices for which extents are to be retrieved.
/// The number of glyphs in the array pointed to by the pgiIn parameter.
/// The maximum allowable width, in logical units, of the formatted string.
///
/// A pointer to an integer that receives a count of the maximum number of characters that will fit in the space specified by the
/// nMaxExtent parameter. When the lpnFit parameter is NULL, the nMaxExtent parameter is ignored.
///
///
/// A pointer to an array of integers that receives partial glyph extents. Each element in the array gives the distance, in logical
/// units, between the beginning of the glyph indices array and one of the glyphs that fits in the space specified by the nMaxExtent
/// parameter. Although this array should have at least as many elements as glyph indices specified by the cgi parameter, the
/// function fills the array with extents only for as many glyph indices as are specified by the lpnFit parameter. If lpnFit is
/// NULL, the function does not compute partial string widths.
///
///
/// A pointer to a SIZE structure that receives the dimensions of the glyph indices array, in logical units. This value cannot be NULL.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// If both the lpnFit and alpDx parameters are NULL, calling the GetTextExtentExPointI function is equivalent to
/// calling the GetTextExtentPointI function.
///
///
/// When this function returns the text extent, it assumes that the text is horizontal, that is, that the escapement is always 0.
/// This is true for both the horizontal and vertical measurements of the text. Even if you use a font that specifies a nonzero
/// escapement, this function doesn't use the angle while it computes the text extent. The app must convert it explicitly. However,
/// when the graphics mode is set to GM_ADVANCED and the character orientation is 90 degrees from the print orientation, the values
/// that this function return do not follow this rule. When the character orientation and the print orientation match for a given
/// string, this function returns the dimensions of the string in the SIZE structure as { cx : 116, cy : 18 }. When the character
/// orientation and the print orientation are 90 degrees apart for the same string, this function returns the dimensions of the
/// string in the SIZE structure as { cx : 18, cy : 116 }.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gettextextentexpointi BOOL GetTextExtentExPointI( HDC hdc,
// LPWORD lpwszString, int cwchString, int nMaxExtent, LPINT lpnFit, LPINT lpnDx, LPSIZE lpSize );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "d543ec43-f6f1-4463-b27d-a1abf1cf3961")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetTextExtentExPointI(HDC hdc, [In] ushort[] lpwszString, int cwchString, int nMaxExtent, out int lpnFit, [Out] int[] lpnDx, out SIZE lpSize);
///
/// The GetTextExtentPoint function computes the width and height of the specified string of text.
///
/// Note This function is provided only for compatibility with 16-bit versions of Windows. Applications should call the
/// GetTextExtentPoint32 function, which provides more accurate results.
///
///
/// A handle to the device context.
///
/// A pointer to the string that specifies the text. The string does not need to be zero-terminated, since cbString specifies the
/// length of the string.
///
/// The length of the string pointed to by lpString.
/// A pointer to a SIZE structure that receives the dimensions of the string, in logical units.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// The GetTextExtentPoint function uses the currently selected font to compute the dimensions of the string. The width and
/// height, in logical units, are computed without considering any clipping. Also, this function assumes that the text is horizontal,
/// that is, that the escapement is always 0. This is true for both the horizontal and vertical measurements of the text. Even if
/// using a font specifying a nonzero escapement, this function will not use the angle while computing the text extent. The
/// application must convert it explicitly.
///
///
/// Because some devices kern characters, the sum of the extents of the characters in a string may not be equal to the extent of the string.
///
/// The calculated string width takes into account the intercharacter spacing set by the SetTextCharacterExtra function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gettextextentpointa BOOL GetTextExtentPointA( HDC hdc, LPCSTR
// lpString, int c, LPSIZE lpsz );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "731085ce-009d-42e1-885f-2f5151e0f6d3")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetTextExtentPoint(HDC hdc, string lpString, int c, out SIZE lpsz);
/// The GetTextExtentPoint32 function computes the width and height of the specified string of text.
/// A handle to the device context.
///
/// A pointer to a buffer that specifies the text string. The string does not need to be null-terminated, because the c parameter
/// specifies the length of the string.
///
/// The length of the string pointed to by lpString.
/// A pointer to a SIZE structure that receives the dimensions of the string, in logical units.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// The GetTextExtentPoint32 function uses the currently selected font to compute the dimensions of the string. The width and
/// height, in logical units, are computed without considering any clipping.
///
///
/// Because some devices kern characters, the sum of the extents of the characters in a string may not be equal to the extent of the string.
///
///
/// The calculated string width takes into account the intercharacter spacing set by the SetTextCharacterExtra function and the
/// justification set by SetTextJustification. This is true for both displaying on a screen and for printing. However, if lpDx is set
/// in ExtTextOut, GetTextExtentPoint32 does not take into account either intercharacter spacing or justification. In
/// addition, for EMF, the print result always takes both intercharacter spacing and justification into account.
///
///
/// When dealing with text displayed on a screen, the calculated string width takes into account the intercharacter spacing set by
/// the SetTextCharacterExtra function and the justification set by SetTextJustification. However, if lpDx is set in ExtTextOut,
/// GetTextExtentPoint32 does not take into account either intercharacter spacing or justification. However, when printing
/// with EMF:
///
///
/// -
/// The print result ignores intercharacter spacing, although GetTextExtentPoint32 takes it into account.
///
/// -
/// The print result takes justification into account, although GetTextExtentPoint32 ignores it.
///
///
///
/// When this function returns the text extent, it assumes that the text is horizontal, that is, that the escapement is always 0.
/// This is true for both the horizontal and vertical measurements of the text. Even if you use a font that specifies a nonzero
/// escapement, this function doesn't use the angle while it computes the text extent. The app must convert it explicitly. However,
/// when the graphics mode is set to GM_ADVANCED and the character orientation is 90 degrees from the print orientation, the values
/// that this function return do not follow this rule. When the character orientation and the print orientation match for a given
/// string, this function returns the dimensions of the string in the SIZE structure as { cx : 116, cy : 18 }. When the character
/// orientation and the print orientation are 90 degrees apart for the same string, this function returns the dimensions of the
/// string in the SIZE structure as { cx : 18, cy : 116 }.
///
///
/// GetTextExtentPoint32 doesn't consider "\n" (new line) or "\r\n" (carriage return and new line) characters when it computes
/// the height of a text string.
///
/// Examples
/// For an example, see Drawing Text from Different Fonts on the Same Line.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gettextextentpoint32a BOOL GetTextExtentPoint32A( HDC hdc,
// LPCSTR lpString, int c, LPSIZE psizl );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "530280ee-dfd8-4905-9b72-6c19efcff133")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetTextExtentPoint32(HDC hdc, string lpString, int c, out SIZE psizl);
/// The GetTextExtentPointI function computes the width and height of the specified array of glyph indices.
/// Handle to the device context.
/// Pointer to array of glyph indices.
/// Specifies the number of glyph indices.
/// Pointer to a SIZE structure that receives the dimensions of the string, in logical units.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// The GetTextExtentPointI function uses the currently selected font to compute the dimensions of the array of glyph indices.
/// The width and height, in logical units, are computed without considering any clipping.
///
///
/// When this function returns the text extent, it assumes that the text is horizontal, that is, that the escapement is always 0.
/// This is true for both the horizontal and vertical measurements of the text. Even if you use a font that specifies a nonzero
/// escapement, this function doesn't use the angle while it computes the text extent. The app must convert it explicitly. However,
/// when the graphics mode is set to GM_ADVANCED and the character orientation is 90 degrees from the print orientation, the values
/// that this function return do not follow this rule. When the character orientation and the print orientation match for a given
/// string, this function returns the dimensions of the string in the SIZE structure as { cx : 116, cy : 18 }. When the character
/// orientation and the print orientation are 90 degrees apart for the same string, this function returns the dimensions of the
/// string in the SIZE structure as { cx : 18, cy : 116 }.
///
///
/// Because some devices kern characters, the sum of the extents of the individual glyph indices may not be equal to the extent of
/// the entire array of glyph indices.
///
/// The calculated string width takes into account the intercharacter spacing set by the SetTextCharacterExtra function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gettextextentpointi BOOL GetTextExtentPointI( HDC hdc, LPWORD
// pgiIn, int cgi, LPSIZE psize );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "d06a48dd-3f38-4c60-a4c6-954e43f718d1")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetTextExtentPointI(HDC hdc, [In] ushort[] pgiIn, int cgi, out SIZE psize);
///
/// The GetTextFace function retrieves the typeface name of the font that is selected into the specified device context.
///
/// A handle to the device context.
///
/// The length of the buffer pointed to by lpFaceName. For the ANSI function it is a BYTE count and for the Unicode function it is a
/// WORD count. Note that for the ANSI function, characters in SBCS code pages take one byte each, while most characters in DBCS code
/// pages take two bytes; for the Unicode function, most currently defined Unicode characters (those in the Basic Multilingual Plane
/// (BMP)) are one WORD while Unicode surrogates are two WORDs.
///
///
/// A pointer to the buffer that receives the typeface name. If this parameter is NULL, the function returns the number of
/// characters in the name, including the terminating null character.
///
///
/// If the function succeeds, the return value is the number of characters copied to the buffer.
/// If the function fails, the return value is zero.
///
///
/// The typeface name is copied as a null-terminated character string.
/// If the name is longer than the number of characters specified by the nCount parameter, the name is truncated.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gettextfacea int GetTextFaceA( HDC hdc, int c, LPSTR lpName );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "c4c8c8f5-3651-481b-a55f-da7f49d92f3a")]
public static extern int GetTextFace(HDC hdc, int c, [Optional] StringBuilder lpName);
/// The GetTextMetrics function fills the specified buffer with the metrics for the currently selected font.
/// A handle to the device context.
/// A pointer to the TEXTMETRIC structure that receives the text metrics.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// To determine whether a font is a TrueType font, first select it into a DC, then call GetTextMetrics, and then check for
/// TMPF_TRUETYPE in TEXTMETRIC.tmPitchAndFamily. Note that GetDC returns an uninitialized DC, which has "System" (a bitmap font) as
/// the default font; thus the need to select a font into the DC.
///
/// Examples
///
/// For an example, see "Displaying Keyboard Input" in Using Keyboard Input or Drawing Text from Different Fonts on the Same Line.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-gettextmetricsa BOOL GetTextMetricsA( HDC hdc, LPTEXTMETRICA
// lptm );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "92d45a3b-12df-42ff-8d87-5c27b44dc481")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetTextMetrics(HDC hdc, out TEXTMETRIC lptm);
///
/// The PolyTextOut function draws several strings using the font and text colors currently selected in the specified device context.
///
/// A handle to the device context.
///
/// A pointer to an array of POLYTEXT structures describing the strings to be drawn. The array contains one structure for each string
/// to be drawn.
///
/// The number of POLYTEXT structures in the pptxt array.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// Each POLYTEXT structure contains the coordinates of a reference point that Windows uses to align the corresponding string of
/// text. An application can specify how the reference point is used by calling the SetTextAlign function. An application can
/// determine the current text-alignment setting for the specified device context by calling the GetTextAlign function.
///
/// To draw a single string of text, the application should call the ExtTextOut function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-polytextouta BOOL PolyTextOutA( HDC hdc, const POLYTEXTA *ppt,
// int nstrings );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "643b4f6a-843f-4795-adc8-a90223bdc246")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PolyTextOut(HDC hdc, [In] POLYTEXT[] ppt, int nstrings);
/// The RemoveFontMemResourceEx function removes the fonts added from a memory image file.
/// A handle to the font-resource. This handle is returned by the AddFontMemResourceEx function.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. No extended error information is available.
///
///
/// This function removes a font that was added by the AddFontMemResourceEx function. To remove the font, specify the same path and
/// flags as were used in AddFontMemResourceEx. This function will only remove the font that is specified by fh.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-removefontmemresourceex BOOL RemoveFontMemResourceEx( HANDLE h );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "b73c3f1d-c508-418c-a5a2-105a35ec3a9b")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool RemoveFontMemResourceEx(HANDLE h);
///
/// The RemoveFontResource function removes the fonts in the specified file from the system font table.
/// If the font was added using the AddFontResourceEx function, you must use the RemoveFontResourceEx function.
///
/// A pointer to a null-terminated string that names a font resource file.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// We recommend that if an app adds or removes fonts from the system font table that it notify other windows of the change by
/// sending a WM_FONTCHANGE message to all top-level windows in the system. The app sends this message by calling the SendMessage
/// function with the hwnd parameter set to HWND_BROADCAST.
///
///
/// If there are outstanding references to a font, the associated resource remains loaded until no device context is using it.
/// Furthermore, if the font is listed in the font registry ( HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
/// NT\CurrentVersion\Fonts) and is installed to any location other than the %windir%\fonts\ folder, it may be loaded into other
/// active sessions (including session 0).
///
///
/// When you try to replace an existing font file that contains a font with outstanding references to it, you might get an error that
/// indicates that the original font can't be deleted because it’s in use even after you call RemoveFontResource. If your app
/// requires that the font file be replaced, to reduce the resource count of the original font to zero, call
/// RemoveFontResource in a loop as shown in this example code. If you continue to get errors, this is an indication that the
/// font file remains loaded in other sessions. Make sure the font isn't listed in the font registry and restart the system to ensure
/// the font is unloaded from all sessions.
///
///
/// Note Apps where the original font file is in use will still be able to access the original file and won't use the new font
/// until the font reloads. Call AddFontResource to reload the font. We recommend that you call AddFontResource the same
/// number of times as the call to RemoveFontResource succeeded as shown in this example code.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-removefontresourcea BOOL RemoveFontResourceA( LPCSTR
// lpFileName );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "ccc0ac8b-e373-47a9-a362-64fd79a33d0c")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool RemoveFontResource(string lpFileName);
/// The RemoveFontResourceEx function removes the fonts in the specified file from the system font table.
/// A pointer to a null-terminated string that names a font resource file.
///
/// The characteristics of the font to be removed from the system. In order for the font to be removed, the flags used must be the
/// same as when the font was added with the AddFontResourceEx function. See the function for more information.
///
/// Reserved. Must be zero.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. No extended error information is available.
///
///
///
/// This function will only remove the font if the flags specified are the same as when then font was added with the
/// AddFontResourceEx function.
///
///
/// When you try to replace an existing font file that contains a font with outstanding references to it, you might get an error that
/// indicates that the original font can't be deleted because it’s in use even after you call RemoveFontResourceEx. If your
/// app requires that the font file be replaced, to reduce the resource count of the original font to zero, call
/// RemoveFontResourceEx in a loop as shown in this example code. If you continue to get errors, this is an indication that
/// the font file remains loaded in other sessions. Make sure the font isn't listed in the font registry and restart the system to
/// ensure the font is unloaded from all sessions.
///
///
/// Note Apps where the original font file is in use will still be able to access the original file and won't use the new font
/// until the font reloads. Call AddFontResourceEx to reload the font. We recommend that you call AddFontResourceEx the same
/// number of times as the call to RemoveFontResourceEx succeeded as shown in this example code.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-removefontresourceexa BOOL RemoveFontResourceExA( LPCSTR name,
// DWORD fl, PVOID pdv );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "18056fe7-1efe-428e-a828-3217c53371eb")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool RemoveFontResourceEx(string name, FR fl, IntPtr pdv = default);
///
/// The SetMapperFlags function alters the algorithm the font mapper uses when it maps logical fonts to physical fonts.
///
/// A handle to the device context that contains the font-mapper flag.
///
/// Specifies whether the font mapper should attempt to match a font's aspect ratio to the current device's aspect ratio. If bit zero
/// is set, the mapper selects only matching fonts.
///
///
/// If the function succeeds, the return value is the previous value of the font-mapper flag.
/// If the function fails, the return value is GDI_ERROR.
///
///
///
/// If the dwFlag parameter is set and no matching fonts exist, Windows chooses a new aspect ratio and retrieves a font that matches
/// this ratio.
///
/// The remaining bits of the dwFlag parameter must be zero.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setmapperflags DWORD SetMapperFlags( HDC hdc, DWORD flags );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "74cfe0d3-0d20-4382-8e76-55a6e2323308")]
public static extern uint SetMapperFlags(HDC hdc, uint flags);
/// The SetTextAlign function sets the text-alignment flags for the specified device context.
/// A handle to the device context.
///
///
/// The text alignment by using a mask of the values in the following list. Only one flag can be chosen from those that affect
/// horizontal and vertical alignment. In addition, only one of the two flags that alter the current position can be chosen.
///
///
///
/// Value
/// Meaning
///
/// -
/// TA_BASELINE
/// The reference point will be on the base line of the text.
///
/// -
/// TA_BOTTOM
/// The reference point will be on the bottom edge of the bounding rectangle.
///
/// -
/// TA_TOP
/// The reference point will be on the top edge of the bounding rectangle.
///
/// -
/// TA_CENTER
/// The reference point will be aligned horizontally with the center of the bounding rectangle.
///
/// -
/// TA_LEFT
/// The reference point will be on the left edge of the bounding rectangle.
///
/// -
/// TA_RIGHT
/// The reference point will be on the right edge of the bounding rectangle.
///
/// -
/// TA_NOUPDATECP
/// The current position is not updated after each text output call. The reference point is passed to the text output function.
///
/// -
/// TA_RTLREADING
///
/// Middle East language edition of Windows: The text is laid out in right to left reading order, as opposed to the default left to
/// right order. This applies only when the font selected into the device context is either Hebrew or Arabic.
///
///
/// -
/// TA_UPDATECP
/// The current position is updated after each text output call. The current position is used as the reference point.
///
///
///
/// When the current font has a vertical default base line, as with Kanji, the following values must be used instead of TA_BASELINE
/// and TA_CENTER.
///
///
///
/// Value
/// Meaning
///
/// -
/// VTA_BASELINE
/// The reference point will be on the base line of the text.
///
/// -
/// VTA_CENTER
/// The reference point will be aligned vertically with the center of the bounding rectangle.
///
///
/// The default values are TA_LEFT, TA_TOP, and TA_NOUPDATECP.
///
///
/// If the function succeeds, the return value is the previous text-alignment setting.
/// If the function fails, the return value is GDI_ERROR.
///
///
///
/// The TextOut and ExtTextOut functions use the text-alignment flags to position a string of text on a display or other device. The
/// flags specify the relationship between a reference point and a rectangle that bounds the text. The reference point is either the
/// current position or a point passed to a text output function.
///
/// The rectangle that bounds the text is formed by the character cells in the text string.
/// The best way to get left-aligned text is to use either
/// or
/// You can also use SetTextAlign (hdc, TA_LEFT) for this purpose, but this loses any vertical or right-to-left settings.
///
/// Note You should not use SetTextAlign with TA_UPDATECP when you are using ScriptStringOut, because selected text is
/// not rendered correctly. If you must use this flag, you can unset and reset it as necessary to avoid the problem.
///
/// Examples
/// For an example, see Setting the Text Alignment.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-settextalign UINT SetTextAlign( HDC hdc, UINT align );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "422868c5-14c9-4374-9cc5-b7bf91ab9eb4")]
public static extern TextAlign SetTextAlign(HDC hdc, TextAlign align);
///
/// The SetTextCharacterExtra function sets the intercharacter spacing. Intercharacter spacing is added to each character,
/// including break characters, when the system writes a line of text.
///
/// A handle to the device context.
///
/// The amount of extra space, in logical units, to be added to each character. If the current mapping mode is not MM_TEXT, the
/// nCharExtra parameter is transformed and rounded to the nearest pixel.
///
///
/// If the function succeeds, the return value is the previous intercharacter spacing.
/// If the function fails, the return value is 0x80000000.
///
///
///
/// This function is supported mainly for compatibility with existing applications. New applications should generally avoid calling
/// this function, because it is incompatible with complex scripts (scripts that require text shaping; Arabic script is an example of this).
///
///
/// The recommended approach is that instead of calling this function and then TextOut, applications should call ExtTextOut and use
/// its lpDx parameter to supply widths.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-settextcharacterextra int SetTextCharacterExtra( HDC hdc, int
// extra );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "83b7d225-4fb9-4c75-bc4a-e1bea7f901f1")]
public static extern int SetTextCharacterExtra(HDC hdc, int extra);
/// The SetTextColor function sets the text color for the specified device context to the specified color.
/// A handle to the device context.
/// The color of the text.
///
/// If the function succeeds, the return value is a color reference for the previous text color as a COLORREF value.
/// If the function fails, the return value is CLR_INVALID.
///
///
///
/// The text color is used to draw the face of each character written by the TextOut and ExtTextOut functions. The text color is also
/// used in converting bitmaps from color to monochrome and vice versa.
///
/// Examples
/// For an example, see "Setting Fonts for Menu-Item Text Strings" in Using Menus.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-settextcolor COLORREF SetTextColor( HDC hdc, COLORREF color );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "3875a247-7c32-4917-bf6d-50b2a49848a6")]
public static extern COLORREF SetTextColor(HDC hdc, COLORREF color);
///
/// The SetTextJustification function specifies the amount of space the system should add to the break characters in a string
/// of text. The space is added when an application calls the TextOut or ExtTextOut functions.
///
/// A handle to the device context.
///
/// The total extra space, in logical units, to be added to the line of text. If the current mapping mode is not MM_TEXT, the value
/// identified by the nBreakExtra parameter is transformed and rounded to the nearest pixel.
///
/// The number of break characters in the line.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// The break character is usually the space character (ASCII 32), but it may be defined by a font as some other character. The
/// GetTextMetrics function can be used to retrieve a font's break character.
///
/// The TextOut function distributes the specified extra space evenly among the break characters in the line.
///
/// The GetTextExtentPoint32 function is always used with the SetTextJustification function. Sometimes the
/// GetTextExtentPoint32 function takes justification into account when computing the width of a specified line before
/// justification, and sometimes it does not. For more details on this, see GetTextExtentPoint32. This width must be known
/// before an appropriate nBreakExtra value can be computed.
///
///
/// SetTextJustification can be used to justify a line that contains multiple strings in different fonts. In this case, each
/// string must be justified separately.
///
///
/// Because rounding errors can occur during justification, the system keeps a running error term that defines the current error
/// value. When justifying a line that contains multiple runs, GetTextExtentPoint automatically uses this error term when it computes
/// the extent of the next run, allowing TextOut to blend the error into the new run. After each line has been justified, this error
/// term must be cleared to prevent it from being incorporated into the next line. The term can be cleared by calling
/// SetTextJustification with nBreakExtra set to zero.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-settextjustification BOOL SetTextJustification( HDC hdc, int
// extra, int count );
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("wingdi.h", MSDNShortId = "55fb5a28-b7da-40d8-8e64-4b42c23fa8b1")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetTextJustification(HDC hdc, int extra, int count);
///
/// The TextOut function writes a character string at the specified location, using the currently selected font, background
/// color, and text color.
///
/// A handle to the device context.
/// The x-coordinate, in logical coordinates, of the reference point that the system uses to align the string.
/// The y-coordinate, in logical coordinates, of the reference point that the system uses to align the string.
///
/// A pointer to the string to be drawn. The string does not need to be zero-terminated, because cchString specifies the length of
/// the string.
///
/// The length of the string pointed to by lpString, in characters.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// The interpretation of the reference point depends on the current text-alignment mode. An application can retrieve this mode by
/// calling the GetTextAlign function; an application can alter this mode by calling the SetTextAlign function. You can use the
/// following values for text alignment. Only one flag can be chosen from those that affect horizontal and vertical alignment. In
/// addition, only one of the two flags that alter the current position can be chosen.
///
///
///
/// Term
/// Description
///
/// -
/// TA_BASELINE
/// The reference point will be on the base line of the text.
///
/// -
/// TA_BOTTOM
/// The reference point will be on the bottom edge of the bounding rectangle.
///
/// -
/// TA_TOP
/// The reference point will be on the top edge of the bounding rectangle.
///
/// -
/// TA_CENTER
/// The reference point will be aligned horizontally with the center of the bounding rectangle.
///
/// -
/// TA_LEFT
/// The reference point will be on the left edge of the bounding rectangle.
///
/// -
/// TA_RIGHT
/// The reference point will be on the right edge of the bounding rectangle.
///
/// -
/// TA_NOUPDATECP
/// The current position is not updated after each text output call. The reference point is passed to the text output function.
///
/// -
/// TA_RTLREADING
///
/// Middle East language edition of Windows: The text is laid out in right to left reading order, as opposed to the default left to
/// right order. This applies only when the font selected into the device context is either Hebrew or Arabic.
///
///
/// -
/// TA_UPDATECP
/// The current position is updated after each text output call. The current position is used as the reference point.
///
///
///
/// By default, the current position is not used or updated by this function. However, an application can call the SetTextAlign
/// function with the fMode parameter set to TA_UPDATECP to permit the system to use and update the current position each time the
/// application calls TextOut for a specified device context. When this flag is set, the system ignores the nXStart and
/// nYStart parameters on subsequent TextOut calls.
///
///
/// When the TextOut function is placed inside a path bracket, the system generates a path for the TrueType text that includes
/// each character plus its character box. The region generated is the character box minus the text, rather than the text itself. You
/// can obtain the region enclosed by the outline of the TrueType text by setting the background mode to transparent before placing
/// the TextOut function in the path bracket. Following is sample code that demonstrates this procedure.
///
/// Examples
/// For an example, see Enumerating the Installed Fonts.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-textouta BOOL TextOutA( HDC hdc, int x, int y, LPCSTR
// lpString, int c );
[DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("wingdi.h", MSDNShortId = "0c437ff8-3893-4dc3-827b-fa9ce4bcd7e6")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool TextOut(HDC hdc, int x, int y, string lpString, int c);
/// The ABC structure contains the width of a character in a TrueType font.
///
/// The total width of a character is the summation of the A, B, and C spaces. Either the A or the C space can be negative to
/// indicate underhangs or overhangs.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-abc typedef struct _ABC { int abcA; UINT abcB; int abcC; }
// ABC, *PABC, *NPABC, *LPABC;
[PInvokeData("wingdi.h", MSDNShortId = "00000000-0000-0000-0000-000000000001")]
[StructLayout(LayoutKind.Sequential)]
public struct ABC
{
///
/// The A spacing of the character. The A spacing is the distance to add to the current position before drawing the character glyph.
///
public int abcA;
/// The B spacing of the character. The B spacing is the width of the drawn portion of the character glyph.
public uint abcB;
///
/// The C spacing of the character. The C spacing is the distance to add to the current position to provide white space to the
/// right of the character glyph.
///
public int abcC;
}
/// The ABCFLOAT structure contains the A, B, and C widths of a font character.
///
/// The A, B, and C widths are measured along the base line of the font.
///
/// The character increment (total width) of a character is the sum of the A, B, and C spaces. Either the A or the C space can be
/// negative to indicate underhangs or overhangs.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-abcfloat typedef struct _ABCFLOAT { FLOAT abcfA; FLOAT abcfB;
// FLOAT abcfC; } ABCFLOAT, *PABCFLOAT, *NPABCFLOAT, *LPABCFLOAT;
[PInvokeData("wingdi.h", MSDNShortId = "540bb00c-f0e2-4ddd-98d1-cf3ed86b6ce0")]
[StructLayout(LayoutKind.Sequential)]
public struct ABCFLOAT
{
///
/// The A spacing of the character. The A spacing is the distance to add to the current position before drawing the character glyph.
///
public float abcfA;
/// The B spacing of the character. The B spacing is the width of the drawn portion of the character glyph.
public float abcfB;
///
/// The C spacing of the character. The C spacing is the distance to add to the current position to provide white space to the
/// right of the character glyph.
///
public float abcfC;
}
/// The AXESLIST structure contains information on all the axes of a multiple master font.
///
/// The PostScript Open Type Font does not support multiple master functionality.
///
/// The information on the axes of a multiple master font are specified by the AXISINFO structures. The axlNumAxes member
/// specifies the actual size of axlAxisInfo, while MM_MAX_NUMAXES, which equals 16, is the maximum allowed size of axlAxisInfo.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-axeslista typedef struct tagAXESLISTA { DWORD axlReserved;
// DWORD axlNumAxes; AXISINFOA axlAxisInfo[MM_MAX_NUMAXES]; } AXESLISTA, *PAXESLISTA, *LPAXESLISTA;
[PInvokeData("wingdi.h", MSDNShortId = "f95f012e-f02b-46c1-94ba-69f426ee7ad9")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct AXESLIST
{
/// Reserved. Must be STAMP_AXESLIST.
public uint axlReserved;
/// Number of axes for a specified multiple master font.
public uint axlNumAxes;
///
/// An array of AXISINFO structures. Each AXISINFO structure contains information on an axis of a specified multiple
/// master font. This corresponds to the dvValues array in the DESIGNVECTOR structure.
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public AXISINFO[] axlAxisInfo;
}
/// The AXISINFO structure contains information about an axis of a multiple master font.
///
///
/// The AXISINFO structure contains the name of an axis in a multiple master font and also the minimum and maximum possible
/// values for the axis. The length of the name is MM_MAX_AXES_NAMELEN, which equals 16. An application queries these values before
/// setting its desired values in the DESIGNVECTOR array.
///
/// The PostScript Open Type Font does not support multiple master functionality.
/// For the ANSI version of this structure, axAxisName must be an array of bytes.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-axisinfoa typedef struct tagAXISINFOA { LONG axMinValue; LONG
// axMaxValue; BYTE axAxisName[MM_MAX_AXES_NAMELEN]; } AXISINFOA, *PAXISINFOA, *LPAXISINFOA;
[PInvokeData("wingdi.h", MSDNShortId = "a947618e-4b50-453a-82d5-5a6f825faebb")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct AXISINFO
{
/// The minimum value for this axis.
public int axMinValue;
/// The maximum value for this axis.
public int axMaxValue;
/// The name of the axis, specified as an array of characters.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string axAxisName;
}
///
/// The DESIGNVECTOR structure is used by an application to specify values for the axes of a multiple master font.
///
///
///
/// The dvNumAxes member determines the actual size of dvValues, and thus, of DESIGNVECTOR. The constant
/// MM_MAX_NUMAXES, which is 16, specifies the maximum allowed size of the dvValues array.
///
/// The PostScript Open Type Font does not support multiple master functionality.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-designvector typedef struct tagDESIGNVECTOR { DWORD
// dvReserved; DWORD dvNumAxes; LONG dvValues[MM_MAX_NUMAXES]; } DESIGNVECTOR, *PDESIGNVECTOR, *LPDESIGNVECTOR;
[PInvokeData("wingdi.h", MSDNShortId = "aeff9901-2405-44aa-ba46-8d784afd6b76")]
[StructLayout(LayoutKind.Sequential)]
public struct DESIGNVECTOR
{
/// Reserved. Must be STAMP_DESIGNVECTOR.
public uint dvReserved;
/// Number of values in the dvValues array.
public uint dvNumAxes;
///
/// An array specifying the values of the axes of a multiple master OpenType font. This array corresponds to the
/// axlAxisInfo array in the AXESLIST structure.
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public int[] dvValues;
}
///
/// The ENUMLOGFONT structure defines the attributes of a font, the complete name of a font, and the style of a font.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-enumlogfonta typedef struct tagENUMLOGFONTA { LOGFONTA
// elfLogFont; BYTE elfFullName[LF_FULLFACESIZE]; BYTE elfStyle[LF_FACESIZE]; } ENUMLOGFONTA, *LPENUMLOGFONTA;
[PInvokeData("wingdi.h", MSDNShortId = "cfae9e97-c714-40fb-88ab-95e12ea3ffa9")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct ENUMLOGFONT
{
/// A LOGFONT structure that defines the attributes of a font.
public LOGFONT elfLogFont;
/// A unique name for the font. For example, ABCD Font Company TrueType Bold Italic Sans Serif.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public string elfFullName;
/// The style of the font. For example, Bold Italic.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string elfStyle;
}
/// The ENUMLOGFONTEX structure contains information about an enumerated font.
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-enumlogfontexw typedef struct tagENUMLOGFONTEXW { LOGFONTW
// elfLogFont; WCHAR elfFullName[LF_FULLFACESIZE]; WCHAR elfStyle[LF_FACESIZE]; WCHAR elfScript[LF_FACESIZE]; } ENUMLOGFONTEXW, *LPENUMLOGFONTEXW;
[PInvokeData("wingdi.h", MSDNShortId = "2e848e47-5b5f-46ad-9963-55d6bb6748a9")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct ENUMLOGFONTEX
{
/// A LOGFONT structure that contains values defining the font attributes.
public LOGFONT elfLogFont;
/// The unique name of the font. For example, ABC Font Company TrueType Bold Italic Sans Serif.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = LF_FULLFACESIZE)]
public string elfFullName;
/// The style of the font. For example, Bold Italic.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = LF_FACESIZE)]
public string elfStyle;
/// The script, that is, the character set, of the font. For example, Cyrillic.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = LF_FACESIZE)]
public string elfScript;
}
/// The ENUMLOGFONTEXDV structure contains the information used to create a font.
///
///
/// The actual size of ENUMLOGFONTEXDV depends on that of DESIGNVECTOR, which, in turn depends on its dvNumAxes member.
///
///
/// The EnumFonts, EnumFontFamilies, and EnumFontFamiliesEx functions have been modified to return pointers to ENUMTEXTMETRIC and
/// ENUMLOGFONTEXDV to the callback function.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-enumlogfontexdva typedef struct tagENUMLOGFONTEXDVA {
// ENUMLOGFONTEXA elfEnumLogfontEx; DESIGNVECTOR elfDesignVector; } ENUMLOGFONTEXDVA, *PENUMLOGFONTEXDVA, *LPENUMLOGFONTEXDVA;
[PInvokeData("wingdi.h", MSDNShortId = "8d483f52-250e-4c4f-83cf-ff952bb84fd3")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct ENUMLOGFONTEXDV
{
/// An ENUMLOGFONTEX structure that contains information about the logical attributes of the font.
public ENUMLOGFONTEX elfEnumLogfontEx;
/// A DESIGNVECTOR structure. This is zero-filled unless the font described is a multiple master OpenType font.
public DESIGNVECTOR elfDesignVector;
}
/// The ENUMTEXTMETRIC structure contains information about a physical font.
///
/// ENUMTEXTMETRIC is an extension of NEWTEXTMETRICEX that includes the axis information for a multiple master font.
///
/// The EnumFonts, EnumFontFamilies, and EnumFontFamiliesEx functions have been modified to return pointers to the
/// ENUMTEXTMETRIC and ENUMLOGFONTEXDV structures.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-enumtextmetrica typedef struct tagENUMTEXTMETRICA {
// NEWTEXTMETRICEXA etmNewTextMetricEx; AXESLISTA etmAxesList; } ENUMTEXTMETRICA, *PENUMTEXTMETRICA, *LPENUMTEXTMETRICA;
[PInvokeData("wingdi.h", MSDNShortId = "deb81846-3ada-4c88-8c26-74224538d282")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct ENUMTEXTMETRIC
{
/// A NEWTEXTMETRICEX structure, containing information about a physical font.
public NEWTEXTMETRICEX etmNewTextMetricEx;
///
/// An AXESLIST structure, containing information about the axes for the font. This is only used for multiple master fonts.
///
public AXESLIST etmAxesList;
}
/// The FIXED structure contains the integral and fractional parts of a fixed-point real number.
/// The FIXED structure is used to describe the elements of the MAT2 structure.
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-fixed typedef struct _FIXED { #if ... WORD fract; #if ...
// short value; #else short value; #endif #else WORD fract; #endif } FIXED;
[PInvokeData("wingdi.h", MSDNShortId = "b1d94060-e822-447f-82ba-fd1cf2ddaa3b")]
[StructLayout(LayoutKind.Sequential)]
public struct FIXED
{
/// The integral value.
public short value;
/// The fractional value.
public ushort fract;
/// Performs an implicit conversion from to .
/// The FIXED instance.
/// The result of the conversion.
public static implicit operator decimal(FIXED f) => decimal.Parse($"{f.value.ToString(NumberFormatInfo.InvariantInfo)}{NumberFormatInfo.InvariantInfo.NumberDecimalSeparator}{f.fract.ToString(NumberFormatInfo.InvariantInfo)}", NumberFormatInfo.InvariantInfo);
/// Performs an implicit conversion from to .
/// The decimal value.
/// The result of the conversion.
public static implicit operator FIXED(decimal d) => new FIXED { value = (short)Math.Truncate(d), fract = ushort.Parse(d.ToString(NumberFormatInfo.InvariantInfo).Split(new[] { NumberFormatInfo.InvariantInfo.NumberDecimalSeparator }, StringSplitOptions.None)[1], NumberFormatInfo.InvariantInfo) };
/// Converts to string.
/// A that represents this instance.
public override string ToString() => ((decimal)this).ToString();
}
/// Contains information identifying the code pages and Unicode subranges for which a given font provides glyphs.
///
/// 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.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-fontsignature typedef struct tagFONTSIGNATURE { DWORD
// fsUsb[4]; DWORD fsCsb[2]; } FONTSIGNATURE, *PFONTSIGNATURE, *LPFONTSIGNATURE;
[PInvokeData("wingdi.h", MSDNShortId = "5331da53-7e3d-46e9-a922-da04fedc8382")]
[StructLayout(LayoutKind.Sequential)]
public struct FONTSIGNATURE
{
///
/// 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.
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public uint[] fsUsb;
///
/// 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.
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public uint[] fsCsb;
}
///
/// The GCP_RESULTS structure contains information about characters in a string. This structure receives the results of the
/// GetCharacterPlacement function. For some languages, the first element in the arrays may contain more, language-dependent information.
///
///
///
/// Whether the lpGlyphs, lpOutString, or neither is required depends on the results of the GetFontLanguageInfo call.
///
///
/// In the case of a font for a language such as English, in which none of the GCP_DBCS, GCP_REORDER, GCP_GLYPHSHAPE, GCP_LIGATE,
/// GCP_DIACRITIC, or GCP_KASHIDA flags are returned, neither of the arrays is required for proper operation. (Though not required,
/// they can still be used. If the lpOutString array is used, it will be exactly the same as the lpInputString passed to
/// GetCharacterPlacement.) Note, however, that if GCP_MAXEXTENT is used, then lpOutString will contain the truncated string
/// if it is used, NOT an exact copy of the original.
///
///
/// In the case of fonts for languages such as Hebrew, which DO have reordering but do not typically have extra glyph shapes,
/// lpOutString should be used. This will give the string on the screen-readable order. However, the lpGlyphs array is
/// not typically needed. (Hebrew can have extra glyphs, if the font is a TrueType/Open font.)
///
///
/// In the case of languages such as Thai or Arabic, in which GetFontLanguageInfo returns the GCP_GLYPHSHAPE flag, the
/// lpOutString will give the display-readable order of the string passed to GetCharacterPlacement, but the values will still
/// be the unshaped characters. For proper display, the lpGlyphs array must be used.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-gcp_resultsa typedef struct tagGCP_RESULTSA { DWORD
// lStructSize; LPSTR lpOutString; UINT *lpOrder; int *lpDx; int *lpCaretPos; LPSTR lpClass; LPWSTR lpGlyphs; UINT nGlyphs; int
// nMaxFit; } GCP_RESULTSA, *LPGCP_RESULTSA;
[PInvokeData("wingdi.h", MSDNShortId = "7692637e-963a-4e0a-8a04-e05a6d01c417")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct GCP_RESULTS
{
/// The size, in bytes, of the structure.
public uint lStructSize;
///
/// A pointer to the buffer that receives the output string or is NULL if the output string is not needed. The output
/// string is a version of the original string that is in the order that will be displayed on a specified device. Typically the
/// output string is identical to the original string, but may be different if the string needs reordering and the GCP_REORDER
/// flag is set or if the original string exceeds the maximum extent and the GCP_MAXEXTENT flag is set.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string lpOutString;
///
///
/// A pointer to the array that receives ordering indexes or is NULL if the ordering indexes are not needed. However, its
/// meaning depends on the other elements of GCP_RESULTS. If glyph indexes are to be returned, the indexes are for the
/// lpGlyphs array; if glyphs indexes are not returned and lpOrder is requested, the indexes are for
/// lpOutString. For example, in the latter case the value of lpOrder[i] is the position of lpString[i] in
/// the output string lpOutString.
///
///
/// This is typically used when GetFontLanguageInfo returns the GCP_REORDER flag, which indicates that the original string needs
/// reordering. For example, in Hebrew, in which the text runs from right to left, the lpOrder array gives the exact
/// locations of each element in the original string.
///
///
public IntPtr lpOrder;
///
///
/// A pointer to the array that receives the distances between adjacent character cells or is NULL if these distances are
/// not needed. If glyph rendering is done, the distances are for the glyphs not the characters, so the resulting array can be
/// used with the ExtTextOut function.
///
///
/// The distances in this array are in display order. To find the distance for the i character in the original string, use the
/// lpOrder array as follows:
///
/// width = lpDx[lpOrder[i]];
///
public IntPtr lpDx;
///
///
/// A pointer to the array that receives the caret position values or is NULL if caret positions are not needed. Each
/// value specifies the caret position immediately before the corresponding character. In some languages the position of the
/// caret for each character may not be immediately to the left of the character. For example, in Hebrew, in which the text runs
/// from right to left, the caret position is to the right of the character. If glyph ordering is done, lpCaretPos matches
/// the original string, not the output string. This means that some adjacent values may be the same.
///
///
/// The values in this array are in input order. To find the caret position value for the i character in the original string, use
/// the array as follows:
///
/// position = lpCaretPos[i];
///
public IntPtr lpCaretPos;
///
///
/// A pointer to the array that contains and/or receives character classifications. The values indicate how to lay out characters
/// in the string and are similar (but not identical) to the CT_CTYPE2 values returned by the GetStringTypeEx function. Each
/// element of the array can be set to zero or one of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// GCPCLASS_ARABIC
/// Arabic character.
///
/// -
/// GCPCLASS_HEBREW
/// Hebrew character.
///
/// -
/// GCPCLASS_LATIN
/// Character from a Latin or other single-byte character set for a left-to-right language.
///
/// -
/// GCPCLASS_LATINNUMBER
/// Digit from a Latin or other single-byte character set for a left-to-right language.
///
/// -
/// GCPCLASS_LOCALNUMBER
/// Digit from the character set associated with the current font.
///
///
/// In addition, the following can be used when supplying values in the lpClass array with the GCP_CLASSIN flag.
///
///
/// Value
/// Meaning
///
/// -
/// GCPCLASS_LATINNUMERICSEPARATOR
/// Input only. Character used to separate Latin digits, such as a comma or decimal point.
///
/// -
/// GCPCLASS_LATINNUMERICTERMINATOR
/// Input only. Character used to terminate Latin digits, such as a plus or minus sign.
///
/// -
/// GCPCLASS_NEUTRAL
/// Input only. Character has no specific classification.
///
/// -
/// GCPCLASS_NUMERICSEPARATOR
/// Input only. Character used to separate digits, such as a comma or decimal point.
///
///
///
/// For languages that use the GCP_REORDER flag, the following values can also be used with the GCP_CLASSIN flag. Unlike the
/// preceding values, which can be used anywhere in the lpClass array, all of the following values are used only in the
/// first location in the array. All combine with other classifications.
///
/// Note that GCPCLASS_PREBOUNDLTR and GCPCLASS_PREBOUNDRTL are mutually exclusive, as are GCPCLASSPOSTBOUNDLTR and GCPCLASSPOSTBOUNDRTL.
///
///
/// Value
/// Meaning
///
/// -
/// GCPCLASS_PREBOUNDLTR
/// Set lpClass[0] to GCPCLASS_PREBOUNDLTR to bind the string to left-to-right reading order before the string.
///
/// -
/// GCPCLASS_PREBOUNDRTL
/// Set lpClass[0] to GCPCLASS_PREBOUNDRTL to bind the string to right-to-left reading order before the string.
///
/// -
/// GCPCLASS_POSTBOUNDLTR
/// Set lpClass[0] to GCPCLASS_POSTBOUNDLTR to bind the string to left-to-right reading order after the string.
///
/// -
/// GCPCLASS_POSTBOUNDRTL
/// Set lpClass[0] to GCPCLASS_POSTBOUNDRTL to bind the string to right-to-left reading order after the string.
///
///
///
/// To force the layout of a character to be carried out in a specific way, preset the classification for the corresponding array
/// element; the function leaves such preset classifications unchanged and computes classifications only for array elements that
/// have been set to zero. Preset classifications are used only if the GCP_CLASSIN flag is set and the lpClass array is supplied.
///
/// If GetFontLanguageInfo does not return GCP_REORDER for the current font, only the GCPCLASS_LATIN value is meaningful.
///
public IntPtr lpClass;
///
///
/// A pointer to the array that receives the values identifying the glyphs used for rendering the string or is NULL if
/// glyph rendering is not needed. The number of glyphs in the array may be less than the number of characters in the original
/// string if the string contains ligated glyphs. Also if reordering is required, the order of the glyphs may not be sequential.
///
///
/// This array is useful if more than one operation is being done on a string which has any form of ligation, kerning or
/// order-switching. Using the values in this array for subsequent operations saves the time otherwise required to generate the
/// glyph indices each time.
///
///
/// This array always contains glyph indices and the ETO_GLYPH_INDEX value must always be used when this array is used with the
/// ExtTextOut function.
///
///
/// When GCP_LIGATE is used, you can limit the number of characters that will be ligated together. (In Arabic for example,
/// three-character ligations are common). This is done by setting the maximum required in lpGcpResults->lpGlyphs[0]. If no
/// maximum is required, you should set this field to zero.
///
///
/// For languages such as Arabic, where GetFontLanguageInfo returns the GCP_GLYPHSHAPE flag, the glyphs for a character will be
/// different depending on whether the character is at the beginning, middle, or end of a word. Typically, the first character in
/// the input string will also be the first character in a word, and the last character in the input string will be treated as
/// the last character in a word. However, if the displayed string is a subset of the complete string, such as when displaying a
/// section of scrolled text, this may not be true. In these cases, it is desirable to force the first or last characters to be
/// shaped as not being initial or final forms. To do this, again, the first location in the lpGlyphs array is used by
/// performing an OR operation of the ligation value above with the values GCPGLYPH_LINKBEFORE and/or GCPGLYPH_LINKAFTER. For
/// example, a value of GCPGLYPH_LINKBEFORE | 2 means that two-character ligatures are the maximum required, and the first
/// character in the string should be treated as if it is in the middle of a word.
///
///
public IntPtr lpGlyphs;
///
/// On input, this member must be set to the size of the arrays pointed to by the array pointer members. On output, this is set
/// to the number of glyphs filled in, in the output arrays. If glyph substitution is not required (that is, each input character
/// maps to exactly one glyph), this member is the same as it is on input.
///
public uint nGlyphs;
///
/// The number of characters that fit within the extents specified by the nMaxExtent parameter of the GetCharacterPlacement
/// function. If the GCP_MAXEXTENT or GCP_JUSTIFY value is set, this value may be less than the number of characters in the
/// original string. This member is set regardless of whether the GCP_MAXEXTENT or GCP_JUSTIFY value is specified. Unlike
/// nGlyphs, which specifies the number of output glyphs, nMaxFit refers to the number of characters from the input
/// string. For Latin SBCS languages, this will be the same.
///
public int nMaxFit;
/// The default instance of this structure with the structure size value set.
public static GCP_RESULTS Default = new GCP_RESULTS { lStructSize = (uint)Marshal.SizeOf(typeof(GCP_RESULTS)) };
}
///
/// The GLYPHMETRICS structure contains information about the placement and orientation of a glyph in a character cell.
///
/// Values in the GLYPHMETRICS structure are specified in device units.
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-glyphmetrics typedef struct _GLYPHMETRICS { UINT gmBlackBoxX;
// UINT gmBlackBoxY; POINT gmptGlyphOrigin; short gmCellIncX; short gmCellIncY; } GLYPHMETRICS, *LPGLYPHMETRICS;
[PInvokeData("wingdi.h", MSDNShortId = "a6fa3813-56f7-4b54-b21d-8aabc2309a34")]
[StructLayout(LayoutKind.Sequential)]
public struct GLYPHMETRICS
{
/// The width of the smallest rectangle that completely encloses the glyph (its black box).
public uint gmBlackBoxX;
/// The height of the smallest rectangle that completely encloses the glyph (its black box).
public uint gmBlackBoxY;
/// The x- and y-coordinates of the upper left corner of the smallest rectangle that completely encloses the glyph.
public Point gmptGlyphOrigin;
/// The horizontal distance from the origin of the current character cell to the origin of the next character cell.
public short gmCellIncX;
/// The vertical distance from the origin of the current character cell to the origin of the next character cell.
public short gmCellIncY;
}
/// The GLYPHSET structure contains information about a range of Unicode code points.
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-glyphset typedef struct tagGLYPHSET { DWORD cbThis; DWORD
// flAccel; DWORD cGlyphsSupported; DWORD cRanges; WCRANGE ranges[1]; } GLYPHSET, *PGLYPHSET, *LPGLYPHSET;
[PInvokeData("wingdi.h", MSDNShortId = "b8ac8d3f-b062-491c-966f-02f3d4c11419")]
[VanaraMarshaler(typeof(SafeAnysizeStructMarshaler), nameof(cRanges))]
[StructLayout(LayoutKind.Sequential)]
public struct GLYPHSET
{
/// The size, in bytes, of this structure.
public uint cbThis;
///
/// Flags describing the maximum size of the glyph indices. This member can be the following value.
///
///
/// Value
/// Meaning
///
/// -
/// GS_8BIT_INDICES
/// Treat glyph indices as 8-bit wide values. Otherwise, they are 16-bit wide values.
///
///
///
public GSISize flAccel;
/// The total number of Unicode code points supported in the font.
public uint cGlyphsSupported;
/// The total number of Unicode ranges in ranges.
public uint cRanges;
/// Array of Unicode ranges that are supported in the font.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
public WCRANGE[] ranges;
}
/// The KERNINGPAIR structure defines a kerning pair.
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-kerningpair typedef struct tagKERNINGPAIR { WORD wFirst; WORD
// wSecond; int iKernAmount; } KERNINGPAIR, *LPKERNINGPAIR;
[PInvokeData("wingdi.h", MSDNShortId = "af7bfcf7-467b-4ea9-87c5-3622303b1d8b")]
[StructLayout(LayoutKind.Sequential)]
public struct KERNINGPAIR
{
/// The character code for the first character in the kerning pair.
public ushort wFirst;
/// The character code for the second character in the kerning pair.
public ushort wSecond;
///
/// The amount this pair will be kerned if they appear side by side in the same font and size. This value is typically negative,
/// because pair kerning usually results in two characters being set more tightly than normal. The value is specified in logical
/// units; that is, it depends on the current mapping mode.
///
public int iKernAmount;
}
/// The MAT2 structure contains the values for a transformation matrix used by the GetGlyphOutline function.
///
/// The identity matrix produces a transformation in which the transformed graphical object is identical to the source object. In the
/// identity matrix, the value of eM11 is 1, the value of eM12 is zero, the value of eM21 is zero, and the value
/// of eM22 is 1.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-mat2 typedef struct _MAT2 { FIXED eM11; FIXED eM12; FIXED
// eM21; FIXED eM22; } MAT2, *LPMAT2;
[PInvokeData("wingdi.h", MSDNShortId = "841883d6-bc4d-46ef-abf4-f179771d255b")]
[StructLayout(LayoutKind.Sequential)]
public struct MAT2
{
/// A fixed-point value for the M11 component of a 3 by 3 transformation matrix.
public FIXED eM11;
/// A fixed-point value for the M12 component of a 3 by 3 transformation matrix.
public FIXED eM12;
/// A fixed-point value for the M21 component of a 3 by 3 transformation matrix.
public FIXED eM21;
/// A fixed-point value for the M22 component of a 3 by 3 transformation matrix.
public FIXED eM22;
/// The identity matrix value.
public static readonly MAT2 IdentityMatrix = new MAT2 { eM11 = new FIXED { fract = 1 }, eM22 = new FIXED { fract = 1 } };
}
/// The NEWTEXTMETRIC structure contains data that describes a physical font.
///
///
/// 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.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-newtextmetrica typedef struct tagNEWTEXTMETRICA { LONG
// tmHeight; LONG tmAscent; LONG tmDescent; LONG tmInternalLeading; LONG tmExternalLeading; LONG tmAveCharWidth; LONG tmMaxCharWidth;
// LONG tmWeight; LONG tmOverhang; LONG tmDigitizedAspectX; LONG tmDigitizedAspectY; BYTE tmFirstChar; BYTE tmLastChar; BYTE
// tmDefaultChar; BYTE tmBreakChar; BYTE tmItalic; BYTE tmUnderlined; BYTE tmStruckOut; BYTE tmPitchAndFamily; BYTE tmCharSet; DWORD
// ntmFlags; UINT ntmSizeEM; UINT ntmCellHeight; UINT ntmAvgWidth; } NEWTEXTMETRICA, *PNEWTEXTMETRICA, *NPNEWTEXTMETRICA, *LPNEWTEXTMETRICA;
[PInvokeData("wingdi.h", MSDNShortId = "0dd7fee0-0771-4c72-9843-0fee308da5cc")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct NEWTEXTMETRIC
{
/// The height (ascent + descent) of characters.
public int tmHeight;
/// The ascent (units above the base line) of characters.
public int tmAscent;
/// The descent (units below the base line) of characters.
public int tmDescent;
///
/// 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.
///
public int tmInternalLeading;
///
/// 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.
///
public int tmExternalLeading;
///
/// 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.
///
public int tmAveCharWidth;
/// The width of the widest character in the font.
public int tmMaxCharWidth;
/// The weight of the font.
public int tmWeight;
///
///
/// 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.
///
///
public int tmOverhang;
/// The horizontal aspect of the device for which the font was designed.
public int tmDigitizedAspectX;
///
/// 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.
///
public int tmDigitizedAspectY;
/// The value of the first character defined in the font.
public char tmFirstChar;
/// The value of the last character defined in the font.
public char tmLastChar;
/// The value of the character to be substituted for characters that are not in the font.
public char tmDefaultChar;
/// The value of the character to be used to define word breaks for text justification.
public char tmBreakChar;
/// An italic font if it is nonzero.
public byte tmItalic;
/// An underlined font if it is nonzero.
public byte tmUnderlined;
/// A strikeout font if it is nonzero.
public byte tmStruckOut;
///
///
/// 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; if bit 1 is 1 and bit 2 is 0, the font is a vector font; if bit 1 is 0 and bit 2
/// is set, or if both bits are 1, the font is some other type. Bit 3 is 1 if the font is a device font; otherwise, it is 0.
///
///
/// 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.
///
///
public byte tmPitchAndFamily;
/// The character set of the font.
public byte tmCharSet;
///
///
/// Specifies whether the font is italic, underscored, outlined, bold, and so forth. May be any reasonable combination of the
/// following values.
///
///
///
/// Bit
/// Name
/// Meaning
///
/// -
/// 0
/// NTM_ITALIC
/// italic
///
/// -
/// 5
/// NTM_BOLD
/// bold
///
/// -
/// 8
/// NTM_REGULAR
/// regular
///
/// -
/// 16
/// NTM_NONNEGATIVE_AC
/// no glyph in a font at any size has a negative A or C space.
///
/// -
/// 17
/// NTM_PS_OPENTYPE
/// PostScript OpenType font
///
/// -
/// 18
/// NTM_TT_OPENTYPE
/// TrueType OpenType font
///
/// -
/// 19
/// NTM_MULTIPLEMASTER
/// multiple master font
///
/// -
/// 20
/// NTM_TYPE1
/// Type 1 font
///
/// -
/// 21
/// NTM_DSIG
/// font with a digital signature. This allows traceability and ensures that the font has been tested and is not corrupted
///
///
///
public uint ntmFlags;
///
/// 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).
///
public uint ntmSizeEM;
///
/// The height, in notional units, of the font. This value should be compared with the value of the ntmSizeEM member.
///
public uint ntmCellHeight;
///
/// The average width of characters in the font, in notional units. This value should be compared with the value of the
/// ntmSizeEM member.
///
public uint ntmAvgWidth;
}
/// The NEWTEXTMETRICEX structure contains information about a physical font.
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-newtextmetricexa typedef struct tagNEWTEXTMETRICEXA {
// NEWTEXTMETRICA ntmTm; FONTSIGNATURE ntmFontSig; } NEWTEXTMETRICEXA;
[PInvokeData("wingdi.h", MSDNShortId = "b85ff705-2dd4-4877-9905-d4c2a0894e24")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct NEWTEXTMETRICEX
{
/// A NEWTEXTMETRIC structure.
public NEWTEXTMETRIC ntmTm;
/// A FONTSIGNATURE structure indicating the coverage of the font.
public FONTSIGNATURE ntmFontSig;
}
/// The OUTLINETEXTMETRIC structure contains metrics describing a TrueType font.
///
///
/// 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".
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-outlinetextmetrica typedef struct _OUTLINETEXTMETRICA { UINT
// otmSize; TEXTMETRICA 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; } OUTLINETEXTMETRICA, *POUTLINETEXTMETRICA, *NPOUTLINETEXTMETRICA, *LPOUTLINETEXTMETRICA;
[PInvokeData("wingdi.h", MSDNShortId = "79d77df0-193a-49a8-b93d-4ef5807c3c9b")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct OUTLINETEXTMETRIC
{
/// The size, in bytes, of the OUTLINETEXTMETRIC structure.
public uint otmSize;
/// A TEXTMETRIC structure containing further information about the font.
public TEXTMETRIC otmTextMetrics;
/// A value that causes the structure to be byte-aligned.
public byte otmFiller;
/// The PANOSE number for this font.
public PANOSE otmPanoseNumber;
///
/// The nature of the font pattern. This member can be a combination of the following bits.
///
///
/// Bit
/// Meaning
///
/// -
/// 0
/// Italic
///
/// -
/// 1
/// Underscore
///
/// -
/// 2
/// Negative
///
/// -
/// 3
/// Outline
///
/// -
/// 4
/// Strikeout
///
/// -
/// 5
/// Bold
///
///
///
public uint otmfsSelection;
///
/// 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.
///
public uint otmfsType;
///
/// 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).
///
public int otmsCharSlopeRise;
///
/// 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).
///
public int otmsCharSlopeRun;
///
/// 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).
///
public int otmItalicAngle;
///
/// 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.)
///
public uint otmEMSquare;
///
/// The maximum distance characters in this font extend above the base line. This is the typographic ascent for the font.
///
public int otmAscent;
///
/// The maximum distance characters in this font extend below the base line. This is the typographic descent for the font.
///
public int otmDescent;
/// The typographic line spacing.
public uint otmLineGap;
/// Not supported.
public uint otmsCapEmHeight;
/// Not supported.
public uint otmsXHeight;
/// The bounding box for the font.
public RECT otmrcFontBox;
/// The maximum distance characters in this font extend above the base line for the Macintosh computer.
public int otmMacAscent;
/// The maximum distance characters in this font extend below the base line for the Macintosh computer.
public int otmMacDescent;
/// The line-spacing information for the Macintosh computer.
public uint otmMacLineGap;
/// The smallest recommended size for this font, in pixels per em-square.
public uint otmusMinimumPPEM;
/// The recommended horizontal and vertical size for subscripts in this font.
public Point otmptSubscriptSize;
///
/// 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.
///
public Point otmptSubscriptOffset;
/// The recommended horizontal and vertical size for superscripts in this font.
public Point otmptSuperscriptSize;
///
/// 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.
///
public Point otmptSuperscriptOffset;
/// The width of the strikeout stroke for this font. Typically, this is the width of the em dash for the font.
public uint otmsStrikeoutSize;
///
/// 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.
///
public int otmsStrikeoutPosition;
/// The thickness of the underscore character for this font.
public int otmsUnderscoreSize;
/// The position of the underscore character for this font.
public int otmsUnderscorePosition;
/// The offset from the beginning of the structure to a string specifying the family name for the font.
public IntPtr otmpFamilyName;
///
/// 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.)
///
public IntPtr otmpFaceName;
/// The offset from the beginning of the structure to a string specifying the style name for the font.
public IntPtr otmpStyleName;
///
/// 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.
///
public IntPtr otmpFullName;
}
///
/// The PANOSE structure describes the PANOSE font-classification values for a TrueType font. These characteristics are then
/// used to associate the font with other fonts of similar appearance but different names.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-panose typedef struct tagPANOSE { BYTE bFamilyType; BYTE
// bSerifStyle; BYTE bWeight; BYTE bProportion; BYTE bContrast; BYTE bStrokeVariation; BYTE bArmStyle; BYTE bLetterform; BYTE
// bMidline; BYTE bXHeight; } PANOSE, *LPPANOSE;
[PInvokeData("wingdi.h", MSDNShortId = "18aa4a36-8e47-4e35-973f-376d412ed923")]
[StructLayout(LayoutKind.Sequential)]
public struct PANOSE
{
///
/// For Latin fonts, one of one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PAN_ANY
/// Any
///
/// -
/// PAN_NO_FIT
/// No fit
///
/// -
/// PAN_FAMILY_TEXT_DISPLAY
/// Text and display
///
/// -
/// PAN_FAMILY_SCRIPT
/// Script
///
/// -
/// PAN_FAMILY_DECORATIVE
/// Decorative
///
/// -
/// PAN_FAMILY_PICTORIAL
/// Pictorial
///
///
///
public PAN_FAMILY bFamilyType;
///
/// The serif style. For Latin fonts, one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PAN_ANY
/// Any
///
/// -
/// PAN_NO_FIT
/// No fit
///
/// -
/// PAN_SERIF_COVE
/// Cove
///
/// -
/// PAN_SERIF_OBTUSE_COVE
/// Obtuse cove
///
/// -
/// PAN_SERIF_SQUARE_COVE
/// Square cove
///
/// -
/// PAN_SERIF_OBTUSE_SQUARE_COVE
/// Obtuse square cove
///
/// -
/// PAN_SERIF_SQUARE
/// Square
///
/// -
/// PAN_SERIF_THIN
/// Thin
///
/// -
/// PAN_SERIF_BONE
/// Bone
///
/// -
/// PAN_SERIF_EXAGGERATED
/// Exaggerated
///
/// -
/// PAN_SERIF_TRIANGLE
/// Triangle
///
/// -
/// PAN_SERIF_NORMAL_SANS
/// Normal sans serif
///
/// -
/// PAN_SERIF_OBTUSE_SANS
/// Obtuse sans serif
///
/// -
/// PAN_SERIF_PERP_SANS
/// Perp sans serif
///
/// -
/// PAN_SERIF_FLARED
/// Flared
///
/// -
/// PAN_SERIF_ROUNDED
/// Rounded
///
///
///
public PAN_SERIF bSerifStyle;
///
/// For Latin fonts, one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PAN_ANY
/// Any
///
/// -
/// PAN_NO_FIT
/// No fit
///
/// -
/// PAN_WEIGHT_VERY_LIGHT
/// Very light
///
/// -
/// PAN_WEIGHT_LIGHT
/// Light
///
/// -
/// PAN_WEIGHT_THIN
/// Thin
///
/// -
/// PAN_WEIGHT_BOOK
/// Book
///
/// -
/// PAN_WEIGHT_MEDIUM
/// Medium
///
/// -
/// PAN_WEIGHT_DEMI
/// Demibold
///
/// -
/// PAN_WEIGHT_BOLD
/// Bold
///
/// -
/// PAN_WEIGHT_HEAVY
/// Heavy
///
/// -
/// PAN_WEIGHT_BLACK
/// Black
///
/// -
/// PAN_WEIGHT_NORD
/// Nord
///
///
///
public PAN_WEIGHT bWeight;
///
/// For Latin fonts, one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PAN_ANY
/// Any
///
/// -
/// PAN_NO_FIT
/// No fit
///
/// -
/// PAN_PROP_OLD_STYLE
/// Old style
///
/// -
/// PAN_PROP_MODERN
/// Modern
///
/// -
/// PAN_PROP_EVEN_WIDTH
/// Even width
///
/// -
/// PAN_PROP_EXPANDED
/// Expanded
///
/// -
/// PAN_PROP_CONDENSED
/// Condensed
///
/// -
/// PAN_PROP_VERY_EXPANDED
/// Very expanded
///
/// -
/// PAN_PROP_VERY_CONDENSED
/// Very condensed
///
/// -
/// PAN_PROP_MONOSPACED
/// Monospaced
///
///
///
public PAN_PROP bProportion;
///
/// For Latin fonts, one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PAN_ANY
/// Any
///
/// -
/// PAN_NO_FIT
/// No fit
///
/// -
/// PAN_CONTRAST_NONE
/// None
///
/// -
/// PAN_CONTRAST_VERY_LOW
/// Very low
///
/// -
/// PAN_CONTRAST_LOW
/// Low
///
/// -
/// PAN_CONTRAST_MEDIUM_LOW
/// Medium low
///
/// -
/// PAN_CONTRAST_MEDIUM
/// Medium
///
/// -
/// PAN_CONTRAST_MEDIUM_HIGH
/// Medium high
///
/// -
/// PAN_CONTRAST_HIGH
/// High
///
/// -
/// PAN_CONTRAST_VERY_HIGH
/// Very high
///
///
///
public PAN_CONTRAST bContrast;
///
/// For Latin fonts, one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PAN_ANY
/// Any
///
/// -
/// PAN_NO_FIT
/// No fit
///
/// -
/// PAN_STROKE_GRADUAL_DIAG
/// Gradual/diagonal
///
/// -
/// PAN_STROKE_GRADUAL_TRAN
/// Gradual/transitional
///
/// -
/// PAN_STROKE_GRADUAL_VERT
/// Gradual/vertical
///
/// -
/// PAN_STROKE_GRADUAL_HORZ
/// Gradual/horizontal
///
/// -
/// PAN_STROKE_RAPID_VERT
/// Rapid/vertical
///
/// -
/// PAN_STROKE_RAPID_HORZ
/// Rapid/horizontal
///
/// -
/// PAN_STROKE_INSTANT_VERT
/// Instant/vertical
///
///
///
public PAN_STROKE bStrokeVariation;
///
/// For Latin fonts, one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PAN_ANY
/// Any
///
/// -
/// PAN_NO_FIT
/// No fit
///
/// -
/// PAN_STRAIGHT_ARMS_HORZ
/// Straight arms/horizontal
///
/// -
/// PAN_STRAIGHT_ARMS_WEDGE
/// Straight arms/wedge
///
/// -
/// PAN_STRAIGHT_ARMS_VERT
/// Straight arms/vertical
///
/// -
/// PAN_STRAIGHT_ARMS_SINGLE_SERIF
/// Straight arms/single-serif
///
/// -
/// PAN_STRAIGHT_ARMS_DOUBLE_SERIF
/// Straight arms/double-serif
///
/// -
/// PAN_BENT_ARMS_HORZ
/// Nonstraight arms/horizontal
///
/// -
/// PAN_BENT_ARMS_WEDGE
/// Nonstraight arms/wedge
///
/// -
/// PAN_BENT_ARMS_VERT
/// Nonstraight arms/vertical
///
/// -
/// PAN_BENT_ARMS_SINGLE_SERIF
/// Nonstraight arms/single-serif
///
/// -
/// PAN_BENT_ARMS_DOUBLE_SERIF
/// Nonstraight arms/double-serif
///
///
///
public PAN_ARMS bArmStyle;
///
/// For Latin fonts, one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PAN_ANY
/// Any
///
/// -
/// PAN_NO_FIT
/// No fit
///
/// -
/// PAN_LETT_NORMAL_CONTACT
/// Normal/contact
///
/// -
/// PAN_LETT_NORMAL_WEIGHTED
/// Normal/weighted
///
/// -
/// PAN_LETT_NORMAL_BOXED
/// Normal/boxed
///
/// -
/// PAN_LETT_NORMAL_FLATTENED
/// Normal/flattened
///
/// -
/// PAN_LETT_NORMAL_ROUNDED
/// Normal/rounded
///
/// -
/// PAN_LETT_NORMAL_OFF_CENTER
/// Normal/off center
///
/// -
/// PAN_LETT_NORMAL_SQUARE
/// Normal/square
///
/// -
/// PAN_LETT_OBLIQUE_CONTACT
/// Oblique/contact
///
/// -
/// PAN_LETT_OBLIQUE_WEIGHTED
/// Oblique/weighted
///
/// -
/// PAN_LETT_OBLIQUE_BOXED
/// Oblique/boxed
///
/// -
/// PAN_LETT_OBLIQUE_FLATTENED
/// Oblique/flattened
///
/// -
/// PAN_LETT_OBLIQUE_ROUNDED
/// Oblique/rounded
///
/// -
/// PAN_LETT_OBLIQUE_OFF_CENTER
/// Oblique/off center
///
/// -
/// PAN_LETT_OBLIQUE_SQUARE
/// Oblique/square
///
///
///
public PAN_LETT bLetterform;
///
/// For Latin fonts, one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PAN_ANY
/// Any
///
/// -
/// PAN_NO_FIT
/// No fit
///
/// -
/// PAN_MIDLINE_STANDARD_TRIMMED
/// Standard/trimmed
///
/// -
/// PAN_MIDLINE_STANDARD_POINTED
/// Standard/pointed
///
/// -
/// PAN_MIDLINE_STANDARD_SERIFED
/// Standard/serifed
///
/// -
/// PAN_MIDLINE_HIGH_TRIMMED
/// High/trimmed
///
/// -
/// PAN_MIDLINE_HIGH_POINTED
/// High/pointed
///
/// -
/// PAN_MIDLINE_HIGH_SERIFED
/// High/serifed
///
/// -
/// PAN_MIDLINE_CONSTANT_TRIMMED
/// Constant/trimmed
///
/// -
/// PAN_MIDLINE_CONSTANT_POINTED
/// Constant/pointed
///
/// -
/// PAN_MIDLINE_CONSTANT_SERIFED
/// Constant/serifed
///
/// -
/// PAN_MIDLINE_LOW_TRIMMED
/// Low/trimmed
///
/// -
/// PAN_MIDLINE_LOW_POINTED
/// Low/pointed
///
/// -
/// PAN_MIDLINE_LOW_SERIFED
/// Low/serifed
///
///
///
public PAN_MIDLINE bMidline;
///
/// For Latin fonts, one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PAN_ANY
/// Any
///
/// -
/// PAN_NO_FIT
/// No fit
///
/// -
/// PAN_XHEIGHT_CONSTANT_SMALL
/// Constant/small
///
/// -
/// PAN_XHEIGHT_CONSTANT_STD
/// Constant/standard
///
/// -
/// PAN_XHEIGHT_CONSTANT_LARGE
/// Constant/large
///
/// -
/// PAN_XHEIGHT_DUCKING_SMALL
/// Ducking/small
///
/// -
/// PAN_XHEIGHT_DUCKING_STD
/// Ducking/standard
///
/// -
/// PAN_XHEIGHT_DUCKING_LARGE
/// Ducking/large
///
///
///
public PAN_XHEIGHT bXHeight;
}
/// The POLYTEXT structure describes how the PolyTextOut function should draw a string of text.
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-polytextw typedef struct tagPOLYTEXTW { int x; int y; UINT n;
// LPCWSTR lpstr; UINT uiFlags; RECT rcl; int *pdx; } POLYTEXTW, *PPOLYTEXTW, *NPPOLYTEXTW, *LPPOLYTEXTW;
[PInvokeData("wingdi.h", MSDNShortId = "6f03e2ff-c15f-498c-8c3d-33106222279e")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct POLYTEXT
{
///
/// The horizontal reference point for the string. The string is aligned to this point using the current text-alignment mode.
///
public int x;
///
/// The vertical reference point for the string. The string is aligned to this point using the current text-alignment mode.
///
public int y;
/// The length of the string pointed to by lpstr.
public uint n;
///
/// Pointer to a string of text to be drawn by the PolyTextOut function. This string need not be null-terminated, since n
/// specifies the length of the string.
///
[MarshalAs(UnmanagedType.LPTStr)] public string lpstr;
///
///
/// Specifies whether the string is to be opaque or clipped and whether the string is accompanied by an array of character-width
/// values. This member can be one or more of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// ETO_OPAQUE
/// The rectangle for each string is to be opaqued with the current background color.
///
/// -
/// ETO_CLIPPED
/// Each string is to be clipped to its specified rectangle.
///
///
///
public ETO uiFlags;
///
/// A rectangle structure that contains the dimensions of the opaquing or clipping rectangle. This member is ignored if neither
/// of the ETO_OPAQUE nor the ETO_CLIPPED value is specified for the uiFlags member.
///
public RECT rcl;
/// Pointer to an array containing the width value for each character in the string.
public IntPtr pdx;
}
///
/// The RASTERIZER_STATUS structure contains information about whether TrueType is installed. This structure is filled when an
/// application calls the GetRasterizerCaps function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-rasterizer_status typedef struct _RASTERIZER_STATUS { short
// nSize; short wFlags; short nLanguageID; } RASTERIZER_STATUS, *LPRASTERIZER_STATUS;
[PInvokeData("wingdi.h", MSDNShortId = "40bb4b59-90a4-4780-ae5f-fef8a6fa62cb")]
[StructLayout(LayoutKind.Sequential)]
public struct RASTERIZER_STATUS
{
/// The size, in bytes, of the RASTERIZER_STATUS structure.
public short nSize;
///
/// Specifies whether at least one TrueType font is installed and whether TrueType is enabled. This value is TT_AVAILABLE,
/// TT_ENABLED, or both if TrueType is on the system.
///
public TT wFlags;
/// The language in the system's Setup.inf file.
public short nLanguageID;
}
/// The WCRANGE structure specifies a range of Unicode characters.
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-wcrange typedef struct tagWCRANGE { WCHAR wcLow; USHORT
// cGlyphs; } WCRANGE, *PWCRANGE, *LPWCRANGE;
[PInvokeData("wingdi.h", MSDNShortId = "20959057-6062-4c1e-a23d-535584ba6ea3")]
[StructLayout(LayoutKind.Sequential)]
public struct WCRANGE
{
/// Low Unicode code point in the range of supported Unicode code points.
public ushort wcLow;
/// Number of supported Unicode code points in this range.
public ushort cGlyphs;
}
}
}