From: kramm Date: Mon, 6 Oct 2008 12:57:07 +0000 (+0000) Subject: derive advance value from font parameters or text spacing samples. New parameter... X-Git-Tag: buttons-working~17 X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=commitdiff_plain;h=9f378b70ff01b6210e67d1b72b5ca3871016e3d7 derive advance value from font parameters or text spacing samples. New parameter 'bigchar' --- diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index 16e5e91..3dcaed9 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -564,6 +564,7 @@ GFXOutputDev::GFXOutputDev(InfoOutputDev*info, PDFDoc*doc) this->pages = 0; this->pagebuflen = 0; this->pagepos = 0; + this->config_bigchar=0; this->config_convertgradients=1; this->config_break_on_warning=0; this->config_remapunicode=0; @@ -592,6 +593,8 @@ void GFXOutputDev::setParameter(const char*key, const char*value) this->config_convertgradients = atoi(value); } else if(!strcmp(key,"optimize_polygons")) { this->config_optimize_polygons = atoi(value); + } else if(!strcmp(key,"bigchar")) { + this->config_bigchar = atoi(value); } else if(!strcmp(key,"fontquality")) { this->config_fontquality = atof(value); if(this->config_fontquality<=1) @@ -1842,7 +1845,7 @@ void GFXOutputDev::updateStrokeColor(GfxState *state) } -static gfxfont_t* createGfxFont(GfxFont*xpdffont, FontInfo*src, double config_fontquality) +gfxfont_t* GFXOutputDev::createGfxFont(GfxFont*xpdffont, FontInfo*src) { gfxfont_t*font = (gfxfont_t*)malloc(sizeof(gfxfont_t)); memset(font, 0, sizeof(gfxfont_t)); @@ -1851,11 +1854,14 @@ static gfxfont_t* createGfxFont(GfxFont*xpdffont, FontInfo*src, double config_fo memset(font->glyphs, 0, sizeof(gfxglyph_t)*src->num_glyphs); font->id = 0; int t; - + double quality = (INTERNAL_FONT_SIZE * 200 / config_fontquality) / src->max_size; double scale = 1; //printf("%d glyphs\n", font->num_glyphs); font->num_glyphs = 0; + font->ascent = fabs(src->descender); + font->descent = fabs(src->ascender); + for(t=0;tnum_glyphs;t++) { if(src->glyphs[t]) { SplashPath*path = src->glyphs[t]->path; @@ -1897,8 +1903,21 @@ static gfxfont_t* createGfxFont(GfxFont*xpdffont, FontInfo*src, double config_fo // (f&splashPathFirst)?"first":"", // (f&splashPathLast)?"last":""); } + glyph->line = (gfxline_t*)drawer.result(&drawer); - glyph->advance = xmax*scale; // we don't know the real advance value, so this'll have to do + if(src->glyphs[t]->advance>0) { + glyph->advance = src->glyphs[t]->advance; + } else { + msg(" Approximating advance value for glyph %d", t); + glyph->advance = xmax*scale; + } + if(this->config_bigchar) { + double max = src->glyphs[t]->advance_max; + if(max>0 && max > glyph->advance) { + glyph->advance = max; + } + } + font->num_glyphs++; } } @@ -1944,7 +1963,7 @@ void GFXOutputDev::updateFont(GfxState *state) gfxfont_t*font = gfxfontlist_findfont(this->gfxfontlist,id); if(!font) { - font = createGfxFont(gfxFont, current_fontinfo, this->config_fontquality); + font = this->createGfxFont(gfxFont, current_fontinfo); font->id = strdup(id); this->gfxfontlist = gfxfontlist_addfont(this->gfxfontlist, font); } diff --git a/lib/pdf/GFXOutputDev.h b/lib/pdf/GFXOutputDev.h index a907b71..f966e7c 100644 --- a/lib/pdf/GFXOutputDev.h +++ b/lib/pdf/GFXOutputDev.h @@ -214,6 +214,8 @@ public: void clipToGfxLine(GfxState *state, gfxline_t*line); void fillGfxLine(GfxState *state, gfxline_t*line); + gfxfont_t* createGfxFont(GfxFont*xpdffont, FontInfo*src); + void showfeature(const char*feature,char fully, char warn); void warnfeature(const char*feature,char fully); void infofeature(const char*feature); @@ -281,6 +283,7 @@ public: int config_extrafontdata; int config_convertgradients; int config_optimize_polygons; + int config_bigchar; double config_fontquality; double *dashPattern;