[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debian-devel:16137] Re: gpdf: 日本語/中国語の表示ができない (zh_CN, zh_TW, ja_JP)



On Mon, Sep 13, 2004 at 02:35:58PM +0900, Kenshi Muto wrote:
> 武藤@Debianぷろじぇくとです。
> 
> gpdfは内部的にはxpdfをそのまま使っているんですね。

コードを見るかぎりほとんどのファイルが一緒です。
でもGnome 関連のファイルなどが違います。

同じファイル名のファイルのdiffを添付します。

> At Mon, 13 Sep 2004 05:28:53 +0900,
> Osamu Aoki wrote:
> > このGPDFのCJK表示 BUG 1年以上ホッタラカシのようですが、
> > どなたかパッチご存知ですか?
> > 
> > GNOMEを選んだ際の標準PDFのブラウザーが動かないのは不便ですよね。
> 
> とりあえず自分のところではxpdf、xpdf-japaneseをインストールしてある状
> 態で、/etc/xpdf/xpdfrcを~/.xpdfrcにコピーしたら表示できました。
> (むつみさんのところではコピーしなくても表示された模様)

ぼくも最初はこれインストールしてあったんですが、今は無くても良いようなので
外しています。いまpurgeしたけど日本語うつりますよ。

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
pn  xpdf-japanese  <none>         (no description available)

> #ただいずれにせよ、Cmap問題のために「標準」(main)のDebianでは日本語の
> #gsやPDFは開けないですね…。

gs-epsをいれるとOKですよ。gs-gplならダメですが。

それに http://bugs.debian.org/271228
にあるように、gpdfはだめですが、gnome-gvは今は動いています。

(ただメンテナーの考えによりサポート落されても文句は言えないんですが)

ちなみに gv gnome-gv xpdf すべて動いています。

gs-espはメインあります。確かこれはPDFのGPLパッチを完全に当てたGPLの
最新版なので。

青木

diff -Nru xpdf-xpdf/Annot.cc gpdf-xpdf/Annot.cc
--- xpdf-xpdf/Annot.cc	2004-01-22 02:26:45.000000000 +0100
+++ gpdf-xpdf/Annot.cc	2004-05-17 20:03:01.000000000 +0200
@@ -21,15 +21,18 @@
 // Annot
 //------------------------------------------------------------------------
 
-Annot::Annot(XRef *xrefA, Dict *dict) {
+Annot::Annot(XRef *xrefA, Dict *dictA) {
   Object apObj, asObj, obj1, obj2;
   double t;
 
   ok = gFalse;
   xref = xrefA;
+  dict = dictA;
+  dict->incRef(); 
 
-  if (dict->lookup("AP", &apObj)->isDict()) {
-    if (dict->lookup("AS", &asObj)->isName()) {
+  dictA->lookup("Subtype", &subtype); 
+  if (dictA->lookup("AP", &apObj)->isDict()) {
+    if (dictA->lookup("AS", &asObj)->isName()) {
       if (apObj.dictLookup("N", &obj1)->isDict()) {
 	if (obj1.dictLookupNF(asObj.getName(), &obj2)->isRef()) {
 	  obj2.copy(&appearance);
@@ -49,7 +52,7 @@
   }
   apObj.free();
 
-  if (dict->lookup("Rect", &obj1)->isArray() &&
+  if (dictA->lookup("Rect", &obj1)->isArray() &&
       obj1.arrayGetLength() == 4) {
     //~ should check object types here
     obj1.arrayGet(0, &obj2);
diff -Nru xpdf-xpdf/Annot.h gpdf-xpdf/Annot.h
--- xpdf-xpdf/Annot.h	2004-01-22 02:26:45.000000000 +0100
+++ gpdf-xpdf/Annot.h	2004-01-12 20:32:08.000000000 +0100
@@ -34,9 +34,21 @@
   // Get appearance object.
   Object *getAppearance(Object *obj) { return appearance.fetch(xref, obj); }
 
+  // Get subtype object
+  Object *getSubtype(Object *obj) {return subtype.copy(obj); };
+
+  // Get dictionary
+  Dict *getDict() {return dict; };
+
+  // Get annot appearance ID
+  int getRefNum() {return appearance.getRefNum();};
+  int getRefGen() {return appearance.getRefGen();};
+  
 private:
 
   XRef *xref;			// the xref table for this PDF file
+  Dict *dict;
+  Object subtype;
   Object appearance;		// a reference to the Form XObject stream
 				//   for the normal appearance
   double xMin, yMin,		// annotation rectangle
diff -Nru xpdf-xpdf/CharCodeToUnicode.h gpdf-xpdf/CharCodeToUnicode.h
--- xpdf-xpdf/CharCodeToUnicode.h	2004-09-12 15:01:15.000000000 +0200
+++ gpdf-xpdf/CharCodeToUnicode.h	2004-05-17 20:03:01.000000000 +0200
@@ -67,10 +67,6 @@
   // Map a CharCode to Unicode.
   int mapToUnicode(CharCode c, Unicode *u, int size);
 
-  // Return the mapping's length, i.e., one more than the max char
-  // code supported by the mapping.
-  CharCode getLength() { return mapLen; }
-
 private:
 
   void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
diff -Nru xpdf-xpdf/Function.cc gpdf-xpdf/Function.cc
--- xpdf-xpdf/Function.cc	2004-01-22 02:26:45.000000000 +0100
+++ gpdf-xpdf/Function.cc	2004-05-17 20:03:02.000000000 +0200
@@ -12,6 +12,7 @@
 #pragma implementation
 #endif
 
+#include <locale.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
@@ -1071,7 +1072,11 @@
       resizeCode(*codePtr);
       if (isReal) {
 	code[*codePtr].type = psReal;
-	code[*codePtr].real = atof(tok->getCString());
+        {
+          char *theLocale = setlocale(LC_NUMERIC, "C");
+          code[*codePtr].real = atof(tok->getCString());
+          setlocale(LC_NUMERIC, theLocale);
+        }
       } else {
 	code[*codePtr].type = psInt;
 	code[*codePtr].intg = atoi(tok->getCString());
diff -Nru xpdf-xpdf/Gfx.h gpdf-xpdf/Gfx.h
--- xpdf-xpdf/Gfx.h	2004-01-22 02:26:45.000000000 +0100
+++ gpdf-xpdf/Gfx.h	2004-05-17 22:44:31.000000000 +0200
@@ -16,6 +16,7 @@
 #endif
 
 #include "gtypes.h"
+#include "Object.h"
 
 class GString;
 class XRef;
diff -Nru xpdf-xpdf/GfxState.cc gpdf-xpdf/GfxState.cc
--- xpdf-xpdf/GfxState.cc	2004-01-22 02:26:45.000000000 +0100
+++ gpdf-xpdf/GfxState.cc	2004-05-17 22:44:31.000000000 +0200
@@ -437,6 +437,12 @@
 void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
   double c, m, y, aw, ac, am, ay, ar, ag, ab;
 
+  /* FIXME ask Derek */
+  if (color->c[0] == 0.0 && color->c[1] == 0 && color->c[2] == 0) {
+    rgb->r = rgb->g = rgb->b = 1 - color->c[3];
+    return;
+  }
+    
   c = clip01(color->c[0] + color->c[3]);
   m = clip01(color->c[1] + color->c[3]);
   y = clip01(color->c[2] + color->c[3]);
diff -Nru xpdf-xpdf/Link.cc gpdf-xpdf/Link.cc
--- xpdf-xpdf/Link.cc	2004-01-22 02:26:45.000000000 +0100
+++ gpdf-xpdf/Link.cc	2004-05-17 20:03:02.000000000 +0200
@@ -42,8 +42,9 @@
   Object obj2, obj3, obj4;
 
   if (!obj->isDict()) {
-    error(-1, "Bad annotation action");
-    return NULL;
+      error(-1, "parseAction: Bad annotation action for URI '%s'",
+            baseURI ? baseURI->getCString() : "NULL");
+      return NULL;
   }
 
   obj->dictLookup("S", &obj2);
@@ -92,7 +93,8 @@
 
   // action is missing or wrong type
   } else {
-    error(-1, "Bad annotation action");
+    error(-1, "parseAction: Unknown annotation action object: URI = '%s'",
+          baseURI ? baseURI->getCString() : "NULL");
     action = NULL;
   }
 
@@ -827,7 +829,7 @@
   gfree(links);
 }
 
-LinkAction *Links::find(double x, double y) {
+LinkAction *Links::find(double x, double y) const {
   int i;
 
   for (i = numLinks - 1; i >= 0; --i) {
@@ -838,7 +840,7 @@
   return NULL;
 }
 
-GBool Links::onLink(double x, double y) {
+GBool Links::onLink(double x, double y) const {
   int i;
 
   for (i = 0; i < numLinks; ++i) {
diff -Nru xpdf-xpdf/Link.h gpdf-xpdf/Link.h
--- xpdf-xpdf/Link.h	2004-01-22 02:26:45.000000000 +0100
+++ gpdf-xpdf/Link.h	2004-05-17 20:03:02.000000000 +0200
@@ -390,15 +390,15 @@
   ~Links();
 
   // Iterate through list of links.
-  int getNumLinks() { return numLinks; }
-  Link *getLink(int i) { return links[i]; }
+  int getNumLinks() const { return numLinks; }
+  Link *getLink(int i) const { return links[i]; }
 
   // If point <x>,<y> is in a link, return the associated action;
   // else return NULL.
-  LinkAction *find(double x, double y);
+  LinkAction *find(double x, double y) const;
 
   // Return true if <x>,<y> is in a link.
-  GBool onLink(double x, double y);
+  GBool onLink(double x, double y) const;
 
 private:
 
diff -Nru xpdf-xpdf/Outline.cc gpdf-xpdf/Outline.cc
--- xpdf-xpdf/Outline.cc	2004-01-22 02:26:45.000000000 +0100
+++ gpdf-xpdf/Outline.cc	2004-05-17 22:44:31.000000000 +0200
@@ -44,7 +44,7 @@
 //------------------------------------------------------------------------
 
 OutlineItem::OutlineItem(Dict *dict, XRef *xrefA) {
-  Object obj1;
+  Object obj1, obj2;
   GString *s;
   int i;
 
@@ -78,10 +78,10 @@
   if (!dict->lookup("Dest", &obj1)->isNull()) {
     action = LinkAction::parseDest(&obj1);
   } else {
-    obj1.free();
-    if (dict->lookup("A", &obj1)) {
-      action = LinkAction::parseAction(&obj1);
-    }
+      obj1.free();
+      dict->lookup("A", &obj1);
+      if (!obj1.isNull())
+        action = LinkAction::parseAction(&obj1);
   }
   obj1.free();
 
diff -Nru xpdf-xpdf/OutputDev.h gpdf-xpdf/OutputDev.h
--- xpdf-xpdf/OutputDev.h	2004-01-22 02:26:45.000000000 +0100
+++ gpdf-xpdf/OutputDev.h	2004-05-17 22:44:31.000000000 +0200
@@ -19,6 +19,7 @@
 #include "CharTypes.h"
 
 class GString;
+class Object;
 class GfxState;
 class GfxColorSpace;
 class GfxImageColorMap;
diff -Nru xpdf-xpdf/PDFDoc.cc gpdf-xpdf/PDFDoc.cc
--- xpdf-xpdf/PDFDoc.cc	2004-01-22 02:26:45.000000000 +0100
+++ gpdf-xpdf/PDFDoc.cc	2004-05-17 22:44:31.000000000 +0200
@@ -12,6 +12,7 @@
 #pragma implementation
 #endif
 
+#include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>
@@ -192,7 +193,11 @@
   }
   str->moveStart(i);
   p = strtok(&hdrBuf[i+5], " \t\n\r");
-  pdfVersion = atof(p);
+  {
+    char *theLocale = setlocale(LC_NUMERIC, "C");
+    pdfVersion = atof(p);
+    setlocale(LC_NUMERIC, theLocale);
+  }
   if (!(hdrBuf[i+5] >= '0' && hdrBuf[i+5] <= '9') ||
       pdfVersion > supportedPDFVersionNum + 0.0001) {
     error(-1, "PDF version %s -- xpdf supports version %s"
@@ -203,7 +208,9 @@
 void PDFDoc::displayPage(OutputDev *out, int page, double hDPI, double vDPI,
 			 int rotate, GBool crop, GBool doLinks,
 			 GBool (*abortCheckCbk)(void *data),
-			 void *abortCheckCbkData) {
+			 void *abortCheckCbkData,
+                         GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data),
+                         void *annotDisplayDecideCbkData) {
   Page *p;
 
   if (globalParams->getPrintCommands()) {
@@ -213,13 +220,16 @@
   if (doLinks) {
     if (links) {
       delete links;
+      links = NULL;
     }
     getLinks(p);
     p->display(out, hDPI, vDPI, rotate, crop, links, catalog,
-	       abortCheckCbk, abortCheckCbkData);
+	       abortCheckCbk, abortCheckCbkData,
+               annotDisplayDecideCbk, annotDisplayDecideCbkData);
   } else {
     p->display(out, hDPI, vDPI, rotate, crop, NULL, catalog,
-	       abortCheckCbk, abortCheckCbkData);
+	       abortCheckCbk, abortCheckCbkData,
+               annotDisplayDecideCbk, annotDisplayDecideCbkData);
   }
 }
 
@@ -227,12 +237,15 @@
 			  double hDPI, double vDPI, int rotate,
 			  GBool crop, GBool doLinks,
 			  GBool (*abortCheckCbk)(void *data),
-			  void *abortCheckCbkData) {
+			  void *abortCheckCbkData,
+                          GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data),
+                          void *annotDisplayDecideCbkData) {
   int page;
 
   for (page = firstPage; page <= lastPage; ++page) {
     displayPage(out, page, hDPI, vDPI, rotate, crop, doLinks,
-		abortCheckCbk, abortCheckCbkData);
+		abortCheckCbk, abortCheckCbkData,
+                annotDisplayDecideCbk, annotDisplayDecideCbkData);
   }
 }
 
@@ -241,13 +254,17 @@
 			      int rotate, GBool crop,
 			      int sliceX, int sliceY, int sliceW, int sliceH,
 			      GBool (*abortCheckCbk)(void *data),
-			      void *abortCheckCbkData) {
+			      void *abortCheckCbkData,
+                              GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data),
+                              void *annotDisplayDecideCbkData) {
   Page *p;
 
   p = catalog->getPage(page);
   p->displaySlice(out, hDPI, vDPI, rotate, crop,
 		  sliceX, sliceY, sliceW, sliceH,
-		  NULL, catalog, abortCheckCbk, abortCheckCbkData);
+		  NULL, catalog,
+                  abortCheckCbk, abortCheckCbkData,
+                  annotDisplayDecideCbk, annotDisplayDecideCbkData);
 }
 
 GBool PDFDoc::isLinearized() {
diff -Nru xpdf-xpdf/PDFDoc.h gpdf-xpdf/PDFDoc.h
--- xpdf-xpdf/PDFDoc.h	2004-01-22 02:26:45.000000000 +0100
+++ gpdf-xpdf/PDFDoc.h	2004-05-17 22:44:31.000000000 +0200
@@ -20,6 +20,7 @@
 #include "Link.h"
 #include "Catalog.h"
 #include "Page.h"
+#include "Annot.h"
 
 class GString;
 class BaseStream;
@@ -82,14 +83,18 @@
   void displayPage(OutputDev *out, int page, double hDPI, double vDPI,
 		   int rotate, GBool crop, GBool doLinks,
 		   GBool (*abortCheckCbk)(void *data) = NULL,
-		   void *abortCheckCbkData = NULL);
+		   void *abortCheckCbkData = NULL,
+                   GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL,
+                   void *annotDisplayDecideCbkData = NULL);
 
   // Display a range of pages.
   void displayPages(OutputDev *out, int firstPage, int lastPage,
 		    double hDPI, double vDPI, int rotate,
 		    GBool crop, GBool doLinks,
 		    GBool (*abortCheckCbk)(void *data) = NULL,
-		    void *abortCheckCbkData = NULL);
+		    void *abortCheckCbkData = NULL,
+                    GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL,
+                    void *annotDisplayDecideCbkData = NULL);
 
   // Display part of a page.
   void displayPageSlice(OutputDev *out, int page,
@@ -97,7 +102,9 @@
 			int rotate, GBool crop,
 			int sliceX, int sliceY, int sliceW, int sliceH,
 			GBool (*abortCheckCbk)(void *data) = NULL,
-			void *abortCheckCbkData = NULL);
+			void *abortCheckCbkData = NULL,
+                        GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL,
+                        void *annotDisplayDecideCbkData = NULL);
 
   // Find a page, given its object ID.  Returns page number, or 0 if
   // not found.
@@ -147,7 +154,6 @@
   // Save this file with another name.
   GBool saveAs(GString *name);
 
-
 private:
 
   GBool setup(GString *ownerPassword, GString *userPassword);
@@ -165,7 +171,6 @@
   Outline *outline;
 #endif
 
-
   GBool ok;
   int errCode;
 };
diff -Nru xpdf-xpdf/Page.cc gpdf-xpdf/Page.cc
--- xpdf-xpdf/Page.cc	2004-01-22 02:26:45.000000000 +0100
+++ gpdf-xpdf/Page.cc	2004-05-17 22:44:31.000000000 +0200
@@ -203,6 +203,14 @@
     goto err1;
   }
 
+  // thumb
+  pageDict->lookupNF("Thumb", &thumb);
+  if (!(thumb.isStream() || thumb.isNull() || thumb.isRef())) {
+      error(-1, "Page thumb object (page %d) is wrong type (%s)",
+            num, thumb.getTypeName());
+      thumb.initNull(); 
+  }
+  
   return;
 
  err2:
@@ -222,9 +230,12 @@
 		   int rotate, GBool crop,
 		   Links *links, Catalog *catalog,
 		   GBool (*abortCheckCbk)(void *data),
-		   void *abortCheckCbkData) {
+		   void *abortCheckCbkData,
+                   GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data),
+                   void *annotDisplayDecideCbkData) {
   displaySlice(out, hDPI, vDPI, rotate, crop, -1, -1, -1, -1, links, catalog,
-	       abortCheckCbk, abortCheckCbkData);
+	       abortCheckCbk, abortCheckCbkData,
+               annotDisplayDecideCbk, annotDisplayDecideCbkData);
 }
 
 void Page::displaySlice(OutputDev *out, double hDPI, double vDPI,
@@ -232,7 +243,9 @@
 			int sliceX, int sliceY, int sliceW, int sliceH,
 			Links *links, Catalog *catalog,
 			GBool (*abortCheckCbk)(void *data),
-			void *abortCheckCbkData) {
+			void *abortCheckCbkData,
+                        GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data),
+                        void *annotDisplayDecideCbkData) {
 #ifndef PDF_PARSER_ONLY
   PDFRectangle *mediaBox, *cropBox;
   PDFRectangle box;
@@ -335,15 +348,21 @@
   // draw non-link annotations
   annotList = new Annots(xref, annots.fetch(xref, &obj));
   obj.free();
+#ifdef USE_ANNOTS_VIEW
   if (annotList->getNumAnnots() > 0) {
     if (globalParams->getPrintCommands()) {
       printf("***** Annotations\n");
     }
     for (i = 0; i < annotList->getNumAnnots(); ++i) {
-      annotList->getAnnot(i)->draw(gfx);
+        Annot *annot = annotList->getAnnot(i);
+        if ((annotDisplayDecideCbk &&
+             (*annotDisplayDecideCbk)(annot, annotDisplayDecideCbkData)) || 
+            !annotDisplayDecideCbk)
+          annot->draw(gfx); 
     }
     out->dump();
   }
+#endif
   delete annotList;
 
   delete gfx;
diff -Nru xpdf-xpdf/Page.h gpdf-xpdf/Page.h
--- xpdf-xpdf/Page.h	2004-01-22 02:26:45.000000000 +0100
+++ gpdf-xpdf/Page.h	2004-05-17 22:44:31.000000000 +0200
@@ -22,6 +22,8 @@
 class OutputDev;
 class Links;
 class Catalog;
+class Annots;
+class Annot;
 
 //------------------------------------------------------------------------
 
@@ -140,12 +142,17 @@
   // Get contents.
   Object *getContents(Object *obj) { return contents.fetch(xref, obj); }
 
+  // Get thumb.
+  Object *getThumb(Object *obj) { return thumb.fetch(xref, obj); }
+
   // Display a page.
   void display(OutputDev *out, double hDPI, double vDPI,
 	       int rotate, GBool crop,
 	       Links *links, Catalog *catalog,
 	       GBool (*abortCheckCbk)(void *data) = NULL,
-	       void *abortCheckCbkData = NULL);
+	       void *abortCheckCbkData = NULL,
+               GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL,
+               void *annotDisplayDecideCbkData = NULL);
 
   // Display part of a page.
   void displaySlice(OutputDev *out, double hDPI, double vDPI,
@@ -153,7 +160,9 @@
 		    int sliceX, int sliceY, int sliceW, int sliceH,
 		    Links *links, Catalog *catalog,
 		    GBool (*abortCheckCbk)(void *data) = NULL,
-		    void *abortCheckCbkData = NULL);
+		    void *abortCheckCbkData = NULL,
+                    GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL,
+                    void *annotDisplayDecideCbkData = NULL);
 
 private:
 
@@ -162,6 +171,7 @@
   PageAttrs *attrs;		// page attributes
   Object annots;		// annotations array
   Object contents;		// page contents
+  Object thumb;			// page thumbnail
   GBool ok;			// true if page is valid
 };