Commit 8079dce3 authored by Kristian Høgsberg's avatar Kristian Høgsberg

2005-06-26 Kristian Høgsberg <krh@redhat.com>

        * poppler/CairoOutputDev.cc:
        * poppler/CairoOutputDev.h: Switch back to using drawChar() for
        text, but utilize the beginString() and endString() hooks so we
        can use cairo_show_glyphs() efficiently.
parent 1aa48d6b
2005-06-26 Kristian Høgsberg <krh@redhat.com>
* poppler/CairoOutputDev.cc:
* poppler/CairoOutputDev.h: Switch back to using drawChar() for
text, but utilize the beginString() and endString() hooks so we
can use cairo_show_glyphs() efficiently.
2005-06-26 Albert Astals Cid <aacid@kde.org>
* qt/poppler-page.cc:
* qt/poppler-page.h: Add PageTransition class and
......
......@@ -340,96 +340,51 @@ void CairoOutputDev::eoClip(GfxState *state) {
LOG (printf ("clip-eo\n"));
}
void CairoOutputDev::drawString(GfxState *state, GooString *s)
void CairoOutputDev::beginString(GfxState *state, GooString *s)
{
GfxFont *font;
int wMode;
int render;
// the number of bytes in the string and not the number of glyphs?
int len = s->getLength();
// need at most len glyphs
cairo_glyph_t *glyphs;
char *p = s->getCString();
int count = 0;
double curX, curY;
double riseX, riseY;
font = state->getFont();
wMode = font->getWMode();
if (needFontUpdate) {
glyphs = (cairo_glyph_t *) gmalloc (len * sizeof (cairo_glyph_t));
glyphCount = 0;
}
void CairoOutputDev::drawChar(GfxState *state, double x, double y,
double dx, double dy,
double originX, double originY,
CharCode code, Unicode *u, int uLen)
{
double tx, ty;
glyphs[glyphCount].index = currentFont->getGlyph (code, u, uLen);
state->transform(x, y, &tx, &ty);
glyphs[glyphCount].x = tx;
glyphs[glyphCount].y = ty;
glyphCount++;
}
void CairoOutputDev::endString(GfxState *state)
{
int render;
if (needFontUpdate)
updateFont(state);
}
if (!currentFont) {
if (!currentFont)
return;
}
// check for invisible text -- this is used by Acrobat Capture
render = state->getRender();
if (render == 3) {
if (render == 3)
return;
}
// ignore empty strings
if (len == 0)
if (glyphCount == 0)
return;
glyphs = (cairo_glyph_t *) gmalloc (len * sizeof (cairo_glyph_t));
state->textTransformDelta(0, state->getRise(), &riseX, &riseY);
curX = state->getCurX();
curY = state->getCurY();
while (len > 0) {
double x, y;
double x1, y1;
double dx, dy, tdx, tdy;
double originX, originY, tOriginX, tOriginY;
int n, uLen;
CharCode code;
Unicode u[8];
n = font->getNextChar(p, len, &code,
u, (int)(sizeof(u) / sizeof(Unicode)), &uLen,
&dx, &dy, &originX, &originY);
if (wMode) {
dx *= state->getFontSize();
dy = dy * state->getFontSize() + state->getCharSpace();
if (n == 1 && *p == ' ') {
dy += state->getWordSpace();
}
} else {
dx = dx * state->getFontSize() + state->getCharSpace();
if (n == 1 && *p == ' ') {
dx += state->getWordSpace();
}
dx *= state->getHorizScaling();
dy *= state->getFontSize();
}
originX *= state->getFontSize();
originY *= state->getFontSize();
state->textTransformDelta(dx, dy, &tdx, &tdy);
state->textTransformDelta(originX, originY, &tOriginX, &tOriginY);
x = curX + riseX;
y = curY + riseY;
x -= tOriginX;
y -= tOriginY;
state->transform(x, y, &x1, &y1);
glyphs[count].index = currentFont->getGlyph (code, u, uLen);
glyphs[count].x = x1;
glyphs[count].y = y1;
curX += tdx;
curY += tdy;
p += n;
len -= n;
count++;
}
// fill
if (!(render & 1)) {
LOG (printf ("fill string\n"));
cairo_set_source_rgb (cairo,
fill_color.r, fill_color.g, fill_color.b);
cairo_show_glyphs (cairo, glyphs, count);
cairo_show_glyphs (cairo, glyphs, glyphCount);
}
// stroke
......@@ -437,7 +392,7 @@ void CairoOutputDev::drawString(GfxState *state, GooString *s)
LOG (printf ("stroke string\n"));
cairo_set_source_rgb (cairo,
stroke_color.r, stroke_color.g, stroke_color.b);
cairo_glyph_path (cairo, glyphs, count);
cairo_glyph_path (cairo, glyphs, glyphCount);
cairo_stroke (cairo);
}
......@@ -447,7 +402,7 @@ void CairoOutputDev::drawString(GfxState *state, GooString *s)
// glyphs within one text object before we clip. Right now this
// just add this one string.
LOG (printf ("clip string\n"));
cairo_glyph_path (cairo, glyphs, count);
cairo_glyph_path (cairo, glyphs, glyphCount);
cairo_clip (cairo);
}
......
......@@ -48,7 +48,7 @@ public:
virtual GBool upsideDown() { return gTrue; }
// Does this device use drawChar() or drawString()?
virtual GBool useDrawChar() { return gFalse; }
virtual GBool useDrawChar() { return gTrue; }
// Does this device use beginType3Char/endType3Char? Otherwise,
// text in Type 3 fonts will be drawn with drawChar/drawString.
......@@ -97,7 +97,13 @@ public:
virtual void eoClip(GfxState *state);
//----- text drawing
virtual void drawString(GfxState *state, GooString *s);
void beginString(GfxState *state, GooString *s);
void endString(GfxState *state);
void drawChar(GfxState *state, double x, double y,
double dx, double dy,
double originX, double originY,
CharCode code, Unicode *u, int uLen);
virtual GBool beginType3Char(GfxState *state, double x, double y,
double dx, double dy,
CharCode code, Unicode *u, int uLen);
......@@ -142,6 +148,8 @@ protected:
int pixels_w, pixels_h;
cairo_t *cairo;
GBool needFontUpdate; // set when the font needs to be updated
cairo_glyph_t *glyphs;
int glyphCount;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment