X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2FInfoOutputDev.cc;h=a142c772d946f510822cb86a90625658d7eee00c;hb=5ba24931ec3861ca5befcaae1502dd9105639b44;hp=affad697948cd809648ab01781283a4057ac185e;hpb=727449f065760e1d99735f44638c25678cd8bc52;p=swftools.git diff --git a/lib/pdf/InfoOutputDev.cc b/lib/pdf/InfoOutputDev.cc index affad69..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 @@ -106,7 +107,7 @@ static int findSpace(gfxfont_t*font) first_space = t; } } - if(GLYPH_IS_SPACE(&font->glyphs[32])) { + if(font->num_glyphs>32 && GLYPH_IS_SPACE(&font->glyphs[32])) { return 32; } return first_space; @@ -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,