fixed bugs in ttf generator
authorMatthias Kramm <kramm@quiss.org>
Thu, 18 Feb 2010 20:04:16 +0000 (12:04 -0800)
committerMatthias Kramm <kramm@quiss.org>
Thu, 18 Feb 2010 20:04:16 +0000 (12:04 -0800)
lib/gfxfont.c
lib/ttf.c
src/Makefile.in

index cc6c62c..8e39272 100644 (file)
@@ -553,6 +553,7 @@ ttf_t* gfxfont_to_ttf(gfxfont_t*font)
        dest->num_points = count;
        dest->points = rfx_calloc(count*sizeof(ttfpoint_t));
        count = 0;
        dest->num_points = count;
        dest->points = rfx_calloc(count*sizeof(ttfpoint_t));
        count = 0;
+       line = src->line;
        while(line) {
            if(line->type == gfx_splineTo) {
                dest->points[count].x = line->sx*scale;
        while(line) {
            if(line->type == gfx_splineTo) {
                dest->points[count].x = line->sx*scale;
@@ -570,6 +571,8 @@ ttf_t* gfxfont_to_ttf(gfxfont_t*font)
            count++;
            line=line->next;
        }
            count++;
            line=line->next;
        }
+       if(count)
+           dest->points[count-1].flags |= GLYPH_CONTOUR_END;
 
        /* compute bounding box */
        int s;
 
        /* compute bounding box */
        int s;
@@ -578,13 +581,13 @@ ttf_t* gfxfont_to_ttf(gfxfont_t*font)
            dest->ymin = dest->ymax = dest->points[0].y;
            for(s=1;s<count;s++) {
                if(dest->points[s].x < dest->xmin) 
            dest->ymin = dest->ymax = dest->points[0].y;
            for(s=1;s<count;s++) {
                if(dest->points[s].x < dest->xmin) 
-                   dest->xmin = dest->points[0].x;
-               if(dest->points[s].y < dest->xmin) 
-                   dest->xmin = dest->points[0].y;
-               if(dest->points[s].x > dest->xmin) 
-                   dest->xmax = dest->points[0].x;
-               if(dest->points[s].y > dest->xmin) 
-                   dest->ymax = dest->points[0].y;
+                   dest->xmin = dest->points[s].x;
+               if(dest->points[s].y < dest->ymin) 
+                   dest->ymin = dest->points[s].y;
+               if(dest->points[s].x > dest->xmax) 
+                   dest->xmax = dest->points[s].x;
+               if(dest->points[s].y > dest->ymax) 
+                   dest->ymax = dest->points[s].y;
            }
        }
 
            }
        }
 
@@ -594,7 +597,7 @@ ttf_t* gfxfont_to_ttf(gfxfont_t*font)
     }
     ttf->unicode_size = max_unicode+1;
     ttf->unicode = rfx_calloc(sizeof(unicode_t)*ttf->unicode_size);
     }
     ttf->unicode_size = max_unicode+1;
     ttf->unicode = rfx_calloc(sizeof(unicode_t)*ttf->unicode_size);
-    for(t=0;t<ttf->num_glyphs;t++) {
+    for(t=0;t<font->num_glyphs;t++) {
        gfxglyph_t*src = &font->glyphs[t];
        int u = font->glyphs[t].unicode;
        if(u>=0)
        gfxglyph_t*src = &font->glyphs[t];
        int u = font->glyphs[t].unicode;
        if(u>=0)
@@ -602,9 +605,9 @@ ttf_t* gfxfont_to_ttf(gfxfont_t*font)
     }
     int u;
     for(u=0;u<font->max_unicode;u++) {
     }
     int u;
     for(u=0;u<font->max_unicode;u++) {
-       int g = font->unicode2glyph[t];
+       int g = font->unicode2glyph[u];
        if(g>=0) {
        if(g>=0) {
-           ttf->unicode[u] = g;
+           ttf->unicode[u] = g+offset;
        }
     }
     ttf->ascent = font->ascent;
        }
     }
     ttf->ascent = font->ascent;
index c17b631..c262009 100644 (file)
--- a/lib/ttf.c
+++ b/lib/ttf.c
@@ -268,10 +268,10 @@ static table_head_t*head_new(ttf_t*ttf)
        head->xmax = ttf->glyphs[0].xmax;
        head->ymax = ttf->glyphs[0].ymax;
        for(t=1;t<ttf->num_glyphs;t++) {
        head->xmax = ttf->glyphs[0].xmax;
        head->ymax = ttf->glyphs[0].ymax;
        for(t=1;t<ttf->num_glyphs;t++) {
-           if(ttf->glyphs[0].xmin < head->xmin) head->xmin = ttf->glyphs[0].xmin;
-           if(ttf->glyphs[0].ymin < head->ymin) head->ymin = ttf->glyphs[0].ymin;
-           if(ttf->glyphs[0].xmax > head->xmax) head->xmax = ttf->glyphs[0].xmax;
-           if(ttf->glyphs[0].ymax > head->ymax) head->ymax = ttf->glyphs[0].ymax;
+           if(ttf->glyphs[t].xmin < head->xmin) head->xmin = ttf->glyphs[t].xmin;
+           if(ttf->glyphs[t].ymin < head->ymin) head->ymin = ttf->glyphs[t].ymin;
+           if(ttf->glyphs[t].xmax > head->xmax) head->xmax = ttf->glyphs[t].xmax;
+           if(ttf->glyphs[t].ymax > head->ymax) head->ymax = ttf->glyphs[t].ymax;
        }
     }
     head->macStyle = 0;
        }
     }
     head->macStyle = 0;
@@ -705,10 +705,10 @@ static table_hea_t*hea_new(ttf_t*ttf)
        for(t=0;t<ttf->num_glyphs;t++) {
            if(ttf->glyphs[t].advance > hea->advanceWidthMax)
                hea->advanceWidthMax = ttf->glyphs[t].advance;
        for(t=0;t<ttf->num_glyphs;t++) {
            if(ttf->glyphs[t].advance > hea->advanceWidthMax)
                hea->advanceWidthMax = ttf->glyphs[t].advance;
-           if(ttf->glyphs[t].xmin < ttf->hea->minLeftSideBearing)
-               ttf->hea->minLeftSideBearing = ttf->glyphs[t].xmin;
-           if(ttf->glyphs[t].xmax < ttf->hea->minRightSideBearing)
-               ttf->hea->minRightSideBearing = ttf->glyphs[t].xmax;
+           if(ttf->glyphs[t].xmin < hea->minLeftSideBearing)
+               hea->minLeftSideBearing = ttf->glyphs[t].xmin;
+           if(ttf->glyphs[t].xmax < hea->minRightSideBearing)
+               hea->minRightSideBearing = ttf->glyphs[t].xmax;
            int width = ttf->glyphs[t].xmax - ttf->glyphs[t].xmin;
            if(width > hea->xMaxExtent)
                hea->xMaxExtent = width;
            int width = ttf->glyphs[t].xmax - ttf->glyphs[t].xmin;
            if(width > hea->xMaxExtent)
                hea->xMaxExtent = width;
index d85d8af..8c8c802 100644 (file)
@@ -59,7 +59,7 @@ parser.$(O): parser.yy.c parser.h ../lib/q.h
 ../lib/libgfxpdf$(A): ../lib/pdf/GFXOutputDev.cc
        cd ../lib;$(MAKE) libgfxpdf$(A);cd -
 
 ../lib/libgfxpdf$(A): ../lib/pdf/GFXOutputDev.cc
        cd ../lib;$(MAKE) libgfxpdf$(A);cd -
 
-../lib/libgfx$(A): ../lib/devices/*.c
+../lib/libgfx$(A): ../lib/devices/*.c ../lib/gfxdevice.h ../lib/gfxtools.c ../lib/gfxfont.c
        cd ../lib;$(MAKE) libgfx$(A);cd -
 
 ../lib/libgfxswf$(A): ../lib/devices/swf.c
        cd ../lib;$(MAKE) libgfx$(A);cd -
 
 ../lib/libgfxswf$(A): ../lib/devices/swf.c