X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fttf.c;h=601aa7444da0f3663b6fc7575a7b743b200990ab;hb=94fca1d60ea0f076d7315dbb1c1b27a74176a263;hp=3edcc217e3a96cb666efa18810f957645ac4e3e2;hpb=6b0fcad7a0ca59ec47fe523dcb10662b091737f2;p=swftools.git diff --git a/lib/ttf.c b/lib/ttf.c index 3edcc21..601aa74 100644 --- a/lib/ttf.c +++ b/lib/ttf.c @@ -404,7 +404,7 @@ static table_os2_t*os2_new(ttf_t*ttf) os2->yStrikeoutSize = ttf->head->units_per_em / 10; os2->yStrikeoutPosition = ymid; os2->usWinAscent = ttf->ascent; - os2->usWinDescent = -ttf->descent; + os2->usWinDescent = ttf->descent>0?0:-ttf->descent; os2->sxHeight = ymid; os2->sCapHeight = height*2/3; } @@ -638,6 +638,7 @@ static table_maxp_t*maxp_new(ttf_t*ttf) maxp->maxComponentPoints = 0; maxp->maxComponentContours = 0; } + maxp->maxZones = 2; // we don't use the Z0 zone return maxp; } static table_maxp_t* maxp_parse(ttf_t*ttf, memreader_t*r) @@ -726,8 +727,8 @@ static table_hea_t*hea_new(ttf_t*ttf) for(t=0;tnum_glyphs;t++) { if(ttf->glyphs[t].advance > hea->advanceWidthMax) hea->advanceWidthMax = ttf->glyphs[t].advance; - if(ttf->glyphs[t].xmin < hea->minLeftSideBearing) - hea->minLeftSideBearing = ttf->glyphs[t].xmin; + if(ttf->glyphs[t].bearing < hea->minLeftSideBearing) + hea->minLeftSideBearing = ttf->glyphs[t].bearing; if(ttf->glyphs[t].xmax < hea->minRightSideBearing) hea->minRightSideBearing = ttf->glyphs[t].xmax; int width = ttf->glyphs[t].xmax - ttf->glyphs[t].xmin; @@ -849,10 +850,10 @@ static int mtx_write(ttf_t*ttf, ttf_table_t*w) int t; for(t=0;tglyphs[t].advance); - writeU16(w, ttf->glyphs[t].bearing); + writeS16(w, ttf->glyphs[t].bearing); } for(;tnum_glyphs;t++) { - writeU16(w, ttf->glyphs[t].bearing); + writeS16(w, ttf->glyphs[t].bearing); } return num_advances; } @@ -1418,11 +1419,12 @@ void cmap_write(ttf_t* ttf, ttf_table_t*w) w->data[num_segments_pos++]=(search_range*2); /* backpatch entry selector */ int entry_selector = 0; + tmp = search_range; while(tmp>1) {tmp>>=1;entry_selector++;} w->data[num_segments_pos++]=entry_selector>>8; w->data[num_segments_pos++]=entry_selector; /* backpatch range shift */ - int range_shift = num_segments*2 - search_range; + int range_shift = num_segments*2 - search_range*2; w->data[num_segments_pos++]=range_shift>>8; w->data[num_segments_pos++]=range_shift; @@ -1718,13 +1720,25 @@ void gasp_parse(memreader_t*r, ttf_t*ttf) gasp->records[t].behaviour = readU16(r); } } + +#define GASP_SYMMETRIC_GRIDFIT 0x0008 +#define GASP_SYMMETRIC_SMOOTHING 0x0004 +#define GASP_DOGRAY 0x0002 +#define GASP_GRIDFIT 0x0001 + void gasp_write(ttf_t*ttf, ttf_table_t*table) { table_gasp_t*gasp = ttf->gasp; - writeU16(table, 0); - writeU16(table, gasp->num); + int version = 0; int t; for(t=0;tnum;t++) { + if(gasp->records[t].behaviour & ~(GASP_GRIDFIT | GASP_DOGRAY)) { + version = 1; + } + } + writeU16(table, version); + writeU16(table, gasp->num); + for(t=0;tnum;t++) { writeU16(table, gasp->records[t].size); writeU16(table, gasp->records[t].behaviour); }