1 #include "SplashTypes.h"
2 #include "SplashOutputDev.h"
3 #include "InfoOutputDev.h"
8 InfoOutputDev::InfoOutputDev(XRef*xref)
13 id2font = new GHash();
14 SplashColor white = {255,255,255};
15 //splash = new SplashOutputDev(splashModeRGB8,320,0,white,0,0);
16 //splash->startDoc(xref);
18 InfoOutputDev::~InfoOutputDev()
22 GBool InfoOutputDev::upsideDown() {return gTrue;}
23 GBool InfoOutputDev::useDrawChar() {return gTrue;}
24 GBool InfoOutputDev::interpretType3Chars() {return gTrue;}
25 GBool InfoOutputDev::useTilingPatternFill() {return gTrue;}
26 void InfoOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, double crop_y1, double crop_x2, double crop_y2)
29 state->transform(crop_x1,crop_y1,&x1,&y1);
30 state->transform(crop_x2,crop_y2,&x2,&y2);
31 if(x2<x1) {double x3=x1;x1=x2;x2=x3;}
32 if(y2<y1) {double y3=y1;y1=y2;y2=y3;}
37 msg("<verbose> Generating info structure for page %d", pageNum);
39 void InfoOutputDev::drawLink(Link *link, Catalog *catalog)
43 double InfoOutputDev::getMaximumFontSize(char*id)
45 FontInfo*info = (FontInfo*)id2font->lookup(id);
47 msg("<error> Unknown font id: %s", id);
50 return info->max_size;
53 static char*getFontID(GfxFont*font)
55 Ref*ref = font->getID();
56 GString*gstr = font->getName();
57 char* fname = gstr==0?0:gstr->getCString();
60 sprintf(buf, "font-%d-%d", ref->num, ref->gen);
62 sprintf(buf, "%s-%d-%d", fname, ref->num, ref->gen);
67 void InfoOutputDev::updateFont(GfxState *state)
69 GfxFont*font = state->getFont();
72 char*id = getFontID(font);
74 FontInfo*info = (FontInfo*)id2font->lookup(id);
76 GString* idStr = new GString(id);
80 id2font->add(idStr, (void*)info);
86 //splash->doUpdateFont(state);
87 //SplashFont* splash_font = splash->getCurrentFont();
89 //printf("%s: %d chars\n", id, splash_font->getNumChars());
92 void InfoOutputDev::drawChar(GfxState *state, double x, double y,
94 double originX, double originY,
95 CharCode code, int nBytes, Unicode *u, int uLen)
97 int render = state->getRender();
100 double m11,m21,m12,m22;
101 state->getFontTransMat(&m11, &m12, &m21, &m22);
102 m11 *= state->getHorizScaling();
103 m21 *= state->getHorizScaling();
104 double lenx = sqrt(m11*m11 + m12*m12);
105 double leny = sqrt(m21*m21 + m22*m22);
106 double len = lenx>leny?lenx:leny;
107 if(currentfont && currentfont->max_size < len) {
108 currentfont->max_size = len;
111 void InfoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
112 int width, int height, GBool invert,
116 OutputDev::drawImageMask(state,ref,str,width,height,invert,inlineImg);
118 void InfoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
119 int width, int height, GfxImageColorMap *colorMap,
120 int *maskColors, GBool inlineImg)
123 OutputDev::drawImage(state,ref,str,width,height,colorMap,maskColors,inlineImg);
125 void InfoOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
126 int width, int height,
127 GfxImageColorMap *colorMap,
129 int maskWidth, int maskHeight,
132 OutputDev::drawMaskedImage(state,ref,str,width,height,colorMap,maskStr,maskWidth,maskHeight,maskInvert);
135 void InfoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
136 int width, int height,
137 GfxImageColorMap *colorMap,
139 int maskWidth, int maskHeight,
140 GfxImageColorMap *maskColorMap)
142 OutputDev::drawSoftMaskedImage(state,ref,str,width,height,colorMap,maskStr,maskWidth,maskHeight,maskColorMap);