shithub: freetype+ttf2subf

Download patch

ref: 18931a5a5dacf1a0bb2c54eed2bf4c607245f893
parent: f1a981b5ce4f06c772bb2f62f3ce4c54a0c2c6d0
author: Werner Lemberg <[email protected]>
date: Tue Feb 1 02:08:43 EST 2011

[truetype] FT_LOAD_PEDANTIC now affects `prep' and `fpgm' also.

* src/truetype/ttgload.c (tt_loader_init): Handle
`FT_LOAD_PEDANTIC'.
* src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep,
tt_size_init_bytecode, tt_size_ready_bytecode): New argument to
handle pedantic mode.
* src/truetype/ttobjs.h: Updated.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-02-01  Werner Lemberg  <[email protected]>
+
+	[truetype] FT_LOAD_PEDANTIC now affects `prep' and `fpgm' also.
+
+	* src/truetype/ttgload.c (tt_loader_init): Handle
+	`FT_LOAD_PEDANTIC'.
+	* src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep,
+	tt_size_init_bytecode, tt_size_ready_bytecode): New argument to
+	handle pedantic mode.
+	* src/truetype/ttobjs.h: Updated.
+
 2011-01-31  Werner Lemberg  <[email protected]>
 
 	[truetype] Protect jump instructions against endless loops.
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1868,6 +1868,7 @@
   {
     TT_Face    face;
     FT_Stream  stream;
+    FT_Bool    pedantic = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
 
 
     face   = (TT_Face)glyph->face;
@@ -1886,7 +1887,7 @@
 
       if ( !size->cvt_ready )
       {
-        FT_Error  error = tt_size_ready_bytecode( size );
+        FT_Error  error = tt_size_ready_bytecode( size, pedantic );
 
 
         if ( error )
@@ -1918,7 +1919,7 @@
 
         for ( i = 0; i < size->cvt_size; i++ )
           size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
-        tt_size_run_prep( size );
+        tt_size_run_prep( size, pedantic );
       }
 
       /* see whether the cvt program has disabled hinting */
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -4,8 +4,7 @@
 /*                                                                         */
 /*    Objects manager (body).                                              */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,   */
-/*            2010 by                                                      */
+/*  Copyright 1996-2011                                                    */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -570,13 +569,16 @@
   /*    Run the font program.                                              */
   /*                                                                       */
   /* <Input>                                                               */
-  /*    size :: A handle to the size object.                               */
+  /*    size     :: A handle to the size object.                           */
   /*                                                                       */
+  /*    pedantic :: Set if bytecode execution should be pedantic.          */
+  /*                                                                       */
   /* <Return>                                                              */
   /*    FreeType error code.  0 means success.                             */
   /*                                                                       */
   FT_LOCAL_DEF( FT_Error )
-  tt_size_run_fpgm( TT_Size  size )
+  tt_size_run_fpgm( TT_Size  size,
+                    FT_Bool  pedantic )
   {
     TT_Face         face = (TT_Face)size->root.face;
     TT_ExecContext  exec;
@@ -594,8 +596,8 @@
 
     TT_Load_Context( exec, face, size );
 
-    exec->callTop   = 0;
-    exec->top       = 0;
+    exec->callTop = 0;
+    exec->top     = 0;
 
     exec->period    = 64;
     exec->phase     = 0;
@@ -602,8 +604,10 @@
     exec->threshold = 0;
 
     exec->instruction_trap = FALSE;
-    exec->F_dot_P = 0x10000L;
+    exec->F_dot_P          = 0x10000L;
 
+    exec->pedantic_hinting = pedantic;
+
     {
       FT_Size_Metrics*  metrics    = &exec->metrics;
       TT_Size_Metrics*  tt_metrics = &exec->tt_metrics;
@@ -659,13 +663,16 @@
   /*    Run the control value program.                                     */
   /*                                                                       */
   /* <Input>                                                               */
-  /*    size :: A handle to the size object.                               */
+  /*    size     :: A handle to the size object.                           */
   /*                                                                       */
+  /*    pedantic :: Set if bytecode execution should be pedantic.          */
+  /*                                                                       */
   /* <Return>                                                              */
   /*    FreeType error code.  0 means success.                             */
   /*                                                                       */
   FT_LOCAL_DEF( FT_Error )
-  tt_size_run_prep( TT_Size  size )
+  tt_size_run_prep( TT_Size  size,
+                    FT_Bool  pedantic )
   {
     TT_Face         face = (TT_Face)size->root.face;
     TT_ExecContext  exec;
@@ -688,6 +695,8 @@
 
     exec->instruction_trap = FALSE;
 
+    exec->pedantic_hinting = pedantic;
+
     TT_Set_CodeRange( exec,
                       tt_coderange_cvt,
                       face->cvt_program,
@@ -766,7 +775,8 @@
   /* Initialize bytecode-related fields in the size object.       */
   /* We do this only if bytecode interpretation is really needed. */
   static FT_Error
-  tt_size_init_bytecode( FT_Size  ftsize )
+  tt_size_init_bytecode( FT_Size  ftsize,
+                         FT_Bool  pedantic )
   {
     FT_Error   error;
     TT_Size    size = (TT_Size)ftsize;
@@ -839,7 +849,7 @@
     }
 
     /* Fine, now run the font program! */
-    error = tt_size_run_fpgm( size );
+    error = tt_size_run_fpgm( size, pedantic );
 
   Exit:
     if ( error )
@@ -850,7 +860,8 @@
 
 
   FT_LOCAL_DEF( FT_Error )
-  tt_size_ready_bytecode( TT_Size  size )
+  tt_size_ready_bytecode( TT_Size  size,
+                          FT_Bool  pedantic )
   {
     FT_Error  error = TT_Err_Ok;
 
@@ -857,7 +868,7 @@
 
     if ( !size->bytecode_ready )
     {
-      error = tt_size_init_bytecode( (FT_Size)size );
+      error = tt_size_init_bytecode( (FT_Size)size, pedantic );
       if ( error )
         goto Exit;
     }
@@ -889,7 +900,7 @@
 
       size->GS = tt_default_graphics_state;
 
-      error = tt_size_run_prep( size );
+      error = tt_size_run_prep( size, pedantic );
       if ( !error )
         size->cvt_ready = 1;
     }
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Objects manager (specification).                                     */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/*  Copyright 1996-2009, 2011 by                                           */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -390,13 +390,16 @@
 #ifdef TT_USE_BYTECODE_INTERPRETER
 
   FT_LOCAL( FT_Error )
-  tt_size_run_fpgm( TT_Size  size );
+  tt_size_run_fpgm( TT_Size  size,
+                    FT_Bool  pedantic );
 
   FT_LOCAL( FT_Error )
-  tt_size_run_prep( TT_Size  size );
+  tt_size_run_prep( TT_Size  size,
+                    FT_Bool  pedantic );
 
   FT_LOCAL( FT_Error )
-  tt_size_ready_bytecode( TT_Size  size );
+  tt_size_ready_bytecode( TT_Size  size,
+                          FT_Bool  pedantic );
 
 #endif /* TT_USE_BYTECODE_INTERPRETER */