diff -uNr ttf2pk-1.5_CVS20051222.000/newobj.c ttf2pk-1.5_CVS20051222.001/newobj.c --- ttf2pk-1.5_CVS20051222.000/newobj.c 2002-06-21 02:34:37.000000000 +0900 +++ ttf2pk-1.5_CVS20051222.001/newobj.c 2005-12-22 16:48:25.000000000 +0900 @@ -202,6 +202,8 @@ ti->dptr = 0; ti->iptr = 0; + ti->fntnum = -1; + fnt->charlist = ti; return ti; @@ -313,6 +315,10 @@ fnt->codingscheme = default_codingscheme; fnt->titlebuf = NULL; + fnt->cksum = 0; + fnt->subfont_num = 0; + fnt->subfont_list = NULL; + fnt->units_per_em = 0; fnt->italicangle = 0.0; fnt->fixedpitch = 0; diff -uNr ttf2pk-1.5_CVS20051222.000/subfont.c ttf2pk-1.5_CVS20051222.001/subfont.c --- ttf2pk-1.5_CVS20051222.000/subfont.c 2002-03-15 10:33:52.000000000 +0900 +++ ttf2pk-1.5_CVS20051222.001/subfont.c 2005-12-22 16:48:25.000000000 +0900 @@ -35,7 +35,7 @@ static realsubfont * really_init_sfd(char *name, Boolean fatal); static Boolean -really_get_sfd(Font *fnt, Boolean next, realsubfont *rsf); +really_get_sfd(Font *fnt, Boolean next, realsubfont *rsf, Boolean new_sfd); static void really_close_sfd(realsubfont *real_name); @@ -163,14 +163,14 @@ Boolean get_sfd(Font *fnt, Boolean is_sfd) { if (is_sfd) - return really_get_sfd(fnt, False, real_sfd_name); + return really_get_sfd(fnt, False, real_sfd_name, True); else - return really_get_sfd(fnt, False, real_lig_name); + return really_get_sfd(fnt, False, real_lig_name, False); } static Boolean -really_get_sfd(Font *fnt, Boolean next, realsubfont *rsf) +really_get_sfd(Font *fnt, Boolean next, realsubfont *rsf, Boolean new_sfd) { long i, offset; long begin, end = -1; @@ -229,7 +229,7 @@ if (*bufp == '\0') oops("Invalid subfont entry in `%s'.", rsf->name); - if (next) + if (next || !new_sfd) { if (strcmp(fnt->subfont_name, buffer)) goto again; @@ -309,7 +309,7 @@ if (!next) while ((rsf = rsf->next)) - (void)really_get_sfd(fnt, True, rsf); + (void)really_get_sfd(fnt, True, rsf, new_sfd); return True; } diff -uNr ttf2pk-1.5_CVS20051222.000/tfmaux.c ttf2pk-1.5_CVS20051222.001/tfmaux.c --- ttf2pk-1.5_CVS20051222.000/tfmaux.c 2002-01-08 21:48:27.000000000 +0900 +++ ttf2pk-1.5_CVS20051222.001/tfmaux.c 2005-12-22 16:48:26.000000000 +0900 @@ -283,7 +283,6 @@ register int i, j; register ttfinfo *ti; int byte1, old_byte1, byte2; - long cksum; double Slant; char buffer[256]; struct sf sf_array[256]; @@ -366,8 +365,8 @@ } header = (long *)mymalloc(40000L); - cksum = checksum(fnt->inencptrs); - header[0] = cksum; + fnt->cksum = checksum(fnt->inencptrs); + header[0] = fnt->cksum; header[1] = 0xA00000; /* 10pt design size */ (void)makebcpl(header + 2, fnt->codingscheme, 39); @@ -510,7 +509,8 @@ old_byte1 = byte1; nl++; } - ligkern[nl - 1] |= 0x80000000L; + if (nl > 0) + ligkern[nl - 1] |= 0x80000000L; } kerns = ligkern + nl; diff -uNr ttf2pk-1.5_CVS20051222.000/ttf2tfm.c ttf2pk-1.5_CVS20051222.001/ttf2tfm.c --- ttf2pk-1.5_CVS20051222.000/ttf2tfm.c 2002-06-21 02:34:37.000000000 +0900 +++ ttf2pk-1.5_CVS20051222.001/ttf2tfm.c 2005-12-22 16:48:26.000000000 +0900 @@ -235,6 +235,37 @@ } +#define MAX_SFLIST 10 +static void +add_subfont_list(Font *fnt) +{ + if (fnt->subfont_list == NULL) + fnt->subfont_list = (sflist *)mymalloc(MAX_SFLIST * sizeof(sflist)); + else if (fnt->subfont_num % MAX_SFLIST == 0) + fnt->subfont_list = (sflist *)myrealloc(fnt->subfont_list, + (fnt->subfont_num / MAX_SFLIST + 1) * MAX_SFLIST * sizeof(sflist)); + + (fnt->subfont_list[fnt->subfont_num]).name = + (char *)mymalloc(strlen(fnt->fullname)+1); + strcpy((fnt->subfont_list[fnt->subfont_num]).name, fnt->fullname); + (fnt->subfont_list[fnt->subfont_num]).cksum = fnt->cksum; + + fnt->subfont_num++; +} + + +static void +release_subfont_list(Font *fnt) +{ + register int i; + + for (i = 0; i < fnt->subfont_num; i++) + free((fnt->subfont_list[i]).name); + + free(fnt->subfont_list); +} + + #define VERSION "\ Copyright (C) 1997-1999, 2000, 2002 Frederic Loyer and Werner Lemberg.\n\ There is NO warranty. You may redistribute this software\n\ @@ -251,6 +282,7 @@ David Turner, Robert Wilhelm, and Werner Lemberg.\n\ " + static void version(void) { @@ -272,6 +304,7 @@ -L LIGFILE[.sfd] create 1st/2nd byte ligatures in subfonts using LIGFILE\n\ -n use PS names of TrueType font\n\ -N use only PS names and no cmap\n\ +-o FILE[.ovp] make an OVP file for conversion to OVF and OFM\n\ -O use octal for all character codes in the vpl file\n\ -p ENCFILE[.enc] read ENCFILE for the TTF->raw TeX mapping\n\ -P INT select INT as the TTF platform ID [3]\n\ @@ -528,6 +561,15 @@ arginc = 1; break; + case 'o': + if (argc <= 3) + oops("Missing parameter for -o option."); + if (vpl_name) + free(vpl_name); + vpl_name = newstring(argv[3]); + handle_extension(&vpl_name, ".ovp"); + break; + default: if (argc <= 3 || argv[3][0] == '-') { @@ -664,6 +706,9 @@ warning("Ignoring `-v' and `-V' switches for subfonts."); makevpl = 0; } + if (vpl_name) + if ((fnt->vplout = fopen(vpl_name, "wt")) == NULL) + oops("Cannot open ovp output file."); if (have_capheight) warning("Ignoring `-c' switch for subfonts."); if (fnt->inencname || fnt->outencname) @@ -890,10 +935,19 @@ writetfm(&font); if (font.write_enc) writeenc(&font); + if (font.vplout) + add_subfont_list(&font); } } close_sfd(); + + if (font.vplout) + { + writeovp(&font); + fclose(font.vplout); + release_subfont_list(&font); + } } else { diff -uNr ttf2pk-1.5_CVS20051222.000/ttf2tfm.h ttf2pk-1.5_CVS20051222.001/ttf2tfm.h --- ttf2pk-1.5_CVS20051222.000/ttf2tfm.h 2002-01-08 21:48:27.000000000 +0900 +++ ttf2pk-1.5_CVS20051222.001/ttf2tfm.h 2005-12-22 16:48:26.000000000 +0900 @@ -54,7 +54,8 @@ typedef struct _pcc pcc; struct _stringlist; typedef struct _stringlist stringlist; - +struct _sflist; +typedef struct _sflist sflist; struct _ttfinfo @@ -77,6 +78,8 @@ pcc *pccs; /* we use the composite feature for */ /* `germandbls' <--> `SS' only */ unsigned char wptr, hptr, dptr, iptr; + + short fntnum; }; @@ -120,6 +123,13 @@ }; +struct _sflist +{ + char *name; + long cksum; +}; + + struct _Font { char *ttfname; @@ -187,6 +197,11 @@ char *codingscheme; /* coding scheme for TeX */ char *titlebuf; + long cksum; + + short subfont_num; + sflist *subfont_list; + /* * The name of the subfont definition file. */ diff -uNr ttf2pk-1.5_CVS20051222.000/ttfaux.c ttf2pk-1.5_CVS20051222.001/ttfaux.c --- ttf2pk-1.5_CVS20051222.000/ttfaux.c 2003-11-05 21:19:02.000000000 +0900 +++ ttf2pk-1.5_CVS20051222.001/ttfaux.c 2005-12-22 16:48:26.000000000 +0900 @@ -562,6 +562,8 @@ ti->urx = bbox.xMax * 1000 / fnt->units_per_em; ti->ury = bbox.yMax * 1000 / fnt->units_per_em; + ti->fntnum = fnt->subfont_num; + /* * We must now shift the rotated character both horizontally * and vertically. The vertical amount is 25% by default. diff -uNr ttf2pk-1.5_CVS20051222.000/vplaux.c ttf2pk-1.5_CVS20051222.001/vplaux.c --- ttf2pk-1.5_CVS20051222.000/vplaux.c 2002-11-15 18:41:24.000000000 +0900 +++ ttf2pk-1.5_CVS20051222.001/vplaux.c 2005-12-22 16:48:26.000000000 +0900 @@ -568,4 +568,117 @@ } +void +writeovp(Font *fnt) +{ + register int i; + register ttfinfo *ti; + long bc, ec; + char header[256]; + float Slant; + ttfinfo *ofm_array[65536]; + + + out = fnt->vplout; + + header[0] = '\0'; + strncat(header, "Created by `", 12); + strncat(header, fnt->titlebuf, 255 - 12 - 1); + strncat(header, "'", 1); + + voutln2("(VTITLE %s)", header); + voutln("(COMMENT Please change VTITLE if you edit this file)"); + + voutln("(OFMLEVEL H 1)"); + voutln("(FONTDIR TL)"); + voutln2("(FAMILY %s)", fnt->outname); + voutln("(FACE F MRR)"); + voutln("(CODINGSCHEME UNSPECIFIED)"); + voutln("(DESIGNSIZE R 10.0)"); + voutln("(DESIGNUNITS R 1000)"); + voutln("(COMMENT DESIGNSIZE (1 em) IS IN POINTS)"); + voutln("(COMMENT OTHER DIMENSIONS ARE MULTIPLES OF DESIGNSIZE/1000)"); + +#if 0 + /* Let vptovf compute the checksum. */ + voutln2("(CHECKSUM O %lo)", cksum ^ 0xFFFFFFFF); +#endif + + vleft(&level); + voutln("FONTDIMEN"); + + Slant = fnt->slant - fnt->efactor * tan(fnt->italicangle * (PI / 180.0)); + + if (Slant) + voutln2("(SLANT R %f)", Slant); + voutln2("(SPACE D %d)", fnt->fontspace); + if (!fnt->fixedpitch) + { + voutln2("(STRETCH D %d)", transform(200, 0, fnt->efactor, fnt->slant)); + voutln2("(SHRINK D %d)", transform(100, 0, fnt->efactor, fnt->slant)); + } + voutln2("(XHEIGHT D %d)", fnt->xheight); + voutln2("(QUAD D %d)", transform(1000, 0, fnt->efactor, fnt->slant)); + voutln2("(EXTRASPACE D %d)", + fnt->fixedpitch ? fnt->fontspace : + transform(111, 0, fnt->efactor, fnt->slant)); + vright(&level); + + for (i = 0; i < fnt->subfont_num; i++) + { + vleft(&level); + voutln2("MAPFONT D %d", i); + voutln2("(FONTNAME %s)", (fnt->subfont_list[i]).name); + voutln2("(FONTCHECKSUM O %lo)", (fnt->subfont_list[i]).cksum); + vright(&level); + } + + for (i = 0; i <= 0xFFFF; i++) + ofm_array[i] = NULL; + + for (ti = fnt->charlist; ti != NULL; ti = ti->next) + if (ti->charcode >= 0 && ti->charcode <= 0xFFFF) + ofm_array[ti->charcode] = ti; + + for (i = 0; i <= 0xFFFF && ofm_array[i] == NULL; i++) + ; + bc = i; + for (i = 0xFFFF; i >= 0 && ofm_array[i] == NULL; i--) + ; + ec = i; + + if (ec < bc) + oops("No TTF characters."); + + for (i = bc; i <= ec; i++) + { + if ((ti = ofm_array[i]) == NULL) continue; + + vleft(&level); + fprintf(out, "CHARACTER H %X\n ", ti->charcode); + + voutln2("(CHARWD R %d)", ti->width); + if (ti->ury) + voutln2("(CHARHT R %d)", ti->ury); + if (ti->lly) + voutln2("(CHARDP R %d)", -ti->lly); + if (ti->urx > ti->width) + voutln2("(CHARIC R %d)", ti->urx - ti->width); + + vleft(&level); + voutln("MAP"); + if (ti->fntnum) + voutln2("(SELECTFONT D %d)", ti->fntnum); + + voutln2("(SETCHAR H %X)", (unsigned)ti->incode); + vright(&level); + + vright(&level); + } + + if (level) + oops("I forgot to match the parentheses."); +} + + /* end */ diff -uNr ttf2pk-1.5_CVS20051222.000/vplaux.h ttf2pk-1.5_CVS20051222.001/vplaux.h --- ttf2pk-1.5_CVS20051222.000/vplaux.h 2002-01-08 21:48:27.000000000 +0900 +++ ttf2pk-1.5_CVS20051222.001/vplaux.h 2005-12-22 16:48:26.000000000 +0900 @@ -16,6 +16,7 @@ void writevpl(Font *fnt, char makevpl, Boolean forceoctal); void upmap(Font *fnt); +void writeovp(Font *fnt); #endif /* VPLAUX_H */