X11workbench Toolkit  1.0
font_helper.h File Reference

Definition file for font helper functions and structures. More...

Go to the source code of this file.

Data Structures

struct  WBFont
 An allocated structure containing XFontStruct, XFontInfo, and XftFont [as applicable] for a specified font. More...
 
struct  WBFontInfo
 Internal structure, caching font information (mostly for legacy font support) More...
 

Macros

#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
 

Typedefs

typedef struct s_WB_EXTENT WB_EXTENT
 internal wrapper struct for 'extent' definition More...
 
typedef struct WBFontWB_FONT
 An allocated structure containing XFontStruct, XFontInfo, and XftFont [as applicable] for a specified font. More...
 
typedef const struct WBFontWB_FONTC
 a 'const' version of WB_FONT - note that this CAN actually be written to, so it's not truly 'const'. More...
 
typedef struct WBFontInfo WB_FONT_INFO
 Internal structure, caching font information (mostly for legacy font support) More...
 

Enumerations

enum  WBFontFlags {
  WBFontFlag_PITCH_FIXED = 1,
  WBFontFlag_PITCH_VARIABLE = 2,
  WBFontFlag_PITCH_CONDENSED = 4,
  WBFontFlag_PITCH_ANY = 0,
  WBFontFlag_PITCH_MASK = 7,
  WBFontFlag_STYLE_SANS = 8,
  WBFontFlag_STYLE_SERIF = 0x10,
  WBFontFlag_Reserved20 = 0x20,
  WBFontFlag_Reserved40 = 0x40,
  WBFontFlag_STYLE_ANY = 0,
  WBFontFlag_STYLE_MASK = 0x78,
  WBFontFlag_RASTER = 0x80,
  WBFontFlag_FREETYPE = 0x100,
  WBFontFlag_Reserved200 = 0x200,
  WBFontFlag_FNDRY_ANY = 0,
  WBFontFlag_FNDRY_MASK = 0x380,
  WBFontFlag_SIZE_PIXELS = 0,
  WBFontFlag_SIZE_POINTS = 0x400,
  WBFontFlag_SIZE_TWIPS = 0x800,
  WBFontFlag_SIZE_Reserved = 0xc00,
  WBFontFlag_SIZE_MASK = 0xc00,
  WBFontFlag_WT_ANY = 0,
  WBFontFlag_WT_REGULAR = 0x1000,
  WBFontFlag_WT_MEDIUM = 0x2000,
  WBFontFlag_WT_DEMIBOLD = 0x3000,
  WBFontFlag_WT_BOLD = 0x4000,
  WBFontFlag_WT_Reserved5 = 0x5000,
  WBFontFlag_WT_Reserved6 = 0x6000,
  WBFontFlag_WT_MASK = 0x7000,
  WBFontFlag_SLANT_REGULAR = 0x10000,
  WBFontFlag_SLANT_OBLIQUE = 0x20000,
  WBFontFlag_SLANT_ITALIC = 0x30000,
  WBFontFlag_SLANT_ANY = 0,
  WBFontFlag_SLANT_MASK = 0x30000,
  WBFontFlag_WIDTH_NORMAL = 0x40000,
  WBFontFlag_WIDTH_SEMICOND = 0x80000,
  WBFontFlag_WIDTH_Reserved = 0xc0000,
  WBFontFlag_WIDTH_ANY = 0,
  WBFontFlag_WIDTH_MASK = 0xc0000,
  WBFontFlag_REG_ISO8859 = 0x100000,
  WBFontFlag_REG_ISO646_1991 = 0x200000,
  WBFontFlag_REG_ASCII = 0x300000,
  WBFontFlag_REG_FNTSPECIFIC = 0x400000,
  WBFontFlag_REG_MISC = 0x500000,
  WBFontFlag_REG_GB2312_1980 = 0x600000,
  WBFontFlag_REG_ADOBE = 0x700000,
  WBFontFlag_REG_Reserved8 = 0x800000,
  WBFontFlag_REG_Reserved9 = 0x900000,
  WBFontFlag_REG_ReservedA = 0xa00000,
  WBFontFlag_REG_ReservedB = 0xb00000,
  WBFontFlag_REG_ReservedC = 0xc00000,
  WBFontFlag_REG_ReservedD = 0xd00000,
  WBFontFlag_REG_ReservedE = 0xe00000,
  WBFontFlag_REG_ReservedF = 0xf00000,
  WBFontFlag_REG_MASK = 0xf00000,
  WBFontFlag_WHATEVER = 0
}
 Font 'flag' enumeration. More...
 

Functions

static void WBDumpFontStruct (const XFontStruct *pFont)
 debug function to dump font struct members
 
static void WBDumpMatchingFontNames (Display *pDisplay, const char *szFontName)
 debug function to dump matching font names
 
static void WBDumpFontSet (Display *pDisplay, XFontSet fontSet)
 debug function to dump font set members
 
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...
 
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...
 
void WBDumpFontInfo (const char *pSpec)
 Dump debug information about fonts according to pSpec. More...
 

Detailed Description

Definition file for font helper functions and structures.

This is the definition file for font helper functions and structures, designed to SPECIFICALY work with 'X11 Core' fonts and rendering. Compatibility and support for 'Xft' fonts and rendering is currently 'reserved for future implementation'. 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.

The font_helper uses the 'classic' X11 fonts. If you need true-type fonts, you will need to use the Xft interface from the 'FreeType' library to load and render them. Xft uses a completely different font set than the ones provided by the 'classic' font interface.

Definition in file font_helper.h.