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 void InfoOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, double crop_y1, double crop_x2, double crop_y2)
28 state->transform(crop_x1,crop_y1,&x1,&y1);
29 state->transform(crop_x2,crop_y2,&x2,&y2);
30 if(x2<x1) {double x3=x1;x1=x2;x2=x3;}
31 if(y2<y1) {double y3=y1;y1=y2;y2=y3;}
36 msg("<verbose> Generating info structure for page %d", pageNum);
38 void InfoOutputDev::drawLink(Link *link, Catalog *catalog)
42 double InfoOutputDev::getMaximumFontSize(char*id)
44 FontInfo*info = (FontInfo*)id2font->lookup(id);
46 msg("<error> Unknown font id: %s", id);
49 return info->max_size;
52 static char*getFontID(GfxFont*font)
54 Ref*ref = font->getID();
55 GString*gstr = font->getName();
56 char* fname = gstr==0?0:gstr->getCString();
59 sprintf(buf, "font-%d-%d", ref->num, ref->gen);
61 sprintf(buf, "%s-%d-%d", fname, ref->num, ref->gen);
66 void InfoOutputDev::updateFont(GfxState *state)
68 GfxFont*font = state->getFont();
71 char*id = getFontID(font);
73 FontInfo*info = (FontInfo*)id2font->lookup(id);
75 GString* idStr = new GString(id);
79 id2font->add(idStr, (void*)info);
85 splash->doUpdateFont(state);
86 SplashFont* splash_font = splash->font;
87 //printf("%s: %d chars\n", id, splash_font->getNumChars());
90 void InfoOutputDev::drawChar(GfxState *state, double x, double y,
92 double originX, double originY,
93 CharCode code, int nBytes, Unicode *u, int uLen)
95 int render = state->getRender();
98 double m11,m21,m12,m22;
99 state->getFontTransMat(&m11, &m12, &m21, &m22);
100 m11 *= state->getHorizScaling();
101 m21 *= state->getHorizScaling();
102 double lenx = sqrt(m11*m11 + m12*m12);
103 double leny = sqrt(m21*m21 + m22*m22);
104 double len = lenx>leny?lenx:leny;
105 if(currentfont && currentfont->max_size < len) {
106 currentfont->max_size = len;
109 void InfoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
110 int width, int height, GBool invert,
114 OutputDev::drawImageMask(state,ref,str,width,height,invert,inlineImg);
116 void InfoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
117 int width, int height, GfxImageColorMap *colorMap,
118 int *maskColors, GBool inlineImg)
121 OutputDev::drawImage(state,ref,str,width,height,colorMap,maskColors,inlineImg);
123 void InfoOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
124 int width, int height,
125 GfxImageColorMap *colorMap,
127 int maskWidth, int maskHeight,
130 OutputDev::drawMaskedImage(state,ref,str,width,height,colorMap,maskStr,maskWidth,maskHeight,maskInvert);
133 void InfoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
134 int width, int height,
135 GfxImageColorMap *colorMap,
137 int maskWidth, int maskHeight,
138 GfxImageColorMap *maskColorMap)
140 OutputDev::drawSoftMaskedImage(state,ref,str,width,height,colorMap,maskStr,maskWidth,maskHeight,maskColorMap);