These two patches:

1) Avoid using show_text_glyphs in cairo output when it is either not
   supported or the character mapping can not be reliably obtained.

2) Update the SEE ALSO section of all man pages to add missing entries
   and sort alphabetically.

>From ceb051917168dda06223fdcfa3f2c4947c75f960 Mon Sep 17 00:00:00 2001
From: Adrian Johnson <[email protected]>
Date: Mon, 22 Aug 2011 21:26:24 +0930
Subject: [PATCH 1/2] cairo: only use show_text_glyphs if the surface supports it and the font has toUnicode

When generating pdf output, fonts that do not have toUnicode cause an
excessive number of empty text ActualText entries to be written due to
glyphs that do not have have a mapping.
---
 poppler/CairoOutputDev.cc |   12 ++++++++----
 poppler/CairoOutputDev.h  |    1 +
 poppler/GfxFont.h         |    3 +++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 08c28ec..e894b4e 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -138,6 +138,7 @@ CairoOutputDev::CairoOutputDev() {
   currentFont = NULL;
   prescaleImages = gTrue;
   printing = gTrue;
+  use_show_text_glyphs = gFalse;
   inType3Char = gFalse;
   t3_glyph_has_bbox = gFalse;
 
@@ -578,6 +579,9 @@ void CairoOutputDev::updateFont(GfxState *state) {
 
   font_face = currentFont->getFontFace();
   cairo_set_font_face (cairo, font_face);
+
+  use_show_text_glyphs = state->getFont()->hasToUnicodeCMap() &&
+    cairo_surface_has_show_text_glyphs (cairo_get_target (cairo));
  
   double fontSize = state->getFontSize();
   double *m = state->getTextMat();
@@ -1001,7 +1005,7 @@ void CairoOutputDev::beginString(GfxState *state, GooString *s)
 
   glyphs = (cairo_glyph_t *) gmallocn (len, sizeof (cairo_glyph_t));
   glyphCount = 0;
-  if (printing) {
+  if (use_show_text_glyphs) {
     clusters = (cairo_text_cluster_t *) gmallocn (len, sizeof (cairo_text_cluster_t));
     clusterCount = 0;
     utf8Max = len*2; // start with twice the number of glyphs. we will realloc if we need more.
@@ -1020,7 +1024,7 @@ void CairoOutputDev::drawChar(GfxState *state, double x, double y,
     glyphs[glyphCount].x = x - originX;
     glyphs[glyphCount].y = y - originY;
     glyphCount++;
-    if (printing) {
+    if (use_show_text_glyphs) {
       if (utf8Max - utf8Count < uLen*6) {
         // utf8 encoded characters can be up to 6 bytes
 	if (utf8Max > uLen*6)
@@ -1070,7 +1074,7 @@ void CairoOutputDev::endString(GfxState *state)
   if (!(render & 1) && !haveCSPattern) {
     LOG (printf ("fill string\n"));
     cairo_set_source (cairo, fill_pattern);
-    if (printing)
+    if (use_show_text_glyphs)
       cairo_show_text_glyphs (cairo, utf8, utf8Count, glyphs, glyphCount, clusters, clusterCount, (cairo_text_cluster_flags_t)0);
     else
         cairo_show_glyphs (cairo, glyphs, glyphCount);
@@ -1118,7 +1122,7 @@ void CairoOutputDev::endString(GfxState *state)
 
   gfree (glyphs);
   glyphs = NULL;
-  if (printing) {
+  if (use_show_text_glyphs) {
     gfree (clusters);
     clusters = NULL;
     gfree (utf8);
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 67f7810..386e844 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -301,6 +301,7 @@ protected:
   cairo_matrix_t orig_matrix;
   GBool needFontUpdate;                // set when the font needs to be updated
   GBool printing;
+  GBool use_show_text_glyphs;
   cairo_surface_t *surface;
   cairo_glyph_t *glyphs;
   int glyphCount;
diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h
index 09af062..9550398 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -221,6 +221,9 @@ public:
 			  Unicode **u, int *uLen,
 			  double *dx, double *dy, double *ox, double *oy) = 0;
 
+  // Does this font have a toUnicode map?
+  GBool hasToUnicodeCMap() { return hasToUnicode; }
+
   /* XXX: dfp shouldn't be public, however the font finding code is currently in
    * GlobalParams. Instead it should be inside the GfxFont class. However,
    * getDisplayFont currently uses FCcfg so moving it is not as simple. */
-- 
1.7.4.1

>From f0eb6db2eba25c40c06b6c52c54403102456d103 Mon Sep 17 00:00:00 2001
From: Adrian Johnson <[email protected]>
Date: Mon, 22 Aug 2011 21:41:36 +0930
Subject: [PATCH 2/2] update SEE ALSO section of man pages

- ensure each man page references all other utils
- sort list of utils in alphabetical order
---
 utils/pdffonts.1   |    8 +++++---
 utils/pdfimages.1  |    8 +++++---
 utils/pdfinfo.1    |    8 +++++---
 utils/pdftocairo.1 |    2 +-
 utils/pdftohtml.1  |    8 ++++++++
 utils/pdftoppm.1   |    8 +++++---
 utils/pdftops.1    |    8 +++++---
 utils/pdftotext.1  |    9 +++++----
 8 files changed, 39 insertions(+), 20 deletions(-)

diff --git a/utils/pdffonts.1 b/utils/pdffonts.1
index fd7386c..e125cfd 100644
--- a/utils/pdffonts.1
+++ b/utils/pdffonts.1
@@ -103,8 +103,10 @@ Other error.
 The pdffonts software and documentation are copyright 1996-2004 Glyph
 & Cog, LLC.
 .SH "SEE ALSO"
-.BR pdftops (1),
-.BR pdftotext (1),
+.BR pdfimages (1),
 .BR pdfinfo (1),
+.BR pdftocairo (1),
+.BR pdftohtml (1),
 .BR pdftoppm (1),
-.BR pdfimages (1),
+.BR pdftops (1),
+.BR pdftotext (1)
diff --git a/utils/pdfimages.1 b/utils/pdfimages.1
index 986a296..3f9d816 100644
--- a/utils/pdfimages.1
+++ b/utils/pdfimages.1
@@ -78,8 +78,10 @@ Other error.
 The pdfimages software and documentation are copyright 1998-2004 Glyph
 & Cog, LLC.
 .SH "SEE ALSO"
-.BR pdftops (1),
-.BR pdftotext (1),
-.BR pdfinfo (1),
 .BR pdffonts (1),
+.BR pdfinfo (1),
+.BR pdftocairo (1),
+.BR pdftohtml (1),
 .BR pdftoppm (1),
+.BR pdftops (1),
+.BR pdftotext (1)
diff --git a/utils/pdfinfo.1 b/utils/pdfinfo.1
index 1f5528a..274767e 100644
--- a/utils/pdfinfo.1
+++ b/utils/pdfinfo.1
@@ -130,8 +130,10 @@ Other error.
 The pdfinfo software and documentation are copyright 1996-2004 Glyph &
 Cog, LLC.
 .SH "SEE ALSO"
-.BR pdftops (1),
-.BR pdftotext (1),
 .BR pdffonts (1),
-.BR pdftoppm (1),
 .BR pdfimages (1),
+.BR pdftocairo (1),
+.BR pdftohtml (1),
+.BR pdftoppm (1),
+.BR pdftops (1),
+.BR pdftotext (1)
diff --git a/utils/pdftocairo.1 b/utils/pdftocairo.1
index 6c647ec..1502003 100644
--- a/utils/pdftocairo.1
+++ b/utils/pdftocairo.1
@@ -251,4 +251,4 @@ The pdftocairo software and documentation are copyright 1996-2004 Glyph
 .BR pdftohtml (1),
 .BR pdftoppm (1),
 .BR pdftops (1),
-.BR pdftotext (1),
+.BR pdftotext (1)
diff --git a/utils/pdftohtml.1 b/utils/pdftohtml.1
index 9d7e2ed..f5c6bb6 100644
--- a/utils/pdftohtml.1
+++ b/utils/pdftohtml.1
@@ -92,3 +92,11 @@ based and benefits a lot from Derek Noonburg's xpdf package.
 
 This manual page was written by Søren Boll Overgaard <[email protected]>,
 for the Debian GNU/Linux system (but may be used by others).
+.SH "SEE ALSO"
+.BR pdffonts (1),
+.BR pdfimages (1),
+.BR pdfinfo (1),
+.BR pdftocairo (1),
+.BR pdftoppm (1),
+.BR pdftops (1),
+.BR pdftotext (1)
diff --git a/utils/pdftoppm.1 b/utils/pdftoppm.1
index 66b985c..e84c87d 100644
--- a/utils/pdftoppm.1
+++ b/utils/pdftoppm.1
@@ -142,8 +142,10 @@ Other error.
 The pdftoppm software and documentation are copyright 1996-2004 Glyph
 & Cog, LLC.
 .SH "SEE ALSO"
-.BR pdftops (1),
-.BR pdftotext (1),
-.BR pdfinfo (1),
 .BR pdffonts (1),
 .BR pdfimages (1),
+.BR pdfinfo (1),
+.BR pdftocairo (1),
+.BR pdftohtml (1),
+.BR pdftops (1),
+.BR pdftotext (1)
diff --git a/utils/pdftops.1 b/utils/pdftops.1
index 5a7543e..d508f13 100644
--- a/utils/pdftops.1
+++ b/utils/pdftops.1
@@ -217,8 +217,10 @@ Other error.
 The pdftops software and documentation are copyright 1996-2004 Glyph &
 Cog, LLC.
 .SH "SEE ALSO"
-.BR pdftotext (1),
-.BR pdfinfo (1),
 .BR pdffonts (1),
-.BR pdftoppm (1),
 .BR pdfimages (1),
+.BR pdfinfo (1),
+.BR pdftocairo (1),
+.BR pdftohtml (1),
+.BR pdftoppm (1),
+.BR pdftotext (1)
diff --git a/utils/pdftotext.1 b/utils/pdftotext.1
index eb3aa8e..164e618 100644
--- a/utils/pdftotext.1
+++ b/utils/pdftotext.1
@@ -122,9 +122,10 @@ Other error.
 .SH AUTHOR
 The pdftotext software and documentation are copyright 1996-2004 Glyph
 & Cog, LLC.
-.SH "SEE ALSO"
-.BR pdftops (1),
-.BR pdfinfo (1),
 .BR pdffonts (1),
-.BR pdftoppm (1),
 .BR pdfimages (1),
+.BR pdfinfo (1),
+.BR pdftocairo (1),
+.BR pdftohtml (1),
+.BR pdftoppm (1),
+.BR pdftops (1)
-- 
1.7.4.1

_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to