a23684715125b4288b7fdcd411f7cd7c40d2c373
[rrdtool.git] / src / rrd_afm.h
1 /****************************************************************************
2  * RRDtool 1.2.19  Copyright by Tobi Oetiker, 1997-2007
3  ****************************************************************************
4  * rrd_afm.h  Parsing afm tables to find width of strings.
5  ****************************************************************************/
6
7 #ifndef  RRD_AFM_H
8 #define RRD_AFM_H
9
10 #include <stdlib.h>
11  
12 #ifdef HAVE_MBSTOWCS
13 #define afm_char wchar_t
14 #else
15 #define afm_char unsigned char
16 #endif
17 /*
18    If the font specified by the name parameter in the routes below
19    is not found
20    (because it is not compiled into rrd_afm_data.c by compile_afm.pl)
21    the font specified by RRD_AFM_DEFAULT_FONT will be used.
22    If it is not installed, it uses the first font compiled
23    into rrd_afm_data.c
24    So they will always use some font.
25 */
26
27 #define RRD_AFM_DEFAULT_FONT "Courier"
28
29 /* measure width of a text string */
30 /* fontname can be full name or postscript name */
31 double afm_get_text_width( double start, const char* font, double size,
32                             double tabwidth, const char* text);
33 double afm_get_text_width_wide( double start, const char* font, double size,
34                             double tabwidth, const afm_char* text);
35
36 double afm_get_ascender(const char* font, double size);
37 double afm_get_descender(const char* font, double size);
38
39 /* get postscript name from fullname or postscript name */
40 const char *afm_get_font_postscript_name ( const char* font);
41 const char *afm_get_font_name(const char* font);
42
43 /* cc -E -dM /dev/null */
44 #ifdef __APPLE__
45 /* need charset conversion from macintosh to unicode. */
46 extern const unsigned char afm_mac2iso[128];
47 #define afm_fix_osx_charset(c) \
48         ( (c) >= 128 && (c) <= 255 ? afm_mac2iso[(c) - 128] : (c))
49 #else
50 /* UNSAFE macro */
51 #define afm_fix_osx_charset(x) (x)
52 #endif
53
54 #endif