X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fttf.c;h=0e442d108f0747412f62b58460c95837b105c1e9;hp=3edcc217e3a96cb666efa18810f957645ac4e3e2;hb=c1c865b58f4fbc9c97f92110306e277665ad9c81;hpb=6b0fcad7a0ca59ec47fe523dcb10662b091737f2 diff --git a/lib/ttf.c b/lib/ttf.c index 3edcc21..0e442d1 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; } @@ -726,8 +726,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 +849,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 +1418,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;