X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fpdf%2FInfoOutputDev.cc;h=7c83566ab4d4dc2f1ab05403fbf63cbd402490ec;hp=ec545726a30437f8e7ce068b44e33bb3e9fdcd06;hb=4af346b956d4922d0ea6322e3e1f52ec1beff2d7;hpb=c6d815f656ed77b45bfb5685c030c97f6245044c diff --git a/lib/pdf/InfoOutputDev.cc b/lib/pdf/InfoOutputDev.cc index ec54572..7c83566 100644 --- a/lib/pdf/InfoOutputDev.cc +++ b/lib/pdf/InfoOutputDev.cc @@ -1,6 +1,5 @@ #include "SplashTypes.h" #include "SplashOutputDev.h" -#include "SplashPath.h" #include "InfoOutputDev.h" #include "GfxState.h" #include "../log.h" @@ -11,44 +10,14 @@ InfoOutputDev::InfoOutputDev(XRef*xref) num_links = 0; num_images = 0; num_fonts = 0; - id2font = new GHash(1); + id2font = new GHash(); SplashColor white = {255,255,255}; - splash = new SplashOutputDev(splashModeRGB8,320,0,white,0,0); - splash->startDoc(xref); + //splash = new SplashOutputDev(splashModeRGB8,320,0,white,0,0); + //splash->startDoc(xref); } InfoOutputDev::~InfoOutputDev() { - GHashIter*i; - id2font->startIter(&i); - GString*key; - FontInfo*fontinfo; - while(id2font->getNext(&i, &key, (void**)&fontinfo)) { - delete fontinfo; - } - id2font->killIter(&i); - delete id2font; - delete splash; -} -FontInfo::FontInfo() -{ - this->charid2glyph = 0; -} -FontInfo::~FontInfo() -{ - this->font = 0; - if(this->charid2glyph) { - free(this->charid2glyph); - this->charid2glyph = 0; - } - int t; - for(t=0;tpath;glyphs[t]->path = 0; - delete glyphs[t]; - glyphs[t]=0; - } - } } GBool InfoOutputDev::upsideDown() {return gTrue;} GBool InfoOutputDev::useDrawChar() {return gTrue;} @@ -81,7 +50,7 @@ double InfoOutputDev::getMaximumFontSize(char*id) return info->max_size; } -char*getFontID(GfxFont*font) +static char*getFontID(GfxFont*font) { Ref*ref = font->getID(); GString*gstr = font->getName(); @@ -100,46 +69,24 @@ void InfoOutputDev::updateFont(GfxState *state) GfxFont*font = state->getFont(); if(!font) return; - if(font->getType() == fontType3) { - return; - } char*id = getFontID(font); - + FontInfo*info = (FontInfo*)id2font->lookup(id); - if(info) { - /* font already known */ - free(id); - currentfont = info; - return; + if(!info) { + GString* idStr = new GString(id); + info = new FontInfo; + info->font = font; + info->max_size = 0; + id2font->add(idStr, (void*)info); + free(id); + num_fonts++; } + currentfont = info; - info = new FontInfo; - info->font = font; - info->max_size = 0; - - state->setCTM(1.0,0,0,1.0,0,0); - splash->updateCTM(state, 0,0,0,0,0,0); - state->setTextMat(1.0,0,0,-1.0,0,0); - state->setFont(font, 1024.0); - splash->doUpdateFont(state); - info->splash_font = splash->getCurrentFont(); - info->num_glyphs = 0; - info->glyphs = 0; + //splash->doUpdateFont(state); + //SplashFont* splash_font = splash->getCurrentFont(); - if(!info->splash_font) { - delete info; - return; - } - - GString* idStr = new GString(id); - id2font->add(idStr, (void*)info); - num_fonts++; - currentfont = info; - free(id); -} -FontInfo* InfoOutputDev::getFont(char*id) -{ - return (FontInfo*)id2font->lookup(id); + //printf("%s: %d chars\n", id, splash_font->getNumChars()); } void InfoOutputDev::drawChar(GfxState *state, double x, double y, @@ -147,6 +94,9 @@ void InfoOutputDev::drawChar(GfxState *state, double x, double y, double originX, double originY, CharCode code, int nBytes, Unicode *u, int uLen) { + int render = state->getRender(); + if (render == 3) + return; double m11,m21,m12,m22; state->getFontTransMat(&m11, &m12, &m21, &m22); m11 *= state->getHorizScaling(); @@ -157,21 +107,6 @@ void InfoOutputDev::drawChar(GfxState *state, double x, double y, if(currentfont && currentfont->max_size < len) { currentfont->max_size = len; } - if(code >= currentfont->num_glyphs) { - currentfont->glyphs = (GlyphInfo**)realloc(currentfont->glyphs, sizeof(GlyphInfo*)*(code+1)); - memset(¤tfont->glyphs[currentfont->num_glyphs], 0, sizeof(SplashPath*)*((code+1)-currentfont->num_glyphs)); - currentfont->num_glyphs = code+1; - } - GlyphInfo*g = currentfont->glyphs[code]; - if(!g) { - g = currentfont->glyphs[code] = new GlyphInfo(); - g->path = currentfont->splash_font->getGlyphPath(code); - g->unicode = 0; - } - if(uLen && (u[0]>=32 && u[0]unicode || !g->unicode)) { - g->unicode = u[0]; - } - } void InfoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert,