[poppler] poppler/poppler: CairoOutputDev.cc, 1.14, 1.15 CairoOutputDev.h, 1.4, 1.5

Kristian Hogsberg krh at freedesktop.org
Sun Jun 26 18:04:35 PDT 2005


Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv8209/poppler

Modified Files:
	CairoOutputDev.cc CairoOutputDev.h 
Log Message:
2005-06-26  Kristian Høgsberg  <krh at 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.



Index: CairoOutputDev.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.cc,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- CairoOutputDev.cc	26 May 2005 13:03:35 -0000	1.14
+++ CairoOutputDev.cc	27 Jun 2005 01:04:33 -0000	1.15
@@ -340,96 +340,51 @@
   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 @@
     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 @@
     // 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);
   }
   

Index: CairoOutputDev.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CairoOutputDev.h	26 May 2005 13:03:35 -0000	1.4
+++ CairoOutputDev.h	27 Jun 2005 01:04:33 -0000	1.5
@@ -48,7 +48,7 @@
   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 @@
   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 @@
   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



More information about the poppler mailing list