X11workbench Toolkit
1.0
|
Modules | |
Legacy Font Utilities | |
Font Structures | |
Functions | |
void | __internal_font_helper_init (void) |
initialization for font helper - call once at start of program (WBInit() does this for you) | |
void | __internal_font_helper_exit (void) |
un-initialization for font helper - call once at end of program (WBExit() does this for you) | |
int | WBFontEnableAntiAlias (void) |
returns non-zero value if certain fonts should be anti-aliased when rendered More... | |
void | WBFontSetEnableAntiAlias (int bEnable) |
returns non-zero value if certain fonts should be anti-aliased when rendered More... | |
void | WBFreeFont (Display *pDisplay, WB_FONT pFont) |
free a WB_FONT that was created using one of the WBFont APIs More... | |
WB_FONT | WBCopyFont (Display *pDisplay, WB_FONTC pFont) |
make a copy of an existing font (best when assigning to a window) More... | |
WB_FONT | WBCopyModifyFont (Display *pDisplay, WB_FONTC pOriginal, int iFontSize, int iFlags) |
load and modify a font according to the specified size and flags More... | |
WB_FONT | WBLoadFont (Display *pDisplay, const char *szFontName, int iFontSize, int iFlags) |
load a WB_FONT font object based on a font name, size, and font flags More... | |
int | WBFontAvgCharWidth (WB_FONTC pFont) |
Get the average character width for a font. More... | |
int | WBFontMaxCharWidth (WB_FONTC pFont) |
Get the maximum character width for a font. More... | |
int | WBFontDescent (WB_FONTC pFont) |
Get the maximum character descent from a WB_FONT. More... | |
int | WBFontAscent (WB_FONTC pFont) |
Get the maximum character ascent from a WB_FONT. More... | |
int | WBFontHeight (WB_FONTC pFont) |
Get the maximum character height from a WB_FONT. More... | |
XCharStruct | WBFontMaxBounds (WB_FONTC pFont) |
Get a 'maximized' copy of 'max_bounds' (applicable to all font faces in the WB_FONT) More... | |
int | WBTextWidth (WB_FONTC pFont, const char *szText, int cbText) |
Obtain the pixel width of specified text for a specified WB_FONT. More... | |
void | WBTextExtent (WB_FONTC pFont, const char *szText, int cbText, WB_EXTENT *pExtent) |
Obtain the pixel extent of specified text for a specified XFontSet. More... | |
#define | WB_TEXT_EXTENTS Xutf8TextExtents |
#define | WB_TEXT_ESCAPEMENT Xutf8TextEscapement |
#define | WB_DRAW_STRING Xutf8DrawString |
#define | WB_DRAW_TEXT Xutf8DrawText |
#define | WB_LOOKUP_STRING Xutf8LookupString |
GC Utility/API functions for WB_FONT mid-level font selection and modification
These are the definitions for font helper functions and structures, designed to SPECIFICALY work with 'Xft' freetype fonts and rendering, but also support legacy (X11) fonts and font sets. For maximum compatibility, they have been abstracted using the (new) WB_FONT/WB_FONTC objects, particularly for legacy implementations that do not have the Xft library installed, and for those fonts that are native X11 fonts or font sets.
#define WB_DRAW_STRING Xutf8DrawString |
abstraction for Xutf8DrawString or XmbDrawString
Definition at line 101 of file font_helper.h.
#define WB_DRAW_TEXT Xutf8DrawText |
abstraction for Xutf8DrawText or XmbDrawText
Definition at line 102 of file font_helper.h.
#define WB_LOOKUP_STRING Xutf8LookupString |
abstraction for Xutf8LookupString or XmbLookupString
Definition at line 103 of file font_helper.h.
#define WB_TEXT_ESCAPEMENT Xutf8TextEscapement |
abstraction for Xutf8TextEscapement or XmbTextEscapement
Definition at line 100 of file font_helper.h.
#define WB_TEXT_EXTENTS Xutf8TextExtents |
abstraction for Xutf8TextExtents or XmbTextExtents
Definition at line 99 of file font_helper.h.
enum WBFontFlags |
Font 'flag' enumeration.
An enumeration of 'Font Flags' used by WBLoadFont() and WBCopyModifyFont() to load and/or modify a font according to the desired specifications.
Definition at line 479 of file font_helper.h.
make a copy of an existing font (best when assigning to a window)
pDisplay | A pointer to the display |
pFont | The original WB_FONTC to be copied |
use this function to make a copy of an existing WB_FONT.
On error this function returns NULL. The caller must free non-NULL return values via WBFreeFont()
Header File: font_helper.h
Definition at line 168 of file font_helper.c.
load and modify a font according to the specified size and flags
pDisplay | A pointer to the display |
pOriginal | The original WB_FONTC on which to base the new font |
iFontSize | The 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'. |
iFlags | Various 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. |
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 WBFreeFont()
Header File: font_helper.h
Definition at line 660 of file font_helper.c.
int WBFontAscent | ( | WB_FONTC | pFont | ) |
Get the maximum character ascent from a WB_FONT.
pFont | The WB_FONT to query ( NULL implies the system default WB_FONT) |
Use this function to query a WB_FONT about its maximum ascent.
Definition at line 495 of file font_helper.c.
int WBFontAvgCharWidth | ( | WB_FONTC | pFont | ) |
Get the average character width for a font.
pFont | A pointer to a WB_FONTC |
Use this function to query a WB_FONT about its average character width.
Definition at line 343 of file font_helper.c.
int WBFontDescent | ( | WB_FONTC | pFont | ) |
Get the maximum character descent from a WB_FONT.
pFont | The WB_FONT to query ( NULL implies the system default WB_FONT) |
Use this function to query a WB_FONT about its maximum descent.
Definition at line 443 of file font_helper.c.
int WBFontEnableAntiAlias | ( | void | ) |
returns non-zero value if certain fonts should be anti-aliased when rendered
Anti-aliasing can carry with it a performance degradation due to the somewhat slow process of getting rendering information from the X server. if the Render extension is present, and libXft is also present, then the Xft library uses the Render extension to do the anti-aliasing. Otherwise, it's done "the hard way" which can be slow.
Definition at line 157 of file font_helper.c.
int WBFontHeight | ( | WB_FONTC | pFont | ) |
Get the maximum character height from a WB_FONT.
pFont | The WB_FONT to query ( NULL implies the system default font set) |
Use this function to query a WB_FONT about its maximum height.
Definition at line 546 of file font_helper.c.
XCharStruct WBFontMaxBounds | ( | WB_FONTC | pFont | ) |
Get a 'maximized' copy of 'max_bounds' (applicable to all font faces in the WB_FONT)
pFont | The WB_FONT to query ( NULL implies the system default WB_FONT) |
Use this function to query a WB_FONT about its maximum bounds. This will typically be derived from all of the individual font faces within the object
Definition at line 592 of file font_helper.c.
int WBFontMaxCharWidth | ( | WB_FONTC | pFont | ) |
Get the maximum character width for a font.
pFont | A pointer to a WB_FONTC |
Use this function to query a WB_FONT about its maximum character width.
Definition at line 394 of file font_helper.c.
void WBFontSetEnableAntiAlias | ( | int | bEnable | ) |
returns non-zero value if certain fonts should be anti-aliased when rendered
bEnable | A non-zero value if certain fonts should be anti-aliased; zero if they should not be. This generally applies to legacy (X11) fonts only. |
Anti-aliasing can carry with it a performance degradation due to the somewhat slow process of getting rendering information from the X server. if the Render extension is present, and libXft is also present, then the Xft library uses the Render extension to do the anti-aliasing. Otherwise, it's done "the hard way" which can be slow.
Definition at line 162 of file font_helper.c.
void WBFreeFont | ( | Display * | pDisplay, |
WB_FONT | pFont | ||
) |
free a WB_FONT that was created using one of the WBFont APIs
pDisplay | A pointer to the display |
pFont | The WB_FONT to be freed |
use this function to free up resources associated with an existing WB_FONT, invalidating the pointer.
Header File: font_helper.h
Definition at line 250 of file font_helper.c.
WB_FONT WBLoadFont | ( | Display * | pDisplay, |
const char * | szFontName, | ||
int | iFontSize, | ||
int | iFlags | ||
) |
load a WB_FONT font object based on a font name, size, and font flags
pDisplay | A pointer to the display |
szFontName | A 0-byte terminated ASCII string specifying the desired font name |
iFontSize | The 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' |
iFlags | Various WBFontFlags that specify font characteristics |
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 WBFreeFont()
Header File: font_helper.h
Definition at line 291 of file font_helper.c.
Obtain the pixel extent of specified text for a specified XFontSet.
pFont | A WB_FONT object |
szText | A (const) pointer to a Multi-Byte (or UTF8 string) string |
cbText | The total length of the text pointed to by szText (negative value to use a zero-byte terminator) |
pExtent | A 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 790 of file font_helper.c.
int WBTextWidth | ( | WB_FONTC | pFont, |
const char * | szText, | ||
int | cbText | ||
) |
Obtain the pixel width of specified text for a specified WB_FONT.
pFont | A WB_FONT object |
szText | A (const) pointer to a Multi-Byte (or UTF8 string) string |
cbText | The total length of the text pointed to by szText (negative value to use a zero-byte terminator) |
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 747 of file font_helper.c.