--- fontforge/tottf.c.orig Mon Jun 7 19:18:27 2004 +++ fontforge/tottf.c Wed Jun 16 13:37:06 2004 @@ -3038,6 +3038,8 @@ int i,j,cnt1,cnt2,first,last,avg1,avg2,k; SplineFont *sf = _sf; char *pt; + static int const weightFactors[26] = { 64, 14, 27, 35, 100, 20, 14, 42, 63, + 3, 6, 35, 20, 56, 56, 17, 4, 49, 56, 71, 31, 10, 18, 3, 18, 2 }; os2->version = 1; os2->weightClass = sf->pfminfo.weight; @@ -3102,9 +3104,10 @@ if ( sf->chars[i]->width!=0 ) { avg2 += sf->chars[i]->width; ++cnt2; } - if ( sf->chars[i]->unicodeenc==' ' || - (sf->chars[i]->unicodeenc>='a' && sf->chars[i]->unicodeenc<='z')) { - avg1 += sf->chars[i]->width; ++cnt1; + if ( sf->chars[i]->unicodeenc==' ') { + avg1 += sf->chars[i]->width * 166; ++cnt1; + } else if (sf->chars[i]->unicodeenc>='a' && sf->chars[i]->unicodeenc<='z') { + avg1 += sf->chars[i]->width * weightFactors[sf->chars[i]->unicodeenc-'a']; ++cnt1; } } } @@ -3122,9 +3125,9 @@ while ( ptachVendID ) *pt++ = ' '; /* Pad with spaces not NUL */ os2->avgCharWid = 500; - /*if ( cnt1==27 ) - os2->avgCharWid = avg1/cnt1; - else*/ if ( cnt2!=0 ) + if ( cnt1==27 ) + os2->avgCharWid = avg1/1000; + else if ( cnt2!=0 ) os2->avgCharWid = avg2/cnt2; memcpy(os2->panose,sf->pfminfo.panose,sizeof(os2->panose)); if ( format==ff_ttfsym ) { @@ -3349,11 +3352,34 @@ putshort(at->os2f,0); } -static void dumpgasp(struct alltabs *at) { +static void dumpgasp(struct alltabs *at, SplineFont *sf) { + BDFFont *bdf; + uint32 bitmaps = 0; + int i, rangecnt = 1; + + for ( bdf=sf->bitmaps; bdf!=NULL; bdf=bdf->next) { + if ( BDFDepth(bdf)==1 && bdf->pixelsize<=32 ) + bitmaps |= 1<<(bdf->pixelsize-1); + } + for ( i=1; i<32; i++ ) { + if ( (bitmaps&(1<gaspf = tmpfile(); putshort(at->gaspf,0); /* Version number */ - putshort(at->gaspf,1); /* One range */ + putshort(at->gaspf,rangecnt); /* One range */ + for ( i=0; i<31; i++ ) { + if ( (bitmaps&(1<gaspf, i+1); + putshort(at->gaspf, bitmaps&(1<gaspf,32); + putshort(at->gaspf,0x0); + } putshort(at->gaspf,0xffff); /* Upper bound on pixels/em for this range */ putshort(at->gaspf,0x2); /* Grey scale, no gridfitting */ /* No hints, so no grids to fit */ @@ -4730,7 +4756,7 @@ redoos2(at); if ( format!=ff_otf && format!=ff_otfcid && format!=ff_none ) { if ( !SFHasInstructions(sf)) - dumpgasp(at); + dumpgasp(at, sf); at->fpgmf = dumpstoredtable(sf,CHR('f','p','g','m'),&at->fpgmlen); at->prepf = dumpstoredtable(sf,CHR('p','r','e','p'),&at->preplen); at->cvtf = dumpstoredtable(sf,CHR('c','v','t',' '),&at->cvtlen);