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->getCurrentFont();
88 //printf("%s: %d chars\n", id, splash_font->getNumChars());
91 void InfoOutputDev::drawChar(GfxState *state, double x, double y,
93 double originX, double originY,
94 CharCode code, int nBytes, Unicode *u, int uLen)
96 int render = state->getRender();
99 double m11,m21,m12,m22;
100 state->getFontTransMat(&m11, &m12, &m21, &m22);
101 m11 *= state->getHorizScaling();
102 m21 *= state->getHorizScaling();
103 double lenx = sqrt(m11*m11 + m12*m12);
104 double leny = sqrt(m21*m21 + m22*m22);
105 double len = lenx>leny?lenx:leny;
106 if(currentfont && currentfont->max_size < len) {
107 currentfont->max_size = len;
110 void InfoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
111 int width, int height, GBool invert,
115 OutputDev::drawImageMask(state,ref,str,width,height,invert,inlineImg);
117 void InfoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
118 int width, int height, GfxImageColorMap *colorMap,
119 int *maskColors, GBool inlineImg)
122 OutputDev::drawImage(state,ref,str,width,height,colorMap,maskColors,inlineImg);
124 void InfoOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
125 int width, int height,
126 GfxImageColorMap *colorMap,
128 int maskWidth, int maskHeight,
131 OutputDev::drawMaskedImage(state,ref,str,width,height,colorMap,maskStr,maskWidth,maskHeight,maskInvert);
134 void InfoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
135 int width, int height,
136 GfxImageColorMap *colorMap,
138 int maskWidth, int maskHeight,
139 GfxImageColorMap *maskColorMap)
141 OutputDev::drawSoftMaskedImage(state,ref,str,width,height,colorMap,maskStr,maskWidth,maskHeight,maskColorMap);