X11workbench Toolkit  1.0
Legacy Font Utilities

Functions

XFontStruct * WBLoadFontX (Display *pDisplay, const char *szFontName, int iFontSize, int iFlags)
 load a font based on a font name, size, and font flags More...
 
XFontStruct * WBCopyFontX (XFontStruct *pFont)
 make a copy of an existing font (best when assigning to a window) More...
 
XFontStruct * WBLoadModifyFontX (Display *pDisplay, const XFontStruct *pOriginal, int iFontSize, int iFlags)
 load and modify a font according to the specified size and flags More...
 
XFontSet WBCopyModifyFontSet (Display *pDisplay, XFontSet fsOrig, int iFontSize, int iFlags)
 copy and modify a font set according to the specified size and flags More...
 
int WBFontAvgCharWidthX (Display *pDisplay, const XFontStruct *pFont)
 Get the average character width for a font. More...
 
int WBFontSetDescent (Display *pDisplay, XFontSet fontSet)
 Get the maximum character descent from a font set. More...
 
int WBFontSetAscent (Display *pDisplay, XFontSet fontSet)
 Get the maximum character ascent from a font set. More...
 
int WBFontSetHeight (Display *pDisplay, XFontSet fontSet)
 Get the maximum character height from a font set. More...
 
int WBFontSetAvgCharWidth (Display *pDisplay, XFontSet fontSet)
 Get the average character width for a font set. More...
 
XCharStruct WBFontSetMaxBounds (Display *pDisplay, XFontSet fontSet)
 Get a 'maximized' copy of the 'max_bounds' member for the font set. More...
 
XFontSet WBFontSetFromFont (Display *pDisplay, const XFontStruct *pFont)
 Creates an 'XFontSet' from an XFontStruct for a given display. More...
 
XFontStruct * WBFontFromFontSet (Display *pDisplay, XFontSet fontSet)
 Creates an 'XFontStruct' from the first font assigned to a Font Set. More...
 
XFontSet WBFontSetFromFontSingle (Display *pDisplay, const XFontStruct *pFont)
 Creates an 'XFontSet' from an XFontStruct for a given display, with only a single font in the set. More...
 
int WBTextWidthX (XFontSet fontSet, const char *szText, int cbText)
 Obtain the pixel width of specified text for a specified XFontSet. More...
 
void WBTextExtentX (XFontSet fontSet, const char *szText, int cbText, WB_EXTENT *pExtent)
 Obtain the pixel extent of specified text for a specified XFontSet. More...
 

Detailed Description

GC Utility functions for legacy (X11) font selection and modification

These are the LEGACY definitions for font helper functions and structures, designed to SPECIFICALY work with 'X11 Core' fonts and rendering. Fonts under X11 (core) are generally difficult to deal with. These utility functions allow you to more easily select a font based on an existing font or a general description of a font, with 'fuzzy' matching.
Additionally there is support for creating 'Font Sets' for use with Xmb, Xwc, and Xutf8 versions of 'Core' text rendering APIs.

Function Documentation

◆ WBCopyFontX()

XFontStruct* WBCopyFontX ( XFontStruct *  pFont)

make a copy of an existing font (best when assigning to a window)

Parameters
pFontThe original font to be copied
Returns
A copy of the original font as an XFontStruct

use this function to make a copy of an existing XFontStruct.

On error this function returns NULL. The caller must free non-NULL return values via XFreeFont()

Header File: font_helper.h

Definition at line 106 of file font_legacy.c.

◆ WBCopyModifyFontSet()

XFontSet WBCopyModifyFontSet ( Display *  pDisplay,
XFontSet  fsOrig,
int  iFontSize,
int  iFlags 
)

copy and modify a font set according to the specified size and flags

Parameters
pDisplayA pointer to the display
fsOrigThe original font set on which to base the new font set
iFontSizeThe font size (see WBLoadFont() for more details)
For a non-zero value, the font size is based on the WBFontFlag_SIZE_xxx flag specified in 'iFlags' An 'iFontSize' value of ZERO copies the font size from the original font specified in 'pOriginal'.
iFlagsVarious WBFontFlags that specify font characteristics. The existing font is modified according to these flags. If the font size is zero, flags that modify the font size will be ignored.
Returns
An XFontSet for the desired font set, or None on error The returned value (if not None) must be free'd using XFreeFontSet()

use this function to select a similar font that differs only by whatever is specified in 'iFontSize' or 'iFlags'. If a matching font is NOT available, a copy of the original font will be returned. Typical use is to 'bold' or 'italicize' an existing font.
The returned value (if not None) will need to be free'd using XFreeFontSet()

Header File: font_helper.h

Definition at line 1359 of file font_legacy.c.

◆ WBFontAvgCharWidthX()

int WBFontAvgCharWidthX ( Display *  pDisplay,
const XFontStruct *  pFont 
)

Get the average character width for a font.

Parameters
pDisplayA pointer to the Display ( NULL uses WBGetDefaultDisplay() )
pFontA pointer to an XFontStruct
Returns
The average width of a character for this font

Use this function to query an XFontStruct about its average character width.

Definition at line 912 of file font_legacy.c.

◆ WBFontFromFontSet()

XFontStruct* WBFontFromFontSet ( Display *  pDisplay,
XFontSet  fontSet 
)

Creates an 'XFontStruct' from the first font assigned to a Font Set.

Parameters
pDisplayA pointer to the Display ( NULL uses WBGetDefaultDisplay() )
fontSetAn XFontSet (may not be 'None')
Returns
An XFontStruct pointer or NULL on error. The caller must free the XFontStruct using XFreeFontStruct() if not NULL.

This function helps to The returned value (if not NULL) will need to be free'd using XFreeFont()

Header File: font_helper.h

Definition at line 1866 of file font_legacy.c.

◆ WBFontSetAscent()

int WBFontSetAscent ( Display *  pDisplay,
XFontSet  fontSet 
)

Get the maximum character ascent from a font set.

Parameters
pDisplayA pointer to the Display ( NULL uses WBGetDefaultDisplay() )
fontSetThe Font Set to query ( None implies the system default font set)
Returns
The ascent of a character for this font

Use this function to query an XFontSet about its maximum ascent. This will typically be derived from all of the individual fonts in the font set.

Definition at line 1055 of file font_legacy.c.

◆ WBFontSetAvgCharWidth()

int WBFontSetAvgCharWidth ( Display *  pDisplay,
XFontSet  fontSet 
)

Get the average character width for a font set.

Parameters
pDisplayA pointer to the Display ( NULL uses WBGetDefaultDisplay() )
fontSetThe Font Set to query ( None implies the system default font set)
Returns
The average width of a character for this font

Use this function to query an XFontSet about its average character width. This will typically be derived from all of the individual fonts in the font set.

Definition at line 1146 of file font_legacy.c.

◆ WBFontSetDescent()

int WBFontSetDescent ( Display *  pDisplay,
XFontSet  fontSet 
)

Get the maximum character descent from a font set.

Parameters
pDisplayA pointer to the Display ( NULL uses WBGetDefaultDisplay() )
fontSetThe Font Set to query ( None implies the system default font set)
Returns
The descent of a character for this font

Use this function to query an XFontSet about its maximum descent. This will typically be derived from all of the individual fonts in the font set.

Definition at line 1013 of file font_legacy.c.

◆ WBFontSetFromFont()

XFontSet WBFontSetFromFont ( Display *  pDisplay,
const XFontStruct *  pFont 
)

Creates an 'XFontSet' from an XFontStruct for a given display.

Parameters
pDisplayA pointer to the Display ( NULL uses WBGetDefaultDisplay() )
pFontA pointer to an XFontStruct
Returns
An XFontSet appropriate to the XFontStruct, or None on error. The returned value (if not None) will need to be free'd using XFreeFontSet()

This function helps to support internationalization through use of the 'Xmb' 'Xwc' and 'Xutf8' versions of the X11 'core' text rendering API functions by creating an 'XFontSet' that matches all of the available character sets for a supplied font specification.
The returned value (if not None) will need to be free'd using XFreeFontSet()

Header File: font_helper.h

Definition at line 1579 of file font_legacy.c.

◆ WBFontSetFromFontSingle()

XFontSet WBFontSetFromFontSingle ( Display *  pDisplay,
const XFontStruct *  pFont 
)

Creates an 'XFontSet' from an XFontStruct for a given display, with only a single font in the set.

Parameters
pDisplayA pointer to the Display ( NULL uses WBGetDefaultDisplay() )
pFontA pointer to an XFontStruct
Returns
An XFontSet appropriate to the XFontStruct, or NULL on error.The returned value (if not None) will need to be free'd using XFreeFontSet()

This function helps to support internationalization through use of the 'Xmb' 'Xwc' and 'Xutf8' versions of the X11 'core' text rendering API functions by creating an 'XFontSet' that matches all of the available character sets for a supplied font specification.
This function differs from WBFontSetFromFont() in that it only adds a SINGLE font to the font set, without any wildcard substitutions, and with a locale of "C".

The returned value (if not None) will need to be free'd using XFreeFontSet()

Header File: font_helper.h

Definition at line 1759 of file font_legacy.c.

◆ WBFontSetHeight()

int WBFontSetHeight ( Display *  pDisplay,
XFontSet  fontSet 
)

Get the maximum character height from a font set.

Parameters
pDisplayA pointer to the Display ( NULL uses WBGetDefaultDisplay() )
fontSetThe Font Set to query ( None implies the system default font set)
Returns
The average width of a character for this font

Use this function to query an XFontSet about its maximum height.

Definition at line 1097 of file font_legacy.c.

◆ WBFontSetMaxBounds()

XCharStruct WBFontSetMaxBounds ( Display *  pDisplay,
XFontSet  fontSet 
)

Get a 'maximized' copy of the 'max_bounds' member for the font set.

Parameters
pDisplayA pointer to the Display ( NULL uses WBGetDefaultDisplay() )
fontSetThe Font Set to query ( None implies the system default font set)
Returns
A copy of a 'maximized' XCharStruct where all members are 'maximum' values of the entire font set

Use this function to query an XFontSet about its maximum bounds. This will typically be derived from all of the individual fonts in the font set.

Definition at line 1206 of file font_legacy.c.

◆ WBLoadFontX()

XFontStruct* WBLoadFontX ( Display *  pDisplay,
const char *  szFontName,
int  iFontSize,
int  iFlags 
)

load a font based on a font name, size, and font flags

Parameters
pDisplayA pointer to the display
szFontNameA 0-byte terminated ASCII string specifying the desired font name
iFontSizeThe font size, > 0 for height, < 0 for width, 0 for 'do not care'
the font size is based on the WBFontFlag_SIZE_xxx flag specified in 'iFlags'
iFlagsVarious WBFontFlags that specify font characteristics
Returns
An XFontStruct pointer for the desired font, or NULL on error.

font mapping helper - uses size, italic, bold, 'flags' and font name to determine "the best font" based on a simple mapping algorithm.
negative 'iFontSize' is the average font width
Positive 'iFontSize' is the height (including ascend/descend)
A value of '0' is considered to be a 'wildcard' match. Use a positive 'iFontSize' for more precise font measurement.
On error this function returns NULL. The caller must free non-NULL return values via XFreeFont()

Header File: font_helper.h

Definition at line 772 of file font_legacy.c.

◆ WBLoadModifyFontX()

XFontStruct* WBLoadModifyFontX ( Display *  pDisplay,
const XFontStruct *  pOriginal,
int  iFontSize,
int  iFlags 
)

load and modify a font according to the specified size and flags

Parameters
pDisplayA pointer to the display
pOriginalThe original font on which to base the new font
iFontSizeThe font size (see WBLoadFont() for more details)
For a non-zero value, the font size is based on the WBFontFlag_SIZE_xxx flag specified in 'iFlags' An 'iFontSize' value of ZERO copies the font size from the original font specified in 'pOriginal'.
iFlagsVarious WBFontFlags that specify font characteristics. The existing font is modified according to these flags. If the font size is zero, flags that modify the font size will be ignored.
Returns
An XFontStruct pointer for the desired font, or NULL on error

use this function to select a similar font that differs only by whatever is specified in 'iFontSize' or 'iFlags'. If a matching font is NOT available, a copy of the original font will be returned. Typical use is to 'bold' or 'italicize' an existing font.
On error this function returns NULL. The caller must free non-NULL return values via XFreeFont()

Header File: font_helper.h

Definition at line 1269 of file font_legacy.c.

◆ WBTextExtentX()

void WBTextExtentX ( XFontSet  fontSet,
const char *  szText,
int  cbText,
WB_EXTENT pExtent 
)

Obtain the pixel extent of specified text for a specified XFontSet.

Parameters
fontSetAn XFontSet, as returned by WBFontSetFromFont (or similar)
szTextA (const) pointer to a Multi-Byte (or UTF8 string) string
cbTextThe total length of the text pointed to by szText (negative value to use a zero-byte terminator)
pExtentA pointer to a WB_EXTENT structure that receives the text extent. This will be the logical text extent, for spacing purposes

Use this function to determine the correct 'display' width and height of a UTF8 or Multi-Byte character string. It calculates the 'logical' extent using either XmbTextExtents() or Xutf8TextExtents() (as applicable) and returns the width/height of the bounding rectangle for the text.

Header File: font_helper.h

Definition at line 1941 of file font_legacy.c.

◆ WBTextWidthX()

int WBTextWidthX ( XFontSet  fontSet,
const char *  szText,
int  cbText 
)

Obtain the pixel width of specified text for a specified XFontSet.

Parameters
fontSetAn XFontSet, as returned by WBFontSetFromFont (or similar)
szTextA (const) pointer to a Multi-Byte (or UTF8 string) string
cbTextThe total length of the text pointed to by szText (negative value to use a zero-byte terminator)
Returns
The width of the specified text, in pixels (similar to XTextWidth but for MB and/or UTF8 characters using a font set)

Use this function to determine the correct 'display' width of a UTF8 or Multi-Byte character string.

Header File: font_helper.h

Definition at line 1906 of file font_legacy.c.