added support for getting ascent/descent size info for ps fonts -- Peter Speck
[rrdtool.git] / src / rrd_afm.c
index b9996f4..5bf6e91 100644 (file)
@@ -1,10 +1,10 @@
 /****************************************************************************
- * RRDtool 1.2rc3  Copyright by Tobi Oetiker, 1997-2005
+ * RRDtool 1.2.4  Copyright by Tobi Oetiker, 1997-2005
  ****************************************************************************
  * rrd_afm.h  Parsing afm tables to find width of strings.
  ****************************************************************************/
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
 #include "../confignt/config.h"
 #else
 #include "config.h"
@@ -73,6 +73,18 @@ const char *afm_get_font_postscript_name(const char* font)
   return p ? p->postscript_name : "Helvetica";
 }
 
+double afm_get_ascender(const char* font, double size)
+{
+  const afm_fontinfo *p = afm_findfont(font);
+  return p ? p->ascender : 10; /* just a guess to avoid really bad design if we don't know the font */
+}
+
+double afm_get_descender(const char* font, double size)
+{
+  const afm_fontinfo *p = afm_findfont(font);
+  return p ? p->descender : 4; /* just a guess to avoid really bad design if we don't know the font */
+}
+
 static int afm_find_char_index(const afm_fontinfo *fontinfo,
     afm_cunicode ch1)
 {