From 149d652144fe416dbe4ecf9fc5cef71617ef01ff Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Wed, 5 May 2010 09:37:32 +0000 Subject: dvips pTeX extensions, based on patches sent by Akira git-svn-id: svn://tug.org/texlive/trunk@18107 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dvipsk/tfmload.c | 179 +++++++++++++++++++++++++------------ 1 file changed, 124 insertions(+), 55 deletions(-) (limited to 'Build/source/texk/dvipsk/tfmload.c') diff --git a/Build/source/texk/dvipsk/tfmload.c b/Build/source/texk/dvipsk/tfmload.c index 5b9ed411c4c..d3d9b7ce958 100644 --- a/Build/source/texk/dvipsk/tfmload.c +++ b/Build/source/texk/dvipsk/tfmload.c @@ -11,7 +11,7 @@ */ #include "protos.h" -FILE *tfmfile; +FILE *tfmfile; /* * Our static variables: @@ -32,9 +32,9 @@ badtfm(const char *s) void tfmopen(register fontdesctype *fd) { - register char *n; + register char *n; #ifdef KPATHSEA - kpse_file_format_type d; + kpse_file_format_type d; #else register char *d; #endif @@ -85,25 +85,25 @@ tfmopen(register fontdesctype *fd) shalfword tfmbyte(void) { - return(getc(tfmfile)); + return(getc(tfmfile)); } halfword tfm16(void) { - register halfword a; - a = tfmbyte (); - return ( a * 256 + tfmbyte () ); -} + register halfword a; + a = tfmbyte (); + return ( a * 256 + tfmbyte () ); +} integer tfm32(void) { - register integer a; - a = tfm16 (); - if (a > 32767) a -= 65536; - return ( a * 65536 + tfm16 () ); -} + register integer a; + a = tfm16 (); + if (a > 32767) a -= 65536; + return ( a * 65536 + tfm16 () ); +} int tfmload(register fontdesctype *curfnt) @@ -111,9 +111,12 @@ tfmload(register fontdesctype *curfnt) register integer i, j; register integer li, cd=0; integer scaledsize; + integer id, nt = 0; integer nw, hd; integer bc, ec; integer nco=0, ncw=0, npc=0, no_repeats = 0; + halfword *index = NULL; + halfword *chartype = NULL; integer *scaled; integer *chardat; int font_level; @@ -125,14 +128,32 @@ tfmload(register fontdesctype *curfnt) * Next, we read the font data from the tfm file, and store it in * our own arrays. */ - li = tfm16(); - if (li!=0) { + curfnt->dir = 0; + curfnt->iswide = 0; + curfnt->codewidth = 1; + id = tfm16(); + if (id!=0) { font_level = -1; + if (id == 9 || id == 11) { + if (noptex) badtfm("length"); + if (id == 9) curfnt->dir = id; + nt = tfm16(); li = tfm16(); + curfnt->iswide = 1; + curfnt->maxchars = MAX_CODE; + curfnt->chardesc = (chardesctype *)realloc(curfnt->chardesc, + sizeof(chardesctype)*(MAX_CODE)); + for (i=0; ichardesc[i].TFMwidth = 0; + curfnt->chardesc[i].packptr = NULL; + curfnt->chardesc[i].pixelwidth = 0; + curfnt->chardesc[i].flags = 0; + } + } hd = tfm16(); bc = tfm16(); ec = tfm16(); nw = tfm16(); li = tfm32(); li = tfm32(); li = tfm32(); li = tfm16(); - if (hd<2 || bc>ec+1 || ec>255 || nw>256) + if ((hd<2 || bc>ec+1 || ec>255 || nw>256) && id != 9 && id != 11) badtfm("header"); } else { /* In an .ofm file */ if (noomega) badtfm("length"); @@ -154,58 +175,83 @@ tfmload(register fontdesctype *curfnt) li = tfm32(); check_checksum (li, curfnt->checksum, curfnt->name); li = (integer)(alpha * (real)tfm32()); - if (li > curfnt->designsize + fsizetol - || li < curfnt->designsize - fsizetol) { + if (li > curfnt->designsize + fsizetol || + li < curfnt->designsize - fsizetol) { char *msg = concat ("Design size mismatch in font ", curfnt->name); error(msg); } pretend_no_chars=ec+1; - if (pretend_no_chars<256) pretend_no_chars=256; - else { - curfnt->chardesc = (chardesctype *) - xrealloc(curfnt->chardesc, sizeof(chardesctype)*pretend_no_chars); - curfnt->maxchars = pretend_no_chars; - } - for (i=2; i<((font_level==1)?nco-29:hd); i++) - li = tfm32(); - chardat = (integer *) xmalloc(pretend_no_chars*sizeof(integer)); - for (i=0; i0) { - no_repeats--; - } else if (font_level>=0) { - cd = tfm16(); + if (id == 9 || id == 11) { + chardat = (integer *)xmalloc(256*sizeof(integer)); + for (i=2; ichardesc = (chardesctype *) + xrealloc(curfnt->chardesc, sizeof(chardesctype)*pretend_no_chars); + curfnt->maxchars = pretend_no_chars; + } + for (i=2; i<((font_level==1)?nco-29:hd); i++) + li = tfm32(); + chardat = (integer *) xmalloc(pretend_no_chars*sizeof(integer)); + for (i=0; i0) { + no_repeats--; + } else if (font_level>=0) { + cd = tfm16(); + li = tfm32(); + li = tfm16(); + if (font_level==1) { + no_repeats = tfm16(); + for (j=0; j<(npc|1); j++) tfm16(); + ncw -= 3 + npc/2; + } + } else { + cd = tfmbyte(); + li = tfm16(); + li = tfmbyte(); + } + if (cd>=nw) badtfm("char info"); + if (cd) { + chardat[i] = cd; + charcount++; } - } else { - cd = tfmbyte(); - li = tfm16(); - li = tfmbyte(); } - if (cd>=nw) badtfm("char info"); - if (cd) { - chardat[i] = cd; - charcount++; + if (font_level==1&&ncw!=0) { + char *msg = concat ("Table size mismatch in ", curfnt->name); + error(msg); } } - if (font_level==1&&ncw!=0) { - char *msg = concat ("Table size mismatch in ", curfnt->name); - error(msg); - } scaledsize = curfnt->scaledsize; scaled = (integer *) xmalloc(nw*sizeof(integer)); for (i=0; ichardesc[i].TFMwidth = li; if (li >= 0) curfnt->chardesc[i].pixelwidth = ((integer)(conv*li+0.5)); @@ -213,10 +259,33 @@ tfmload(register fontdesctype *curfnt) curfnt->chardesc[i].pixelwidth = -((integer)(conv*-li+0.5)); curfnt->chardesc[i].flags = (curfnt->resfont ? EXISTS : 0); curfnt->chardesc[i].flags2 = EXISTS; - } else curfnt->chardesc[i].flags = curfnt->chardesc[i].flags2 = 0; + } + for (i=1; ichardesc[index[i]].TFMwidth = li; + if (li >= 0) + curfnt->chardesc[index[i]].pixelwidth = ((integer)(conv*li+0.5)); + else + curfnt->chardesc[index[i]].pixelwidth = -((integer)(conv*-li+0.5)); + } + free(index); + free(chartype); + } else { + for (i=0; ichardesc[i].TFMwidth = li; + if (li >= 0) + curfnt->chardesc[i].pixelwidth = ((integer)(conv*li+0.5)); + else + curfnt->chardesc[i].pixelwidth = -((integer)(conv*-li+0.5)); + curfnt->chardesc[i].flags = (curfnt->resfont ? EXISTS : 0); + curfnt->chardesc[i].flags2 = EXISTS; + } + if (ec>=256) curfnt->codewidth = 2; /* XXX: 2byte-code can have ec<256 */ + } free(chardat); free(scaled); - if (ec>=256) curfnt->codewidth = 2; /* XXX: 2byte-code can have ec<256 */ curfnt->loaded = 1; return charcount; } -- cgit v1.2.3