X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2FInfoOutputDev.cc;h=a142c772d946f510822cb86a90625658d7eee00c;hb=5ba24931ec3861ca5befcaae1502dd9105639b44;hp=fd9bf99c6318e2d7348bee8bf8f49c2c18a3e130;hpb=886a79f1f7573aff476e7053637292c46f3c1471;p=swftools.git diff --git a/lib/pdf/InfoOutputDev.cc b/lib/pdf/InfoOutputDev.cc index fd9bf99..a142c77 100644 --- a/lib/pdf/InfoOutputDev.cc +++ b/lib/pdf/InfoOutputDev.cc @@ -15,6 +15,7 @@ #endif #include "GfxState.h" #include "../log.h" +#include "../q.h" #include #include @@ -216,6 +217,20 @@ static gfxfont_t* createGfxFont(FontInfo*src) return font; } +static float find_average_glyph_advance(gfxfont_t*f) +{ + if(!f->num_glyphs) + return 0.0; + + float*values = (float*)malloc(sizeof(float)*f->num_glyphs); + int t; + for(t=0;tnum_glyphs;t++) { + values[t] = f->glyphs[t].advance; + } + float m = medianf(values, f->num_glyphs); + free(values); + return m; +} gfxfont_t* FontInfo::getGfxFont() { @@ -223,6 +238,8 @@ gfxfont_t* FontInfo::getGfxFont() this->gfxfont = createGfxFont(this); this->gfxfont->id = strdup(this->id); this->space_char = findSpace(this->gfxfont); + this->average_advance = find_average_glyph_advance(this->gfxfont); + if(this->space_char>=0) { msg(" Font %s has space char %d (unicode=%d)", this->id, this->space_char,