1 #include "InfoOutputDev.h"
6 InfoOutputDev::InfoOutputDev()
11 id2font = new GHash();
13 InfoOutputDev::~InfoOutputDev()
17 GBool InfoOutputDev::upsideDown() {return gTrue;}
18 GBool InfoOutputDev::useDrawChar() {return gTrue;}
19 GBool InfoOutputDev::interpretType3Chars() {return gTrue;}
20 void InfoOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, double crop_y1, double crop_x2, double crop_y2)
23 state->transform(crop_x1,crop_y1,&x1,&y1);
24 state->transform(crop_x2,crop_y2,&x2,&y2);
25 if(x2<x1) {double x3=x1;x1=x2;x2=x3;}
26 if(y2<y1) {double y3=y1;y1=y2;y2=y3;}
31 msg("<verbose> Generating info structure for page %d", pageNum);
33 void InfoOutputDev::drawLink(Link *link, Catalog *catalog)
37 double InfoOutputDev::getMaximumFontSize(char*id)
39 FontInfo*info = (FontInfo*)id2font->lookup(id);
41 msg("<error> Unknown font id: %s", id);
44 return info->max_size;
47 static char*getFontID(GfxFont*font)
49 Ref*ref = font->getID();
50 GString*gstr = font->getName();
51 char* fname = gstr==0?0:gstr->getCString();
54 sprintf(buf, "font-%d-%d", ref->num, ref->gen);
56 sprintf(buf, "%s-%d-%d", fname, ref->num, ref->gen);
62 void InfoOutputDev::updateFont(GfxState *state)
64 GfxFont*font = state->getFont();
67 char*id = getFontID(font);
69 FontInfo*info = (FontInfo*)id2font->lookup(id);
71 GString* idStr = new GString(id);
75 id2font->add(idStr, (void*)info);
82 void InfoOutputDev::drawChar(GfxState *state, double x, double y,
84 double originX, double originY,
85 CharCode code, int nBytes, Unicode *u, int uLen)
87 int render = state->getRender();
90 double m11,m21,m12,m22;
91 state->getFontTransMat(&m11, &m12, &m21, &m22);
92 m11 *= state->getHorizScaling();
93 m21 *= state->getHorizScaling();
94 double lenx = sqrt(m11*m11 + m12*m12);
95 double leny = sqrt(m21*m21 + m22*m22);
96 double len = lenx>leny?lenx:leny;
97 if(currentfont && currentfont->max_size < len) {
98 currentfont->max_size = len;
101 void InfoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
102 int width, int height, GBool invert,
106 OutputDev::drawImageMask(state,ref,str,width,height,invert,inlineImg);
108 void InfoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
109 int width, int height, GfxImageColorMap *colorMap,
110 int *maskColors, GBool inlineImg)
113 OutputDev::drawImage(state,ref,str,width,height,colorMap,maskColors,inlineImg);
115 void InfoOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
116 int width, int height,
117 GfxImageColorMap *colorMap,
119 int maskWidth, int maskHeight,
122 OutputDev::drawMaskedImage(state,ref,str,width,height,colorMap,maskStr,maskWidth,maskHeight,maskInvert);
125 void InfoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
126 int width, int height,
127 GfxImageColorMap *colorMap,
129 int maskWidth, int maskHeight,
130 GfxImageColorMap *maskColorMap)
132 OutputDev::drawSoftMaskedImage(state,ref,str,width,height,colorMap,maskStr,maskWidth,maskHeight,maskColorMap);