X11 Work Bench Toolkit  1.0
font_helper.h
Go to the documentation of this file.
1 
2 // __ _ _ _ _ //
3 // / _| ___ _ __ | |_ | |__ ___ | | _ __ ___ _ __ | |__ //
4 // | |_ / _ \ | '_ \ | __| | '_ \ / _ \| || '_ \ / _ \| '__|| '_ \ //
5 // | _|| (_) || | | || |_ | | | || __/| || |_) || __/| | _ | | | | //
6 // |_| \___/ |_| |_| \__|_____|_| |_| \___||_|| .__/ \___||_|(_)|_| |_| //
7 // |_____| |_| //
8 // basic font enumeration and selection //
9 // //
11 
12 /*****************************************************************************
13 
14  X11workbench - X11 programmer's 'work bench' application and toolkit
15  Copyright (c) 2010-2016 by Bob Frazier (aka 'Big Bad Bombastic Bob')
16  all rights reserved
17 
18  DISCLAIMER: The X11workbench application and toolkit software are supplied
19  'as-is', with no warranties, either implied or explicit.
20  Any claims to alleged functionality or features should be
21  considered 'preliminary', and might not function as advertised.
22 
23  BSD-like license:
24 
25  There is no restriction as to what you can do with this software, so long
26  as you include the above copyright notice and DISCLAIMER for any distributed
27  work that is equal to or derived from this one, along with this paragraph
28  that explains the terms of the license if the source is also being made
29  available. A "derived work" describes a work that uses a significant portion
30  of the source files or algorithms that are included with this one.
31  Specifically excluded from this are files that were generated by the software,
32  or anything that is included with the software that is part of another package
33  (such as files that were created or added during the 'configure' process).
34  Specifically included is the use of part or all of any of the X11 workbench
35  toolkit source or header files in your distributed application. If you do not
36  ship the source, the above copyright statement is still required to be placed
37  in a reasonably prominent place, such as documentation, splash screens, and/or
38  'about the application' dialog boxes.
39 
40  Use and distribution are in accordance with GPL, LGPL, and/or the above
41  BSD-like license. See COPYING and README files for more information.
42 
43 
44  Additional information at http://sourceforge.net/projects/X11workbench
45 
46 ******************************************************************************/
47 
66 #ifndef _FONT_HELPER_H_INCLUDED_
67 #define _FONT_HELPER_H_INCLUDED_
68 
69 #ifdef __cplusplus
70 extern "C" {
71 #endif // __cplusplus
72 
73 
77 // UTF-8 HANDLING
78 // X11 has XFree86 extensions with 'Xutf8' versions of a lot of things
79 // which is only applicable with the following
80 //#ifdef X_HAVE_UTF8_STRING
81 // I use the utf8 version
82 // etc.
83 //
84 // Unfortunately many things that I use don't have that available
85 // like XTextWidth for one (maybe I could use Xutf8TextExtents?)
86 // Using Xmb and Xwc equivalent methods should work on Interix
87 //
88 #if defined(X_HAVE_UTF8_STRING) || defined(__DOXYGEN__)
89 
90 #define WB_TEXT_EXTENTS Xutf8TextExtents
91 #define WB_TEXT_ESCAPEMENT Xutf8TextEscapement
92 #define WB_DRAW_STRING Xutf8DrawString
93 #define WB_DRAW_TEXT Xutf8DrawText
94 #define WB_LOOKUP_STRING Xutf8LookupString
96 #else // X_HAVE_UTF8_STRING
97 
98 #warning UTF8 not supported, using 'MB' equivalents
99 
100 #define WB_TEXT_EXTENTS XmbTextExtents
101 #define WB_TEXT_ESCAPEMENT XmbTextEscapement
102 #define WB_DRAW_STRING XmbDrawString
103 #define WB_DRAW_TEXT XmbDrawText
104 #define WB_LOOKUP_STRING XmbLookupString
106 #endif // X_HAVE_UTF8_STRING
107 
127 XFontStruct *WBCopyFont(XFontStruct *pFont);
128 
151 XFontStruct *WBLoadFont(Display *pDisplay, const char *szFontName,
152  int iFontSize, int iFlags);
153 
176 XFontStruct *WBLoadModifyFont(Display *pDisplay, const XFontStruct *pOriginal,
177  int iFontSize, int iFlags);
178 
179 
202 XFontSet WBCopyModifyFontSet(Display *pDisplay, XFontSet fsOrig, int iFontSize, int iFlags);
203 
204 
215 int WBFontAvgCharWidth(Display *pDisplay, const XFontStruct *pFont);
216 
217 
229 int WBFontSetDescent(Display *pDisplay, XFontSet fontSet);
230 
231 
243 int WBFontSetAscent(Display *pDisplay, XFontSet fontSet);
244 
245 
257 int WBFontSetHeight(Display *pDisplay, XFontSet fontSet);
258 
259 
271 int WBFontSetAvgCharWidth(Display *pDisplay, XFontSet fontSet);
272 
273 
285 XCharStruct WBFontSetMaxBounds(Display *pDisplay, XFontSet fontSet);
286 
287 
304 XFontSet WBFontSetFromFont(Display *pDisplay, const XFontStruct *pFont);
305 
306 
320 XFontStruct * WBFontFromFontSet(Display *pDisplay, XFontSet fontSet);
321 
322 
343 XFontSet WBFontSetFromFontSingle(Display *pDisplay, const XFontStruct *pFont);
344 
345 
359 int WBTextWidth(XFontSet fontSet, const char *szText, int cbText);
360 
361 
373 void WBDumpFontInfo(const char *pSpec); // debugging function - dumps a list of fonts and info
374 
375 
386 {
392 
399 
405 
406  // if the font size is > 0 then these bits apply
412 
421 
427 
433 
434  // reserved - font registry and encoding (installed X11 fonts typically include most if not all of these)
437  WBFontFlag_REG_ASCII = 0x300000,
439  WBFontFlag_REG_MISC = 0x500000,
441  WBFontFlag_REG_ADOBE = 0x700000,
450  WBFontFlag_REG_MASK = 0xf00000,
451 
452  // TODO: flags for 'encoding' ?
453 
454  WBFontFlag_WHATEVER = 0 // don't force anything (zero, default)
455 };
456 
457 
458 
459 #ifdef __cplusplus
460 };
461 #endif // __cplusplus
462 
463 
464 #endif // _FONT_HELPER_H_INCLUDED_
465