X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_afm.c;h=0e3109c4804b7b0ed56e164382177d8591a58ef1;hb=37329a5f991870e8f47c8a52f6dd594fef813de6;hp=a7cb2956e41e97a2d40a8d3b8039829b22973644;hpb=0f913ead7c1e1e7ba4976e8763d73c3167f8cf73;p=rrdtool.git diff --git a/src/rrd_afm.c b/src/rrd_afm.c index a7cb295..0e3109c 100644 --- a/src/rrd_afm.c +++ b/src/rrd_afm.c @@ -1,5 +1,5 @@ /**************************************************************************** - * RRDtool 1.2.4 Copyright by Tobi Oetiker, 1997-2005 + * RRDtool 1.2.6 Copyright by Tobi Oetiker, 1997-2005 **************************************************************************** * rrd_afm.h Parsing afm tables to find width of strings. ****************************************************************************/ @@ -20,6 +20,8 @@ #include #endif +#include "unused.h" + #if 0 # define DEBUG 1 # define DLOG(x) fprintf x @@ -35,6 +37,7 @@ #define ENABLE_LIGATURES 0 static const afm_fontinfo *afm_last_used_font = NULL; +static const char *last_unknown_font = NULL; #define is_font(p, name) \ (!strcmp(p->postscript_name, name) || !strcmp(p->fullname, name)) @@ -55,8 +58,10 @@ static const afm_fontinfo *afm_searchfont(const char *name) return NULL; } -static const char *last_unknown_font = NULL; +/* returns always a font, never NULL. + The rest of the code depends on the result never being NULL. + See rrd_afm.h */ static const afm_fontinfo *afm_findfont(const char *name) { const afm_fontinfo *p = afm_searchfont(name); @@ -66,10 +71,10 @@ static const afm_fontinfo *afm_findfont(const char *name) fprintf(stderr, "Can't find font '%s'\n", name); last_unknown_font = name; } - p = afm_searchfont("Courier"); + p = afm_searchfont(RRD_AFM_DEFAULT_FONT); if (p) return p; - return afm_fontinfolist; // anything, just anything. + return afm_fontinfolist; /* anything, just anything. */ } const char *afm_get_font_postscript_name(const char* font) @@ -78,6 +83,12 @@ const char *afm_get_font_postscript_name(const char* font) return p->postscript_name; } +const char *afm_get_font_name(const char* font) +{ + const afm_fontinfo *p = afm_findfont(font); + return p->fullname; +} + double afm_get_ascender(const char* font, double size) { const afm_fontinfo *p = afm_findfont(font); @@ -176,8 +187,8 @@ static long afm_find_kern(const afm_fontinfo *fontinfo, } /* measure width of a text string */ -double afm_get_text_width ( double start, const char* font, double size, - double tabwidth, const char* text) +double afm_get_text_width ( double UNUSED(start), const char* font, double size, + double UNUSED(tabwidth), const char* text) { const afm_fontinfo *fontinfo = afm_findfont(font); long width = 0;