[poppler] 4 commits - CMakeLists.txt poppler/CairoOutputDev.cc poppler/GlobalParams.cc poppler/Makefile.am poppler/UTF8.h poppler/UTF.cc poppler/UTF.h

Albert Astals Cid aacid at kemper.freedesktop.org
Sun Oct 14 14:06:47 PDT 2012


 CMakeLists.txt            |    1 
 poppler/CairoOutputDev.cc |    8 ++--
 poppler/GlobalParams.cc   |    2 -
 poppler/Makefile.am       |    1 
 poppler/UTF.cc            |    3 +
 poppler/UTF.h             |   79 -------------------------------------------
 poppler/UTF8.h            |   84 ++++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 95 insertions(+), 83 deletions(-)

New commits:
commit 0a5bda01ace9f8576d687c5a28feb5cf09b48a92
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun Oct 14 23:05:27 2012 +0200

    New/old header for cmake buildsystem

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 459846a..8836ae4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -469,6 +469,7 @@ if(ENABLE_XPDF_HEADERS)
     poppler/StdinCachedFile.h
     poppler/StdinPDFDocBuilder.h
     poppler/UTF.h
+    poppler/UTF8.h
     poppler/XpdfPluginAPI.h
     poppler/Sound.h
     ${CMAKE_CURRENT_BINARY_DIR}/poppler/poppler-config.h
commit 6d46f0b477143eb0df09f718e96dd2ff2a7dd61b
Author: Hib Eris <hib at hiberis.nl>
Date:   Sat Sep 22 20:50:07 2012 +0200

    Split our UTF.h into xpdf based UTF8.h and a poppler specific UTF.h

diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 148a0dd..098e4a4 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -108,7 +108,7 @@
 
 #include "NameToUnicodeTable.h"
 #include "UnicodeMapTables.h"
-#include "UTF.h"
+#include "UTF8.h"
 
 #ifdef ENABLE_PLUGINS
 #  ifdef _WIN32
diff --git a/poppler/Makefile.am b/poppler/Makefile.am
index 3a5f4ca..e10d19d 100644
--- a/poppler/Makefile.am
+++ b/poppler/Makefile.am
@@ -252,6 +252,7 @@ poppler_include_HEADERS =	\
 	TextOutputDev.h		\
 	SecurityHandler.h	\
 	UTF.h			\
+	UTF8.h			\
 	XpdfPluginAPI.h		\
 	Sound.h
 nodist_poppler_include_HEADERS = poppler-config.h
diff --git a/poppler/UTF.h b/poppler/UTF.h
index 079b3a2..1111c37 100644
--- a/poppler/UTF.h
+++ b/poppler/UTF.h
@@ -2,23 +2,10 @@
 //
 // UTF.h
 //
-// Copyright 2001-2003 Glyph & Cog, LLC
+// This file is licensed under the GPLv2 or later
 //
-//========================================================================
-
-//========================================================================
-//
-// Modified under the Poppler project - http://poppler.freedesktop.org
-//
-// All changes made under the Poppler project to this file are licensed
-// under GPL version 2 or later
-//
-// Copyright (C) 2008 Koji Otani <sho at bbr.jp>
 // Copyright (C) 2012 Adrian Johnson <ajohnson at redneon.com>
 //
-// To see a description of the changes please see the Changelog file that
-// came with your tarball or type make ChangeLog if you are building from git
-//
 //========================================================================
 
 #ifndef UTF_H
@@ -45,68 +32,4 @@ int UTF16toUCS4(const Unicode *utf16, int utf16_len, Unicode **ucs4_out);
 //   returns number of UCS-4 characters
 int TextStringToUCS4(GooString *textStr, Unicode **ucs4);
 
-
-static int mapUTF8(Unicode u, char *buf, int bufSize) {
-  if        (u <= 0x0000007f) {
-    if (bufSize < 1) {
-      return 0;
-    }
-    buf[0] = (char)u;
-    return 1;
-  } else if (u <= 0x000007ff) {
-    if (bufSize < 2) {
-      return 0;
-    }
-    buf[0] = (char)(0xc0 + (u >> 6));
-    buf[1] = (char)(0x80 + (u & 0x3f));
-    return 2;
-  } else if (u <= 0x0000ffff) {
-    if (bufSize < 3) {
-      return 0;
-    }
-    buf[0] = (char)(0xe0 + (u >> 12));
-    buf[1] = (char)(0x80 + ((u >> 6) & 0x3f));
-    buf[2] = (char)(0x80 + (u & 0x3f));
-    return 3;
-  } else if (u <= 0x0010ffff) {
-    if (bufSize < 4) {
-      return 0;
-    }
-    buf[0] = (char)(0xf0 + (u >> 18));
-    buf[1] = (char)(0x80 + ((u >> 12) & 0x3f));
-    buf[2] = (char)(0x80 + ((u >> 6) & 0x3f));
-    buf[3] = (char)(0x80 + (u & 0x3f));
-    return 4;
-  } else {
-    return 0;
-  }
-}
-
-static int mapUCS2(Unicode u, char *buf, int bufSize) {
-  if (u <= 0xffff) {
-    if (bufSize < 2) {
-      return 0;
-     }
-    buf[0] = (char)((u >> 8) & 0xff);
-    buf[1] = (char)(u & 0xff);
-    return 2;
-  } else if (u < 0x110000) {
-    Unicode uu;
-
-    /* using surrogate pair */
-    if (bufSize < 4) {
-      return 0;
-    }
-    uu = ((u - 0x10000) >> 10) + 0xd800;
-    buf[0] = (char)((uu >> 8) & 0xff);
-    buf[1] = (char)(uu & 0xff);
-    uu = (u & 0x3ff)+0xdc00;
-    buf[2] = (char)((uu >> 8) & 0xff);
-    buf[3] = (char)(uu & 0xff);
-    return 4;
-  } else {
-    return 0;
-  }
-}
-
 #endif
diff --git a/poppler/UTF8.h b/poppler/UTF8.h
new file mode 100644
index 0000000..34a07d4
--- /dev/null
+++ b/poppler/UTF8.h
@@ -0,0 +1,84 @@
+//========================================================================
+//
+// UTF8.h
+//
+// Copyright 2001-2003 Glyph & Cog, LLC
+//
+//========================================================================
+
+//========================================================================
+//
+// Modified under the Poppler project - http://poppler.freedesktop.org
+//
+// All changes made under the Poppler project to this file are licensed
+// under GPL version 2 or later
+//
+// Copyright (C) 2008 Koji Otani <sho at bbr.jp>
+//
+// To see a description of the changes please see the Changelog file that
+// came with your tarball or type make ChangeLog if you are building from git
+//
+//========================================================================
+
+static int mapUTF8(Unicode u, char *buf, int bufSize) {
+  if        (u <= 0x0000007f) {
+    if (bufSize < 1) {
+      return 0;
+    }
+    buf[0] = (char)u;
+    return 1;
+  } else if (u <= 0x000007ff) {
+    if (bufSize < 2) {
+      return 0;
+    }
+    buf[0] = (char)(0xc0 + (u >> 6));
+    buf[1] = (char)(0x80 + (u & 0x3f));
+    return 2;
+  } else if (u <= 0x0000ffff) {
+    if (bufSize < 3) {
+      return 0;
+    }
+    buf[0] = (char)(0xe0 + (u >> 12));
+    buf[1] = (char)(0x80 + ((u >> 6) & 0x3f));
+    buf[2] = (char)(0x80 + (u & 0x3f));
+    return 3;
+  } else if (u <= 0x0010ffff) {
+    if (bufSize < 4) {
+      return 0;
+    }
+    buf[0] = (char)(0xf0 + (u >> 18));
+    buf[1] = (char)(0x80 + ((u >> 12) & 0x3f));
+    buf[2] = (char)(0x80 + ((u >> 6) & 0x3f));
+    buf[3] = (char)(0x80 + (u & 0x3f));
+    return 4;
+  } else {
+    return 0;
+  }
+}
+
+static int mapUCS2(Unicode u, char *buf, int bufSize) {
+  if (u <= 0xffff) {
+    if (bufSize < 2) {
+      return 0;
+    }
+    buf[0] = (char)((u >> 8) & 0xff);
+    buf[1] = (char)(u & 0xff);
+    return 2;
+  } else if (u < 0x110000) {
+    Unicode uu;
+
+    /* using surrogate pair */
+    if (bufSize < 4) {
+      return 0;
+    }
+    uu = ((u - 0x10000) >> 10) + 0xd800;
+    buf[0] = (char)((uu >> 8) & 0xff);
+    buf[1] = (char)(uu & 0xff);
+    uu = (u & 0x3ff)+0xdc00;
+    buf[2] = (char)((uu >> 8) & 0xff);
+    buf[3] = (char)(uu & 0xff);
+    return 4;
+  } else {
+    return 0;
+  }
+}
commit 03cbba935c90ce9a6d9ad44f7cda4901c2f81f2e
Author: Hib Eris <hib at hiberis.nl>
Date:   Sat Sep 22 19:58:40 2012 +0200

    Do not use mapUTF8() directly in CairoOutputDev

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index d8f78d7..bab4562 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -23,7 +23,7 @@
 // Copyright (C) 2008-2012 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2008 Michael Vrable <mvrable at cs.ucsd.edu>
 // Copyright (C) 2008, 2009 Chris Wilson <chris at chris-wilson.co.uk>
-// Copyright (C) 2008 Hib Eris <hib at hiberis.nl>
+// Copyright (C) 2008, 2012 Hib Eris <hib at hiberis.nl>
 // Copyright (C) 2009, 2010 David Benjamin <davidben at mit.edu>
 // Copyright (C) 2011, 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2012 Patrick Pfeifer <p2000 at mailinator.com>
@@ -61,7 +61,7 @@
 #include "CairoOutputDev.h"
 #include "CairoFontEngine.h"
 #include "CairoRescaleBox.h"
-#include "UTF.h"
+#include "UnicodeMap.h"
 //------------------------------------------------------------------------
 
 // #define LOG_CAIRO
@@ -1169,6 +1169,8 @@ void CairoOutputDev::drawChar(GfxState *state, double x, double y,
     glyphs[glyphCount].y = y - originY;
     glyphCount++;
     if (use_show_text_glyphs) {
+      GooString enc("UTF-8");
+      UnicodeMap *utf8Map = globalParams->getUnicodeMap(&enc);
       if (utf8Max - utf8Count < uLen*6) {
         // utf8 encoded characters can be up to 6 bytes
 	if (utf8Max > uLen*6)
@@ -1179,7 +1181,7 @@ void CairoOutputDev::drawChar(GfxState *state, double x, double y,
       }
       clusters[clusterCount].num_bytes = 0;
       for (int i = 0; i < uLen; i++) {
-	int size = mapUTF8 (u[i], utf8 + utf8Count, utf8Max - utf8Count);
+	int size = utf8Map->mapUnicode(u[i], utf8 + utf8Count, utf8Max - utf8Count);
 	utf8Count += size;
 	clusters[clusterCount].num_bytes += size;
       }
commit f219bdbcadcb0334d595bbd9afd01f00c37d1978
Author: Hib Eris <hib at hiberis.nl>
Date:   Sun Oct 14 22:59:55 2012 +0200

    Make sure array index is >= 0
    
    Fixes this warning on array subscript type:
    UTF.cc: In function 'int TextStringToUCS4(GooString*, Unicode**)':
    UTF.cc:99:33: warning: array subscript has type 'char' [-Wchar-subscripts]

diff --git a/poppler/UTF.cc b/poppler/UTF.cc
index 8e9cb9d..675ac68 100644
--- a/poppler/UTF.cc
+++ b/poppler/UTF.cc
@@ -15,6 +15,7 @@
 //
 // Copyright (C) 2008 Koji Otani <sho at bbr.jp>
 // Copyright (C) 2012 Adrian Johnson <ajohnson at redneon.com>
+// Copyright (C) 2012 Hib Eris <hib at hiberis.nl>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -96,7 +97,7 @@ int TextStringToUCS4(GooString *textStr, Unicode **ucs4)
   } else {
     u = (Unicode*)gmallocn(len, sizeof(Unicode));
     for (i = 0 ; i < len; i++) {
-      u[i] = pdfDocEncoding[s[i]];
+      u[i] = pdfDocEncoding[s[i] & 0xff];
     }
   }
   *ucs4 = u;


More information about the poppler mailing list