[gnome-font-viewer] Don’t select non-Unicode font c harmaps



commit d11b6ae9f8e1a62fe366e349793a38e7040aefb5
Author: Khaled Hosny <khaledhosny eglug org>
Date:   Wed Sep 18 00:50:35 2013 +0200

    Don’t select non-Unicode font charmaps
    
    If the font does not contains all characters checked for, it may end up
    with a non-Unicode charmap selected, since the code in
    check_font_contain_text() never resets the original charmap. This will
    break text layout with HarfBuzz and will give us empty boxes.
    
    I fail to see the logic behind this code, we are only interested in the
    Unicode charmap, since the others are pretty useless for us, especially
    when there is a Unicode charmap in the font. So just let
    FT_Select_Charmap() find the best Unicode charmap in the font for us.

 src/sushi-font-widget.c |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)
---
diff --git a/src/sushi-font-widget.c b/src/sushi-font-widget.c
index 9faa10a..e21367b 100644
--- a/src/sushi-font-widget.c
+++ b/src/sushi-font-widget.c
@@ -232,27 +232,19 @@ check_font_contain_text (FT_Face face,
   gunichar *string;
   glong len, idx, map;
   FT_CharMap charmap;
-  gboolean retval = FALSE;
+  gboolean retval = TRUE;
 
   string = g_utf8_to_ucs4_fast (text, -1, &len);
 
-  for (map = 0; map < face->num_charmaps; map++) {
-    charmap = face->charmaps[map];
-    FT_Set_Charmap (face, charmap);
-
-    retval = TRUE;
+  FT_Select_Charmap (face, FT_ENCODING_UNICODE);
 
-    for (idx = 0; idx < len; idx++) {
-      gunichar c = string[idx];
+  for (idx = 0; idx < len; idx++) {
+    gunichar c = string[idx];
 
-      if (!FT_Get_Char_Index (face, c)) {
-        retval = FALSE;
-        break;
-      }
-    }
-
-    if (retval)
+    if (!FT_Get_Char_Index (face, c)) {
+      retval = FALSE;
       break;
+    }
   }
 
   g_free (string);


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