more fiddling with edgestyles
[swftools.git] / lib / ttf.c
index 3edcc21..fbbf200 100644 (file)
--- 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;
     }
@@ -849,10 +849,10 @@ static int mtx_write(ttf_t*ttf, ttf_table_t*w)
     int t;
     for(t=0;t<num_advances;t++) {
        writeU16(w, ttf->glyphs[t].advance);
-       writeU16(w, ttf->glyphs[t].bearing);
+       writeS16(w, ttf->glyphs[t].bearing);
     }
     for(;t<ttf->num_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;