[sushi] font-widget: always pick an alphabet size for fixed size fonts



commit 58a5797250185b9f634b7c78fe9c9383f2906501
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue May 1 12:14:34 2012 -0400

    font-widget: always pick an alphabet size for fixed size fonts
    
    Pick the nearest to 24 among the available sizes. This fixes a rendering
    error with certain fixed size fonts.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=675241

 src/libsushi/sushi-font-widget.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/libsushi/sushi-font-widget.c b/src/libsushi/sushi-font-widget.c
index 7b7ce39..1c6440a 100644
--- a/src/libsushi/sushi-font-widget.c
+++ b/src/libsushi/sushi-font-widget.c
@@ -247,8 +247,11 @@ build_sizes_table (FT_Face face,
     sizes[11] = 168;
     sizes[12] = 192;
     sizes[13] = 216;
+
     *alpha_size = 24;
   } else {
+    gint diff = G_MAXINT;
+
     /* use fixed sizes */
     *n_sizes = face->num_fixed_sizes;
     sizes = g_new (gint, *n_sizes);
@@ -257,9 +260,10 @@ build_sizes_table (FT_Face face,
     for (i = 0; i < face->num_fixed_sizes; i++) {
       sizes[i] = face->available_sizes[i].height;
 
-      /* work out which font size to render */
-      if (face->available_sizes[i].height <= 24)
-        *alpha_size = face->available_sizes[i].height;
+      if ((gint) (abs (sizes[i] - 24)) < diff) {
+        diff = (gint) abs (sizes[i] - 24);
+        *alpha_size = sizes[i];
+      }
     }
   }
 



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