X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fttf.c;h=c1fd06db7be04816483718cfe5020d941697c6c8;hp=3edcc217e3a96cb666efa18810f957645ac4e3e2;hb=fc8854e5ed42dbcef96d25eb851b9873707a15ff;hpb=6b0fcad7a0ca59ec47fe523dcb10662b091737f2 diff --git a/lib/ttf.c b/lib/ttf.c index 3edcc21..c1fd06d 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; @@ -1636,15 +1638,15 @@ static table_post_t*post_new(ttf_t*ttf) void post_parse(memreader_t*r, ttf_t*ttf) { table_post_t*post = ttf->post = rfx_calloc(sizeof(table_post_t)); - U16 format = readU16(r); - post->italic_angle = readU16(r); + U32 format = readU32(r); + post->italic_angle = readU32(r); post->underline_position = readU16(r); post->underline_thickness = readU16(r); - U16 is_monospaced = readU16(r); - readU16(r); // min mem 42 - readU16(r); - readU16(r); // min mem 1 - readU16(r); + U16 is_monospaced = readU32(r); + readU32(r); // min mem 42 + readU32(r); + readU32(r); // min mem 1 + readU32(r); } void post_write(ttf_t*ttf, ttf_table_t*table) { @@ -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); }