summaryrefslogtreecommitdiff
path: root/in_afm.c
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2006-05-13 15:52:03 +0000
committerBen Harris <bjh21@bjh21.me.uk>2006-05-13 15:52:03 +0000
commit9f368a32d754b2827a38f51aa6191aa625ce6a10 (patch)
tree4fbc67e3854b82f5646183fee666c8ae774f49a3 /in_afm.c
parentb45545bf362a30d958c17c4ea58eda573cc4a5b8 (diff)
downloadhalibut-9f368a32d754b2827a38f51aa6191aa625ce6a10.zip
halibut-9f368a32d754b2827a38f51aa6191aa625ce6a10.tar.gz
halibut-9f368a32d754b2827a38f51aa6191aa625ce6a10.tar.bz2
halibut-9f368a32d754b2827a38f51aa6191aa625ce6a10.tar.xz
Generate a more-or-less valid /FontDescriptor dictionary for non-standard
fonts in PDF output. [originally from svn r6684]
Diffstat (limited to 'in_afm.c')
-rw-r--r--in_afm.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/in_afm.c b/in_afm.c
index 0935bf3..f771af7 100644
--- a/in_afm.c
+++ b/in_afm.c
@@ -58,6 +58,9 @@ void read_afm_file(input *in) {
fi->glyphs = NULL;
fi->widths = NULL;
fi->kerns = newtree234(kern_cmp);
+ fi->fontbbox[0] = fi->fontbbox[1] = fi->fontbbox[2] = fi->fontbbox[3] = 0;
+ fi->capheight = fi->xheight = fi->ascent = fi->descent = 0;
+ fi->stemh = fi->stemv = fi->italicangle = 0;
in->pos.line = 0;
line = afm_read_line(in);
if (!line || !afm_require_key(line, "StartFontMetrics", in))
@@ -87,6 +90,63 @@ void read_afm_file(input *in) {
goto giveup;
}
fi->name = dupstr(val);
+ } else if (strcmp(key, "FontBBox") == 0) {
+ int i;
+ for (i = 0; i < 3; i++) {
+ if (!(val = strtok(NULL, " \t"))) {
+ error(err_afmval, &in->pos, key, 4);
+ goto giveup;
+ }
+ fi->fontbbox[i] = atof(val);
+ }
+ } else if (strcmp(key, "CapHeight") == 0) {
+ if (!(val = strtok(NULL, " \t"))) {
+ error(err_afmval, &in->pos, key, 1);
+ goto giveup;
+ }
+ fi->capheight = atof(val);
+ } else if (strcmp(key, "XHeight") == 0) {
+ if (!(val = strtok(NULL, " \t"))) {
+ error(err_afmval, &in->pos, key, 1);
+ goto giveup;
+ }
+ fi->xheight = atof(val);
+ } else if (strcmp(key, "Ascender") == 0) {
+ if (!(val = strtok(NULL, " \t"))) {
+ error(err_afmval, &in->pos, key, 1);
+ goto giveup;
+ }
+ fi->ascent = atof(val);
+ } else if (strcmp(key, "Descender") == 0) {
+ if (!(val = strtok(NULL, " \t"))) {
+ error(err_afmval, &in->pos, key, 1);
+ goto giveup;
+ }
+ fi->descent = atof(val);
+ } else if (strcmp(key, "CapHeight") == 0) {
+ if (!(val = strtok(NULL, " \t"))) {
+ error(err_afmval, &in->pos, key, 1);
+ goto giveup;
+ }
+ fi->capheight = atof(val);
+ } else if (strcmp(key, "StdHW") == 0) {
+ if (!(val = strtok(NULL, " \t"))) {
+ error(err_afmval, &in->pos, key, 1);
+ goto giveup;
+ }
+ fi->stemh = atof(val);
+ } else if (strcmp(key, "StdVW") == 0) {
+ if (!(val = strtok(NULL, " \t"))) {
+ error(err_afmval, &in->pos, key, 1);
+ goto giveup;
+ }
+ fi->stemv = atof(val);
+ } else if (strcmp(key, "ItalicAngle") == 0) {
+ if (!(val = strtok(NULL, " \t"))) {
+ error(err_afmval, &in->pos, key, 1);
+ goto giveup;
+ }
+ fi->italicangle = atof(val);
} else if (strcmp(key, "StartCharMetrics") == 0) {
char const **glyphs;
int *widths;