[poppler] poppler/poppler: CairoFontEngine.cc,1.19,1.20
Kristian Høgsberg
krh at freedesktop.org
Wed Dec 21 09:30:36 PST 2005
Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv26668/poppler
Modified Files:
CairoFontEngine.cc
Log Message:
2005-12-21 Kristian Høgsberg <krh at redhat.com>
* utils/Makefile.am: Add parseargs.h to sources and add
-I$(top_srcdir)/poppler to INCLUDES.
* poppler/CairoFontEngine.cc: Apply patch from Hiroyuki Ikezoe to
man non-embedded CJK fonts work.
Index: CairoFontEngine.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CairoFontEngine.cc,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- CairoFontEngine.cc 5 Dec 2005 20:46:22 -0000 1.19
+++ CairoFontEngine.cc 21 Dec 2005 17:30:33 -0000 1.20
@@ -12,6 +12,7 @@
#include "config.h"
#include <string.h>
#include "CairoFontEngine.h"
+#include "CharCodeToUnicode.h"
#include "GlobalParams.h"
#include <fofi/FoFiTrueType.h>
#include <fofi/FoFiType1C.h>
@@ -43,14 +44,17 @@
GooString *tmpFileName, *fileName, *substName,*tmpFileName2;
DisplayFontParam *dfp;
FILE *tmpFile;
- int c, i, n;
+ int c, i, n, code, cmap;
GfxFontType fontType;
char **enc;
char *name;
FoFiTrueType *ff;
FoFiType1C *ff1c;
+ CharCodeToUnicode *ctu;
+ Unicode uBuf[8];
static cairo_user_data_key_t cairo_font_face_key;
+ dfp = NULL;
codeToGID = NULL;
codeToGIDLen = 0;
cairo_font_face = NULL;
@@ -123,11 +127,49 @@
break;
case fontCIDType2:
- n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
+ codeToGID = NULL;
+ n = 0;
+ if (dfp) {
+ // create a CID-to-GID mapping, via Unicode
+ if ((ctu = ((GfxCIDFont *)gfxFont)->getToUnicode())) {
+ if ((ff = FoFiTrueType::load(fileName->getCString()))) {
+ // look for a Unicode cmap
+ for (cmap = 0; cmap < ff->getNumCmaps(); ++cmap) {
+ if ((ff->getCmapPlatform(cmap) == 3 &&
+ ff->getCmapEncoding(cmap) == 1) ||
+ ff->getCmapPlatform(cmap) == 0) {
+ break;
+ }
+ }
+ if (cmap < ff->getNumCmaps()) {
+ // map CID -> Unicode -> GID
+ n = ctu->getLength();
+ codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort));
+ for (code = 0; code < n; ++code) {
+ if (ctu->mapToUnicode(code, uBuf, 8) > 0) {
+ codeToGID[code] = ff->mapCodeToGID(cmap, uBuf[0]);
+ } else {
+ codeToGID[code] = 0;
+ }
+ }
+ }
+ delete ff;
+ }
+ ctu->decRefCnt();
+ } else {
+ error(-1, "Couldn't find a mapping to Unicode for font '%s'",
+ gfxFont->getName() ? gfxFont->getName()->getCString()
+ : "(unnamed)");
+ }
+ } else {
+ if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {
+ n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
+ codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort));
+ memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
+ n * sizeof(Gushort));
+ }
+ }
codeToGIDLen = n;
- codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort));
- memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
- n * sizeof(Gushort));
/* Fall through */
case fontTrueType:
if (!(ff = FoFiTrueType::load(fileName->getCString()))) {
More information about the poppler
mailing list