[poppler] [patch]fix cjk font display

Albert Astals Cid aacid at kde.org
Tue Jul 12 02:13:11 EST 2005


We are using that patch inside kpdf, i supose i sent the patch to the list but 
poppler is not using it. I'll make no comments about that fact.

Albert

A Dilluns 11 Juliol 2005 10:26, Alf va escriure:
> This patch is from xpdf-3.00, fixed display cjk fonts which not embedded in
> pdf file (need xpdf cjk language package).
>
> diff -Naur poppler-0.3.3.orig/poppler/CharCodeToUnicode.h
> poppler-0.3.3/poppler/CharCodeToUnicode.h ---
> poppler-0.3.3.orig/poppler/CharCodeToUnicode.h 2005-03-04
> 03:46:00.000000000 +0800 +++ poppler-0.3.3/poppler/CharCodeToUnicode.h
> 2005-07-06 20:23:08.000000000 +0800 @@ -66,6 +66,10 @@
>    // 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 -Naur poppler-0.3.3.orig/poppler/SplashOutputDev.cc
> poppler-0.3.3/poppler/SplashOutputDev.cc ---
> poppler-0.3.3.orig/poppler/SplashOutputDev.cc 2005-03-04 03:46:01.000000000
> +0800 +++ poppler-0.3.3/poppler/SplashOutputDev.cc 2005-07-06
> 20:12:12.000000000 +0800 @@ -502,7 +502,11 @@
>    double m11, m12, m21, m22, w1, w2;
>    SplashCoord mat[4];
>    char *name;
> -  int c, substIdx, n, code;
> +//  int c, substIdx, n, code;
> +  CharCodeToUnicode *ctu;
> +  Unicode uBuf[8];
> +  int c, substIdx, n, code, cmap;
> +  dfp = NULL;
>
>    needFontUpdate = gFalse;
>    font = NULL;
> @@ -546,7 +550,7 @@
>      } else if (!(fileName = gfxFont->getExtFontFile())) {
>
>        // look for a display font mapping or a substitute font
> -      dfp = NULL;
> +//      dfp = NULL;
>        if (gfxFont->isCIDFont()) {
>   if (((GfxCIDFont *)gfxFont)->getCollection()) {
>     dfp = globalParams->
> @@ -652,10 +656,54 @@
>        }
>        break;
>      case fontCIDType2:
> +/*
>        n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
>        codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort));
>        memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
>        n * sizeof(Gushort));
> +*/
> +      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 *)gmalloc(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 *)gmalloc(n * sizeof(Gushort));
> +   memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
> +   n * sizeof(Gushort));
> + }
> +      }
>        if (!(fontFile = fontEngine->loadTrueTypeFont(
>        id,
>        fileName->getCString(),

		
______________________________________________ 
Renovamos el Correo Yahoo! 
Nuevos servicios, más seguridad 
http://correo.yahoo.es


More information about the poppler mailing list