Home COM GDI+ WebBrowser Data Access 

Font Functions (GDI+)

 

 

A Font object is used when drawing strings.

 

Return Values

If the function succeeds, it returns Ok, which is an element of the Status enumeration.

 

If the function fails, it returns one of the other elements of the Status enumeration.

 

GdipCloneFont

 

Description

Creates a new Font object based on this Font object.

Syntax

GpStatus WINGDIPAPI GdipCloneFont(

    GpFont* font,

    GpFont** cloneFont

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCloneFont ( _

    BYVAL pFont AS DWORD, _

    BYREF cloneFont AS DWORD _

) AS LONG

Parameters

 

font

[in] Pointer to the Font object to clone.

cloneFont

[out] Pointer to a variable that receives a pointer to the new created Font object.

 

GdipCreateFont

 

Description

Creates a Font object based on a FontFamily object, a size, a font style, and a unit of measurement.

Syntax

GpStatus WINGDIPAPI GdipCreateFont(

    GDIPCONST GpFontFamily *fontFamily,

    REAL emSize,

    INT style,

    Unit unit,

    GpFont **font

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateFont ( _

    BYVAL fontFamily AS DWORD, _

    BYVAL emSize AS SINGLE, _

    BYVAL lStyle AS LONG, _

    BYVAL unit AS LONG, _

    BYREF pFont AS DWORD _

) AS LONG

Parameters

 

family

[in] Pointer to a FontFamily object that specifies information such as the string that identifies the font family and the font family's text metrics measured in design units.

emSize

[in] Single precision value that specifies the em size of the font measured in the units specified in the unit parameter.

style

[in] Long integer value that specifies the style of the typeface. This value must be an element of the FontStyle enumeration or the result of a bitwise OR applied to two or more of these elements. For example, %FontStyleBold OR %FontStyleUnderline OR %FontStyleStrikeout sets the style as a combination of the three styles. The default value is %FontStyleRegular.

unit

[in] Element of the Unit enumeration that specifies the unit of measurement for the font size. The default value is UnitPoint.

font

[out] Pointer to a variable that receives a pointer to the new created Font object.

 

GdipCreateFontFromDC

 

Description

Creates a Font object based on the Microsoft® Windows® Graphics Device Interface (GDI) font object that is currently selected into a specified device context. This constructor is provided for compatibility with GDI.

Syntax

GpStatus WINGDIPAPI GdipCreateFontFromDC(

    HDC hdc,

    GpFont **font

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateFontFromDC ( _

    BYVAL hDC AS DWORD, _

    BYREF pfont AS DWORD _

) AS LONG

Parameters

 

hdc

[in] Handle to a Windows device context that has a font selected. A handle is a number that Windows uses internally to reference an object.

font

[out] Pointer to a variable that receives a pointer to the new created Font object.

Remarks

In most cases when you obtain a device context handle by calling the GGdipGetDC function, the device context will not have a font selected. If you pass such a handle to this constructor, the constructor will fail.

A device context is a structure that is maintained internally. It is associated with a particular device, such as a video monitor or a printer. There is usually one device context associated with each window displayed on a video monitor. A device context contains some graphics attributes used by GDI+.

 

GdipCreateFontFromLogFontA

 

Description

Creates a Font object directly from a Microsoft® Windows® Graphics Device Interface (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.

Syntax

GpStatus WINGDIPAPI GdipCreateFontFromLogfontA(

    HDC hdc,

    GDIPCONST LOGFONTA *logfont,

    GpFont **font

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateFontFromLogfontA ( _

    BYVAL hDC AS DWORD, _

    BYREF pLogfont AS LOGFONT, _

    BYREF pFont AS DWORD _

) AS LONG

Parameters

 

hdc

[in] Handle to a Windows device context. A handle is a number that Windows uses internally to reference an object.

logfont

[in] Pointer to a LOGFONTA structure that contains attributes of the font. The LOGFONTA structure is the one-byte character version of the logical font.

font

[out] Pointer to a variable that receives a pointer to the new created Font object.

Remarks

A device context is a structure that is maintained internally. It is associated with a particular device, such as a video monitor or a printer. There is usually one device context associated with each window displayed on a video monitor. A device context contains some graphics attributes used by GDI+.

A LOGFONTA structure is a GDI structure. GDI+ uses only some of the attributes contained in this structure.

 

GdipCreateFontFromLogFontW

 

Description

Creates a Font object directly from a Microsoft® Windows® Graphics Device Interface (GDI) logical font. The GDI logical font is a LOGFONTW structure, which is the wide character version of a logical font. This constructor is provided for compatibility with GDI.

Syntax

GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(

    HDC hdc,

    GDIPCONST LOGFONTW *logfont,

    GpFont **font

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateFontFromLogfontW ( _

    BYVAL hDC AS DWORD, _

    BYREF pLogfont AS LOGFONTW, _

    BYREF pFont AS DWORD _

) AS LONG

Parameters

 

hdc

[in] Handle to a Windows device context. A handle is a number that Windows uses internally to reference an object.

logfont

[in] Pointer to a LOGFONTW structure that contains attributes of the font. The LOGFONTW structure is the wide character version of the logical font.

font

[out] Pointer to a variable that receives a pointer to the new created Font object.

Remarks

A device context is a structure that is maintained internally. It is associated with a particular device, such as a video monitor or a printer. There is usually one device context associated with each window displayed on a video monitor. A device context contains some graphics attributes used by GDI+.

A LOGFONTW structure is a GDI structure. GDI+ uses only some of the attributes contained in this structure.

 

GdipDeleteFont

 

Description

Deletes the specified Font object.

Syntax

GpStatus WINGDIPAPI GdipDeleteFont(

    GpFont* font,

);

PowerBASIC Syntax

DECLARE FUNCTION GdipDeleteFont ( _

    BYVAL pFont AS DWORD _

) AS LONG

Parameters

 

font

[in] Pointer to the Font object to delete.

 

GdipDeletePrivateFontCollection

 

Description

Deletes the specified PrivateFontCollection object.

Syntax

GpStatus WINGDIPAPI GdipDeletePrivateFontCollection(

    GpFontCollection** fontCollection

);

PowerBASIC Syntax

DECLARE FUNCTION GdipDeletePrivateFontCollection ( _

    BYREF fontCollection AS DWORD _

) AS LONG

Parameters

 

fontCollection

[in] Pointer to the PrivateFontCollection object to delete.

 

GdipGetFamily

 

Description

Gets the font family on which this font is based.

Syntax

GpStatus WINGDIPAPI GdipGetFamily(

    GpFont *font,

    GpFontFamily **family

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetFamily ( _

    BYVAL pFont AS DWORD, _

    BYREF Family AS DWORD _

) AS LONG

Parameters

 

font

[in] Pointer to the Font object.

family

[out] Pointer to a variable thatg receives a pointer to the font family.

 

GdipGetFontCollectionFamilyCount

 

Description

Gets the number of font families contained in this font collection.

Syntax

GpStatus WINGDIPAPI GdipGetFontCollectionFamilyCount(

    GpFontCollection* fontCollection,

    INT * numFound

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetFontCollectionFamilyCount ( _

    BYVAL fontCollection AS DWORD, _

    BYREF numFound AS LONG _

) AS LONG

Parameters

 

fontCollection

[in] Pointer to the font collection object.

numFound

[out] Pointer to a variable that receives the number of font families contained in this font collection.

Remarks

A font family consists of a single font type with related styles. An example of a single font type is Arial Regular. An example of a font family is a set of fonts containing Arial Regular, Arial Italic, and Arial Bold style fonts.

 

GdipGetFontCollectionFamilyList

 

Description

Gets the font families contained in this font collection.

Syntax

GpStatus WINGDIPAPI GdipGetFontCollectionFamilyList(

    GpFontCollection* fontCollection,

    INT numSought,

    GpFontFamily* gpfamilies[],

    INT* numFound

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetFontCollectionFamilyList ( _

    BYVAL fontCollection AS DWORD, _

    BYVAL numSought AS LONG, _

    BYREF families AS DWORD, _

    BYREF numFound AS LONG _

) AS LONG

Parameters

 

fontCollection

[in] Pointer to the font collection object.

numSought

[in] Long integer value  that specifies the number of font families in this font collection.

gpfamilies

[out] Pointer to an array that receives the FontFamily objects.

numFound

[out] Pointer to a LONG that receives the number of font families found in this collection. This number should be the same as the numSought value.

Remarks

A font family consists of a single font type with related styles. An example of a single font type is Arial Regular. An example of a font family is a set of fonts containing Arial Regular, Arial Italic, and Arial Bold style fonts.

 

GdipGetFontHeight

 

Description

Gets this line spacing of the 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.

Syntax

GpStatus WINGDIPAPI GdipGetFontHeight(

    GDIPCONST GpFont *font,

    GDIPCONST GpGraphics *graphics,

    REAL *height

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetFontHeight ( _

    BYVAL pFont AS DWORD, _

    BYVAL graphics AS DWORD, _

    BYREF nHeight AS SINGLE _

) AS LONG

Parameters

 

font

[in] Pointer to the Font object.

graphics

[in] Pointer to a Graphics object whose unit and vertical resolution are used in the height calculation.

height

[out] Pointer to a variab le that receives te line spacing of this font.

Remarks

If the font unit is set to anything other than UnitPixel, the height, in pixels, is calculated using the vertical resolution of the specified Graphics object. For example, suppose the font unit is inches and the font size is 0.3. Also suppose that for the corresponding font family, the em height is 2048 and the line spacing is 2355. If the unit of the Graphics object is UnitPixel and the vertical resolution of the Graphics object is 96 dots per inch, the height is calculated as follows:

 

2355*(0.3/2048)*96 = 33.1171875

 

Continuing with the same example, suppose the unit of the Graphics object is something other than UnitPixel, say UnitMillimeter. Then (using 1 inch = 25.4 millimeters) the height, in millimeters, is calculated as follows:

 

2355*(0.3/2048)25.4 = 8.762256

 

GdipGetFontHeightGivenDPI

 

Description

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.

Syntax

GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(

    GDIPCONST GpFont *font,

    REAL dpi,

    REAL *height

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetFontHeightGivenDPI ( _

    BYVAL pFont AS DWORD, _

    BYVAL dpi AS SINGLE, _

    BYREF nHeight AS SINGLE _

) AS LONG

Parameters

 

font

[in] Pointer to the Font object.

dpi

in] Single precision value that specifies the vertical resolution, in dots per inch, of the device that displays the font.

height

[out] Pointer to a variable that receives the line spacing of the font in pixels.

Remarks

If the font unit is set to anything other than UnitPixel, the height, in pixels, is calculated using the specified vertical resolution. For example, suppose the font unit is inches and the font size is 0.3. Also suppose that for the corresponding font family, the em height is 2048 and the line spacing is 2355. If the specified vertical resolution is 96 dots per inch, the height is calculated as follows:

 

2355*(0.3/2048)*96 = 33.1171875

 

GdipGetFontSize

 

Description

Returns the font size (commonly called the em size) of this Font object. The size is in the units of this Font object.

Syntax

GpStatus WINGDIPAPI GdipGetFontSize(

    GpFont *font,

    REAL *size

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetFontSize ( _

    BYVAL pFont AS DWORD, _

    BYREF psize AS SINGLE _

) AS LONG

Parameters

 

font

[in] Pointer to the Font object.

size

[out] Pointer to a variable that receives the font size is in the units of this Font object.

 

GdipGetFontStyle

 

Description

Gets the style of this font's typeface.

Syntax

GpStatus WINGDIPAPI GdipGetFontStyle(

    GpFont *font,

    INT *style

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetFontStyle ( _

    BYVAL pFont AS DWORD, _

    BYREF pStyle AS LONG _

) AS LONG

Parameters

 

font

[in] Pointer to the Font object.

style

[out] Pointer to a variable that receives the style of this font's typeface. The value is an element of the FontStyle enumeration or the result of a bitwise OR applied to two or more elements of the FontStyle enumeration.

 

GdipGetFontUnit

 

Description

Returns the unit of measure of this Font object.

Syntax

GpStatus WINGDIPAPI GdipGetFontUnit(

    GpFont *font,

    Unit *unit

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetFontUnit ( _

    BYVAL pFont AS DWORD, _

    BYREF unit AS LONG _

) AS LONG

Parameters

 

font

[in] Pointer to the Font object.

unit

[out] Pointer to a variable that receives one of the elements of the Unit enumeration.

 

GdipGetLogFontA

 

Description

Uses a LOGFONTA structure to get the attributes of this Font object.

Syntax

GpStatus WINGDIPAPI GdipGetLogFontA(

    GpFont * font,

    GpGraphics *graphics,

    LOGFONTA * logfontA

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetLogFontA ( _

    BYVAL pFont AS DWORD, _

    BYVAL graphics AS DWORD, _

    BYREF plogfont AS LOGFONT _

) AS LONG

Parameters

 

font

[in] Pointer to the Font object.

g

[in] Pointer to a Graphics object that contains attributes of the display device.

logfontA

[out] Pointer to a LOGFONTA structure that receives the font attributes.

 

GdipGetLogFontW

 

Description

Uses a LOGFONTW structure to get the attributes of this Font object.

Syntax

GpStatus WINGDIPAPI GdipGetLogFontW(

    GpFont * font,

    GpGraphics *graphics,

    LOGFONTW * logfontW

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetLogFontW ( _

    BYVAL pFont AS DWORD, _

    BYVAL graphics AS DWORD, _

    BYREF plogfontw AS LOGFONTW _

) AS LONG

Parameters

 

font

[in] Pointer to the Font object.

g

[in] Pointer to a Graphics object that contains attributes of the video display.

logfontW

[out] Pointer to a LOGFONTW structure that receives the font attributes.

 

GdipNewInstalledFontCollection

 

Description

Creates an InstalledFontCollection object.

Syntax

GpStatus WINGDIPAPI GdipNewInstalledFontCollection(

    GpFontCollection** fontCollection

);

PowerBASIC Syntax

DECLARE FUNCTION GdipNewInstalledFontCollection ( _

    BYREF fontCollection AS DWORD _

) AS LONG

Parameters

 

fontCollection

[out] Pointer to a variable that receives a pointer to the InstalledFontCollection object.

 

GdipNewPrivateFontCollection

 

Description

Creates an PrivateFontCollection object.

Syntax

GpStatus WINGDIPAPI GdipNewPrivateFontCollection(

    GpFontCollection** fontCollection

);

PowerBASIC Syntax

DECLARE FUNCTION GdipNewPrivateFontCollection ( _

    BYREF fontCollection AS DWORD _

) AS LONG

Parameters

 

fontCollection

[out] Pointer to a variable that receives a pointer to the InstalledFontCollection object.

 

GdipPrivateAddFontFile

 

Description

Adds a font file to this private font collection.

Syntax

GpStatus WINGDIPAPI GdipPrivateAddFontFile(

    GpFontCollection* fontCollection,

    GDIPCONST WCHAR* filename

);

PowerBASIC Syntax

DECLARE FUNCTION GdipPrivateAddFontFile ( _

    BYVAL fontCollection AS DWORD, _

    BYVAL pFilename AS STRING _

) AS LONG

Parameters

 

fontCollection

[in] Pointer to the font collection object.

filename

[in] Pointer to a null-terminated unicode string that specifies the name of a font file.

 

GdipPrivateAddMemoryFont

 

Description

Adds a font that is contained in system memory to a Microsoft® Windows® GDI+ font collection.

Syntax

GpStatus WINGDIPAPI GdipPrivateAddMemoryFont(

    GpFontCollection* fontCollection,

    GDIPCONST void* memory,

    INT length

);

PowerBASIC Syntax

DECLARE FUNCTION GdipPrivateAddMemoryFont ( _

    BYVAL fontCollection AS DWORD, _

    BYVAL memory AS DWORD, _

    BYVAL length AS LONG _

) AS LONG

Parameters

 

fontCollection

[in] Pointer to the font collection object.

memory

[in] Pointer to a font that is contained in memory.

length

[in] Long integer value that specifies the number of bytes of data in the font.

 

Page last updated on Monday, 11 December 2006 11:03:17 +0100