summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e8a32c3)
raw | patch | inline | side by side (parent: e8a32c3)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Sun, 8 May 2005 21:25:42 +0000 (21:25 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Sun, 8 May 2005 21:25:42 +0000 (21:25 +0000) |
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@521 a5681a0c-68f1-0310-ab6d-d61299d08faa
index b53d3d47cf3cbd2990311d4f176a8707566aa08d..efcf5dd45a7308f5aecb1a02e25aa087b0afccb7 100644 (file)
-#!/usr/local/bin/perl -w
+#!/usr/bin/perl -w
require 5.005;
use strict;
$fi{FontSpecificUnicodeNameToChar} = {};
$fi{filename} = $fn;
$fi{filename} =~ s/.*\///;
+ $fi{Ascender} = 0;
+ $fi{Descender} = 0;
open(FH, $fn) || die "Can't open $fn\n";
print STDERR "Reads global font info\n" if $q;
while (<FH>) {
chomp;
next if /^\s*$/ || /^\s*#/;
+ $fi{Ascender} = $1 if /^Ascender\s+(-?\d+)/;
+ $fi{Descender} = $1 if /^Descender\s+(-?\d+)/;
last if /^StartCharMetrics/;
next unless (/^(\S+)\s+(\S(.*\S)?)/);
my $id = $1;
$kerning_data_count + 2 * $highchars_count +
3 * 2 * $ligatures_count;
$info_code .= $indent1 . "{ /* $$fiR{filename} $packedSize bytes */\n";
- $info_code .= $i2 . "\"$$fiR{AfmFontName}\",";
- $info_code .= " \"$$fiR{AfmFullName}\",\n";
+ $info_code .= $i2 . "\"$$fiR{AfmFontName}\", \"$$fiR{AfmFullName}\",\n";
+ $info_code .= $i2 . $$fiR{Ascender} . ", " . $$fiR{Descender} . ",\n";
$info_code .= $i2 . $$fiR{widthsACName} . ",\n";
$info_code .= $i2 . $$fiR{kerning_indexACName} . ",\n";
$info_code .= $i2 . $$fiR{kerning_dataACName} . ",\n";
print CFILE ${$font_code{$_}}{TABLES} foreach @fonts;
print CFILE "const afm_fontinfo afm_fontinfolist[] = {\n";
print CFILE ${$font_code{$_}}{INFO} foreach @fonts;
- print CFILE $indent1 . "{ 0, 0, 0 }\n";
+ print CFILE $indent1 . "{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }\n";
print CFILE $indent0 . "};\n";
print CFILE $indent0 . "const int afm_fontinfo_count = ",
($#fonts + 1), ";\n";
diff --git a/src/rrd_afm.c b/src/rrd_afm.c
index 2b7e343c7a777ec0a70e957db4292efc9ccc7584..5bf6e91696b1de68c3a9a518a0ecf25f7f213eac 100644 (file)
--- a/src/rrd_afm.c
+++ b/src/rrd_afm.c
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)
{
diff --git a/src/rrd_afm.h b/src/rrd_afm.h
index 2ff9d061f70d688eb5d86c93e9be6c488171519b..6a59318986aad2216f01e04b8d211bad611c10f2 100644 (file)
--- a/src/rrd_afm.h
+++ b/src/rrd_afm.h
double afm_get_text_width ( double start, const char* font, double size,
double tabwidth, const char* text);
+double afm_get_ascender(const char* font, double size);
+double afm_get_descender(const char* font, double size);
+
/* get postscript name from fullname or postscript name */
const char *afm_get_font_postscript_name ( const char* font);
diff --git a/src/rrd_afm_data.c b/src/rrd_afm_data.c
index 39fb43ecd1b355153078731bda32c8f0ac5754c2..f5805fd551e9cbc3af8cdec4ff9cc9d56d306c79 100644 (file)
--- a/src/rrd_afm_data.c
+++ b/src/rrd_afm_data.c
const afm_fontinfo afm_fontinfolist[] = {
{ /* Courier.afm 761 bytes */
"Courier", "Courier",
+ 629, -157,
afm_Courier_widths,
NULL,
NULL,
afm_Courier_ligatures, 1},
{ /* Courier-Bold.afm 761 bytes */
"Courier-Bold", "Courier Bold",
+ 629, -157,
afm_Courier_Bold_widths,
NULL,
NULL,
afm_Courier_Bold_ligatures, 1},
{ /* Courier-BoldOblique.afm 761 bytes */
"Courier-BoldOblique", "Courier Bold Oblique",
+ 629, -157,
afm_Courier_BoldOblique_widths,
NULL,
NULL,
afm_Courier_BoldOblique_ligatures, 1},
{ /* Courier-Oblique.afm 761 bytes */
"Courier-Oblique", "Courier Oblique",
+ 629, -157,
afm_Courier_Oblique_widths,
NULL,
NULL,
afm_Courier_Oblique_ligatures, 1},
{ /* Helvetica.afm 7841 bytes */
"Helvetica", "Helvetica",
+ 718, -207,
afm_Helvetica_widths,
afm_Helvetica_kerning_index,
afm_Helvetica_kerning_data,
afm_Helvetica_ligatures, 1},
{ /* Helvetica-Bold.afm 7336 bytes */
"Helvetica-Bold", "Helvetica Bold",
+ 718, -207,
afm_Helvetica_Bold_widths,
afm_Helvetica_Bold_kerning_index,
afm_Helvetica_Bold_kerning_data,
afm_Helvetica_Bold_ligatures, 1},
{ /* Helvetica-BoldOblique.afm 7336 bytes */
"Helvetica-BoldOblique", "Helvetica Bold Oblique",
+ 718, -207,
afm_Helvetica_BoldOblique_widths,
afm_Helvetica_BoldOblique_kerning_index,
afm_Helvetica_BoldOblique_kerning_data,
afm_Helvetica_BoldOblique_ligatures, 1},
{ /* Helvetica-Oblique.afm 7841 bytes */
"Helvetica-Oblique", "Helvetica Oblique",
+ 718, -207,
afm_Helvetica_Oblique_widths,
afm_Helvetica_Oblique_kerning_index,
afm_Helvetica_Oblique_kerning_data,
afm_Helvetica_Oblique_ligatures, 1},
{ /* ZapfDingbats.afm 416 bytes */
"ZapfDingbats", "ITC Zapf Dingbats",
+ 0, 0,
afm_ZapfDingbats_widths,
NULL,
NULL,
NULL, 0},
{ /* Symbol.afm 563 bytes */
"Symbol", "Symbol",
+ 0, 0,
afm_Symbol_widths,
NULL,
NULL,
NULL, 0},
{ /* Times-Bold.afm 6761 bytes */
"Times-Bold", "Times Bold",
+ 683, -217,
afm_Times_Bold_widths,
afm_Times_Bold_kerning_index,
afm_Times_Bold_kerning_data,
afm_Times_Bold_ligatures, 1},
{ /* Times-BoldItalic.afm 6270 bytes */
"Times-BoldItalic", "Times Bold Italic",
+ 683, -217,
afm_Times_BoldItalic_widths,
afm_Times_BoldItalic_kerning_index,
afm_Times_BoldItalic_kerning_data,
afm_Times_BoldItalic_ligatures, 1},
{ /* Times-Italic.afm 6975 bytes */
"Times-Italic", "Times Italic",
+ 683, -217,
afm_Times_Italic_widths,
afm_Times_Italic_kerning_index,
afm_Times_Italic_kerning_data,
afm_Times_Italic_ligatures, 1},
{ /* Times-Roman.afm 6287 bytes */
"Times-Roman", "Times Roman",
+ 683, -217,
afm_Times_Roman_widths,
afm_Times_Roman_kerning_index,
afm_Times_Roman_kerning_data,
afm_Times_Roman_highchars_index, 220,
afm_Times_Roman_ligatures, 1},
- { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
const int afm_fontinfo_count = 14;
diff --git a/src/rrd_afm_data.h b/src/rrd_afm_data.h
index 9ae858c36d4889f4207488744a87e9862fbbce68..ecc049f929b2cbb5cf665d0a2dbd86f56af90ec6 100644 (file)
--- a/src/rrd_afm_data.h
+++ b/src/rrd_afm_data.h
typedef struct afm_fontinfo {
const char *fullname; /* e.g. "Futura Bold Oblique" */
const char *postscript_name; /* e.g. "Futura-BoldOblique" */
+ afm_cuint16 ascender, descender;
afm_cuint8 *widths;
afm_csint16 *kerning_index;
afm_cuint8 *kerning_data;