]> www.fi.muni.cz Git - evince.git/blobdiff - pdf/xpdf/FTFont.cc
Import of Xpdf 2.00 for merge
[evince.git] / pdf / xpdf / FTFont.cc
index 0524c7edc135c4d057bc3e0e9e846572420334cf..8de09e0e61046f3cbe482c375b6ce8b7c6047143 100644 (file)
@@ -6,14 +6,14 @@
 //
 //========================================================================
 
-#ifdef __GNUC__
-#pragma implementation
-#endif
-
 #include <aconf.h>
 
 #if FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
 
+#ifdef USE_GCC_PRAGMAS
+#pragma implementation
+#endif
+
 #include <math.h>
 #include <string.h>
 #include "gmem.h"
@@ -261,15 +261,11 @@ FTFont::FTFont(FTFontFile *fontFileA, double *m) {
     yMax = (int)(1.2 * size);
   }
   // this should be (max - min + 1), but we add some padding to
-  // deal with rounding errors
+  // deal with rounding errors, bogus bboxes, etc.
   glyphW = xMax - xMin + 3;
+  glyphW += glyphW >> 1;
   glyphH = yMax - yMin + 3;
-  // another kludge: some CJK TT fonts have bogus bboxes, so add more
-  // padding
-  if (face->num_glyphs > 1000) {
-    glyphW += glyphW >> 1;
-    glyphH += glyphH >> 1;
-  }
+  glyphH += glyphH >> 1;
   if (engine->aa) {
     glyphSize = glyphW * glyphH;
   } else {
@@ -444,9 +440,9 @@ Guchar *FTFont::getGlyphPixmap(CharCode c, Unicode u,
                               int *x, int *y, int *w, int *h) {
   FT_GlyphSlot slot;
   FT_UInt idx;
-  int gSize;
+  int rowSize;
   int i, j, k;
-  Guchar *ret;
+  Guchar *ret, *p, *q;
 
   // check the cache
   i = (c & (cacheSets - 1)) * cacheAssoc;
@@ -516,12 +512,16 @@ Guchar *FTFont::getGlyphPixmap(CharCode c, Unicode u,
       cacheTags[i+j].w = *w;
       cacheTags[i+j].h = *h;
       if (fontFile->engine->aa) {
-       gSize = *w * *h;
+       rowSize = *w;
       } else {
-       gSize = ((*w + 7) >> 3) * *h;
+       rowSize = (*w + 7) >> 3;
       }
       ret = cache + (i+j) * glyphSize;
-      memcpy(ret, slot->bitmap.buffer, gSize);
+      for (k = 0, p = ret, q = slot->bitmap.buffer;
+          k < slot->bitmap.rows;
+          ++k, p += rowSize, q += slot->bitmap.pitch) {
+       memcpy(p, q, rowSize);
+      }
     } else {
       ++cacheTags[i+j].mru;
     }