[poppler] [Patch] Fix bug 15301 for Chinese font

JustFillBug mozbugbox at yahoo.com.au
Mon Dec 1 01:36:05 PST 2008


https://bugs.freedesktop.org/show_bug.cgi?id=15301

Attached patch fixed bug 15301 for specific CJK Fonts.


--- CairoFontEngine.cc.orig	2008-12-01 17:26:16.000000000 +0800
+++ CairoFontEngine.cc	2008-12-01 17:26:21.000000000 +0800
@@ -220,9 +220,37 @@
     delete tmpFileName;
   }
 
-  cairo_font_face = cairo_ft_font_face_create_for_ft_face (face,
-							   FT_LOAD_NO_HINTING |
-							   FT_LOAD_NO_BITMAP);
+  {
+    // Find out tricky fonts which need HINTING to render properly.
+    // See freetype src/truetype/ttobjs.c: tt_face_init()
+    static const char* const  trick_names[] =
+    {
+      "DFKaiSho-SB",     /* dfkaisb.ttf */
+      "DFKai-SB",        /* kaiu.ttf */
+      "HuaTianSongTi?",  /* htst3.ttf */
+      "MingLiU",         /* mingliu.ttf & mingliu.ttc */
+      "PMingLiU",        /* mingliu.ttc */
+      "MingLi43",        /* mingli.ttf */
+      NULL
+    };
+    int load_flag = FT_LOAD_NO_BITMAP;
+    GBool tricky = gFalse;
+    int nn;
+
+    for (nn = 0; trick_names[nn] != NULL; nn++ )
+    {
+      if (face->family_name && strstr(face->family_name, trick_names[nn] ) )
+      {
+	tricky = gTrue;
+	break;
+      }
+    }
+    if (!tricky)
+      load_flag |= FT_LOAD_NO_HINTING;
+
+    cairo_font_face = cairo_ft_font_face_create_for_ft_face (face, load_flag);
+  }
+
   if (cairo_font_face_status (cairo_font_face)) {
     error(-1, "could not create cairo font: %s\n", cairo_status_to_string (cairo_font_face_status (cairo_font_face)));
     goto err2; /* this doesn't do anything, but it looks like we're






More information about the poppler mailing list