Commit 91959bf24c3ecf9c46cec9916e787e5e3457fafd

Werner Lemberg 2006-11-22T10:36:55

Fix Savannah bug #15553. * src/truetype/ttgload.c (tt_loader_init): Re-execute the CVT program after a change from mono to grayscaling (and vice versa). Use correct constant for comparison to get `exec->grayscale'.

diff --git a/ChangeLog b/ChangeLog
index 37be0cb..17b8329 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-11-22  Werner Lemberg  <wl@gnu.org>
+
+	Fix Savannah bug #15553.
+
+	* src/truetype/ttgload.c (tt_loader_init): Re-execute the CVT
+	program after a change from mono to grayscaling (and vice versa).
+	Use correct constant for comparison to get `exec->grayscale'.
+
 2006-11-18  Werner Lemberg  <wl@gnu.org>
 
 	Because FT_Load_Glyph expects CID values for CID-keyed fonts, the
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 3d901ac..13b6577 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1720,6 +1720,7 @@
     /* load execution context */
     {
       TT_ExecContext  exec;
+      FT_Bool         grayscale;
 
 
       /* query new execution context */
@@ -1728,8 +1729,25 @@
       if ( !exec )
         return TT_Err_Could_Not_Find_Context;
 
+      grayscale =
+        FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != FT_RENDER_MODE_MONO );
+
       TT_Load_Context( exec, face, size );
 
+      /* a change from mono to grayscale rendering (and vice versa) */
+      /* requires a re-execution of the CVT program                 */
+      if ( grayscale != exec->grayscale )
+      {
+        FT_UInt  i;
+
+
+        exec->grayscale = grayscale;
+
+        for ( i = 0; i < size->cvt_size; i++ )
+          size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
+        tt_size_run_prep( size );
+      }
+
       /* see if the cvt program has disabled hinting */
       if ( exec->GS.instruct_control & 1 )
         load_flags |= FT_LOAD_NO_HINTING;
@@ -1739,9 +1757,6 @@
         exec->GS = tt_default_graphics_state;
 
       exec->pedantic_hinting = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
-      exec->grayscale =
-        FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != FT_LOAD_TARGET_MONO );
-
       loader->exec = exec;
       loader->instructions = exec->glyphIns;
     }