Font Functions
Windows GDI+ exposes a flat API that consists of about 600 functions, which are implemented in Gdiplus.dll and declared in Gdiplusflat.h. The functions in the GDI+ flat API are wrapped by a collection of about 40 C++ classes. It is recommended that you do not directly call the functions in the flat API. Whenever you make calls to GDI+, you should do so by calling the methods and functions provided by the C++ wrappers. Microsoft Product Support Services will not provide support for code that calls the flat API directly. For more information on using these wrapper methods, see GDI+ Flat API.
The following flat API functions are wrapped by the Font C++ class.
Font Functions and Corresponding Wrapper Methods
Flat function | Wrapper method | Remarks |
---|---|---|
GpStatus WINGDIPAPI GdipCreateFontFromDC( HDC hdc, GpFont **font ) |
Font::Font(IN HDC hdc) | Creates a Font object based on the GDI font object that is currently selected into a specified device context. This constructor is provided for compatibility with GDI. |
GpStatus WINGDIPAPI GdipCreateFontFromLogfontA( HDC hdc, GDIPCONST LOGFONTA *logfont, GpFont **font ) |
Font::Font(IN HDC hdc, IN const LOGFONTA* logfont) | Creates a Font object directly from a GDI logical font. The GDI logical font is a LOGFONTA structure, which is the one-byte character version of a logical font. This constructor is provided for compatibility with GDI. |
GpStatus WINGDIPAPI GdipCreateFontFromLogfontW( HDC hdc, GDIPCONST LOGFONTW *logfont, GpFont **font ) |
Font::Font(IN HDC hdc, IN const LOGFONTW* logfont) | Creates a Font object directly from a GDI logical font. The GDI logical font is a LOGFONTW structure, which is the one-byte character version of a logical font. This constructor is provided for compatibility with GDI. |
GpStatus WINGDIPAPI GdipCloneFont(GpFont* font, GpFont** cloneFont) |
Not called by wrapper methods. |
Not implemented. |
GpStatus WINGDIPAPI GdipCreateFont( GDIPCONST GpFontFamily *fontFamily, REAL emSize, INT style, Unit unit, GpFont **font ) |
Font::Font( IN const FontFamily * family, IN REAL emSize, IN INT style, IN Unit unit ) | Creates a Font object based on a font family, a size, a font style, a unit of measurement, and a FontCollection object. |
GpStatus WINGDIPAPI GdipCloneFont(GpFont* font, GpFont** cloneFont) |
Font::Font* Clone() const | Creates a new Font object based on this Font object. |
GpStatus WINGDIPAPI GdipDeleteFont(GpFont* font) |
Not called by wrapper methods. |
Not implemented. |
GpStatus WINGDIPAPI GdipGetFamily(GpFont *font, GpFontFamily **family) |
Status Font::GetFamily(OUT FontFamily *family) const | Gets the font family on which this font is based. |
GpStatus WINGDIPAPI GdipGetFontStyle(GpFont *font, INT *style) |
INT Font::GetStyle() const | Gets the style of this font's typeface |
GpStatus WINGDIPAPI GdipGetFontSize(GpFont *font, REAL *size) |
REAL Font::GetSize() const | Returns the font size (commonly called the em size) of this Font object. The size is in the units of this Font object. |
GpStatus WINGDIPAPI GdipGetFontUnit(GpFont *font, Unit *unit) |
Unit Font::GetUnit() const | Returns the unit of measure of this Font object. |
GpStatus WINGDIPAPI GdipGetFontHeight(GDIPCONST GpFont *font, GDIPCONST GpGraphics *graphics, REAL *height) |
REAL Font::GetHeight(IN const Graphics *graphics) const | Gets the line spacing of this font in the current unit of a specified Graphics object. The line spacing is the vertical distance between the base lines of two consecutive lines of text. Thus, the line spacing includes the blank space between lines along with the height of the character itself. |
GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi, REAL *height) |
REAL Font::GetHeight(IN REAL dpi) const | Gets the line spacing, in pixels, of this font. The line spacing is the vertical distance between the base lines of two consecutive lines of text. Thus, the line spacing includes the blank space between lines along with the height of the character itself. |
GpStatus WINGDIPAPI GdipGetLogFontA(GpFont * font, GpGraphics *graphics, LOGFONTA * logfontA) |
Status Font::GetLogFontA(IN const Graphics *g, OUT LOGFONTA *logfontA) const | Uses a LOGFONTA structure to get the attributes of this Font object. |
GpStatus WINGDIPAPI GdipGetLogFontW(GpFont * font, GpGraphics *graphics, LOGFONTW * logfontW) |
Status Font::GetLogFontW(IN const Graphics *g, OUT LOGFONTW *logfontW) const | Uses a LOGFONTW structure to get the attributes of this Font object. |
GpStatus WINGDIPAPI GdipNewInstalledFontCollection(GpFontCollection** fontCollection) |
InstalledFontCollection | Defines a class that represents the fonts installed on the system. |
GpStatus WINGDIPAPI GdipNewPrivateFontCollection(GpFontCollection** fontCollection) |
InstalledFontCollection | The PrivateFontCollection is a collection class for fonts. This class keeps a collection of fonts specifically for an application. The fonts in the collection can include installed fonts as well as fonts that have not been installed on the system.. |
GpStatus WINGDIPAPI GdipDeletePrivateFontCollection(GpFontCollection** fontCollection) |
PrivateFontCollection::~PrivateFontCollection | Release the GpFontCollection created by GdipNewPrivateFontCollection. |
GpStatus WINGDIPAPI GdipGetFontCollectionFamilyCount( GpFontCollection* fontCollection, INT * numFound ) |
Not called by wrapper methods. |
Not implemented. |
GpStatus WINGDIPAPI GdipGetFontCollectionFamilyList( GpFontCollection* fontCollection, INT numSought, GpFontFamily* gpfamilies[], INT* numFound ) |
Not called by wrapper methods. |
Not implemented. |
GpStatus WINGDIPAPI GdipPrivateAddFontFile(GpFontCollection* fontCollection, GDIPCONST WCHAR* filename ) |
Status Font::AddFontFile(IN const WCHAR *filename | Adds a font file to this private font collection. |
GpStatus WINGDIPAPI GdipPrivateAddMemoryFont(GpFontCollection* fontCollection, GDIPCONST void* memory, INT length ) |
Status Font::AddMemoryFont(IN const VOID *Memory, IN INT \Length const | Adds a font that is contained in system memory to a Windows GDI+ font collection. |
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for