From 687def0f4060cf9e48dba017316314c05f7b0480 Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Thu, 18 Feb 2010 12:04:16 -0800 Subject: [PATCH] fixed bugs in ttf generator --- lib/gfxfont.c | 23 +++++++++++++---------- lib/ttf.c | 16 ++++++++-------- src/Makefile.in | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/lib/gfxfont.c b/lib/gfxfont.c index cc6c62c..8e39272 100644 --- a/lib/gfxfont.c +++ b/lib/gfxfont.c @@ -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; + line = src->line; 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; } + if(count) + dest->points[count-1].flags |= GLYPH_CONTOUR_END; /* 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;spoints[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); - for(t=0;tnum_glyphs;t++) { + for(t=0;tnum_glyphs;t++) { 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;umax_unicode;u++) { - int g = font->unicode2glyph[t]; + int g = font->unicode2glyph[u]; if(g>=0) { - ttf->unicode[u] = g; + ttf->unicode[u] = g+offset; } } ttf->ascent = font->ascent; diff --git a/lib/ttf.c b/lib/ttf.c index c17b631..c262009 100644 --- 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;tnum_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; @@ -705,10 +705,10 @@ 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 < 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; diff --git a/src/Makefile.in b/src/Makefile.in index d85d8af..8c8c802 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -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/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 -- 1.7.10.4