shithub: freetype+ttf2subf

Download patch

ref: c56216283418771f42842efa72a334f2fc762e63
parent: 7b33dca43c88cf3b1194455145bc70144feaca6c
author: David Turner <[email protected]>
date: Thu Jun 30 07:46:46 EDT 2005

* src/sfnt/ftbitmap.c, src/truetype/ttgload.c, src/sfnt/ttcmap.c:
        removing compiler warnings (Visual C++ /W4)

        * Jamfile, src/otvalid/{otvcommn.h,otvgdef.c,otvgpos.c,otvgsub.c,
        otvjstf.c}: modified the code to use a different pre-processor trick
        to implement the OTV_NEST1, OTV_NEST2 and OTV_NEST3 macros. The code
        now compiles neatly with Visual C++. The 'otvalid' module has been
        put in the Jamfile build again.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-06-30  David Turner  <[email protected]>
+
+        * src/sfnt/ftbitmap.c, src/truetype/ttgload.c, src/sfnt/ttcmap.c:
+        removing compiler warnings (Visual C++ /W4)
+
+        * Jamfile, src/otvalid/{otvcommn.h,otvgdef.c,otvgpos.c,otvgsub.c,
+        otvjstf.c}: modified the code to use a different pre-processor trick
+        to implement the OTV_NEST1, OTV_NEST2 and OTV_NEST3 macros. The code
+        now compiles neatly with Visual C++. The 'otvalid' module has been
+        put in the Jamfile build again.
+
 2005-06-20  Chia I Wu  <[email protected]>
 
 	* include/freetype/internal/ftobjs.h, src/base/ftobjs.c: New function
@@ -5,7 +16,7 @@
 
 	* src/truetype/ttgload.c (compute_glyph_metrics): Use
 	ft_glyphslot_grid_fit_metrics.
-	
+
 	* src/cff/cffgload.c (cff_slot_load), src/cid/cidgload.c
 	(cid_slot_load_glyph), src/type1/t1gload.c (T1_Load_Glyph): Use
 	ft_glyphslot_grid_fit_metrics.
--- a/Jamfile
+++ b/Jamfile
@@ -78,7 +78,7 @@
                   cid        # PostScript CID-keyed font driver
                   gzip       # support for gzip-compressed files
                   lzw        # support for LZW-compressed files
-                  #otvalid    # validation of OpenType tables
+                  otvalid    # validation of OpenType tables
                   pcf        # PCF font driver
                   pfr        # PFR/TrueDoc font driver
                   psaux      # common PostScript routines module
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -277,7 +277,7 @@
     /* for each row */
     for ( y = 0; y < bitmap->rows ; y++ )
     {
-      /* 
+      /*
        * Horizontally:
        *
        * From the last pixel on, make each pixel or'ed with the
@@ -310,12 +310,12 @@
             {
               if ( p[x] + p[x - i] > bitmap->num_grays - 1 )
               {
-                p[x] = bitmap->num_grays - 1;
+                p[x] = (unsigned char)(bitmap->num_grays - 1);
                 break;
               }
               else
               {
-                p[x] += p[x - i];
+                p[x] = (unsigned char)(p[x] + p[x-i]);
                 if ( p[x] == bitmap->num_grays - 1 )
                   break;
               }
@@ -326,7 +326,7 @@
         }
       }
 
-      /* 
+      /*
        * Vertically:
        *
        * Make the above `ystr' rows or'ed with it.
--- a/src/otvalid/otvcommn.h
+++ b/src/otvalid/otvcommn.h
@@ -109,39 +109,42 @@
           FT_END_STMNT
 
 
+#define  OTV_NAME_(x)  #x
+#define  OTV_NAME(x)   OTV_NAME_(x)
+
+#define  OTV_FUNC_(x)  x##Func
+#define  OTV_FUNC(x)   OTV_FUNC_(x)
+
 #ifdef FT_DEBUG_LEVEL_TRACE
 
   /* use preprocessor's argument prescan to expand one argument into two */
-#define OTV_NEST1( x )  OTV_NEST1_( x )
-#define OTV_NEST1_( func0, name0 )                 \
-          FT_BEGIN_STMNT                           \
-            valid->nesting_level          = 0;     \
-            valid->func[0]                = func0; \
-            valid->debug_function_name[0] = name0; \
+#define OTV_NEST1( x )                                     \
+          FT_BEGIN_STMNT                                   \
+            valid->nesting_level          = 0;             \
+            valid->func[0]                = OTV_FUNC(x);   \
+            valid->debug_function_name[0] = OTV_NAME(x);   \
           FT_END_STMNT
 
   /* use preprocessor's argument prescan to expand two arguments into four */
-#define OTV_NEST2( x, y )  OTV_NEST2_( x, y )
-#define OTV_NEST2_( func0, name0, func1, name1 )   \
-          FT_BEGIN_STMNT                           \
-            valid->nesting_level          = 0;     \
-            valid->func[0]                = func0; \
-            valid->func[1]                = func1; \
-            valid->debug_function_name[0] = name0; \
-            valid->debug_function_name[1] = name1; \
+#define OTV_NEST2( x, y )                                   \
+          FT_BEGIN_STMNT                                    \
+            valid->nesting_level          = 0;              \
+            valid->func[0]                = OTV_FUNC(x);    \
+            valid->func[1]                = OTV_FUNC(y);    \
+            valid->debug_function_name[0] = OTV_NAME(x);    \
+            valid->debug_function_name[1] = OTV_NAME(y);    \
           FT_END_STMNT
 
   /* use preprocessor's argument prescan to expand three arguments into six */
-#define OTV_NEST3( x, y, z )  OTV_NEST3_( x, y, z )
-#define OTV_NEST3_( func0, name0, func1, name1, func2, name2 ) \
-          FT_BEGIN_STMNT                                       \
-            valid->nesting_level          = 0;                 \
-            valid->func[0]                = func0;             \
-            valid->func[1]                = func1;             \
-            valid->func[2]                = func2;             \
-            valid->debug_function_name[0] = name0;             \
-            valid->debug_function_name[1] = name1;             \
-            valid->debug_function_name[2] = name2;             \
+#define OTV_NEST3( x, y, z )                                \
+          FT_BEGIN_STMNT                                    \
+            valid->nesting_level          = 0;              \
+            valid->func[0]                = OTV_FUNC(x);    \
+            valid->func[1]                = OTV_FUNC(y);    \
+            valid->func[2]                = OTV_FUNC(z);    \
+            valid->debug_function_name[0] = OTV_NAME(x);    \
+            valid->debug_function_name[1] = OTV_NAME(y);    \
+            valid->debug_function_name[2] = OTV_NAME(z);    \
           FT_END_STMNT
 
 #define OTV_INIT  valid->debug_indent = 0
@@ -172,30 +175,27 @@
 #else   /* !FT_DEBUG_LEVEL_TRACE */
 
   /* use preprocessor's argument prescan to expand one argument into two */
-#define OTV_NEST1( x )  OTV_NEST1_( x )
-#define OTV_NEST1_( func0, name0 )        \
-          FT_BEGIN_STMNT                  \
-            valid->nesting_level = 0;     \
-            valid->func[0]       = func0; \
+#define OTV_NEST1( x )                          \
+          FT_BEGIN_STMNT                        \
+            valid->nesting_level = 0;           \
+            valid->func[0]       = OTV_FUNC(x); \
           FT_END_STMNT
 
   /* use preprocessor's argument prescan to expand two arguments into four */
-#define OTV_NEST2( x, y )  OTV_NEST2_( x, y )
-#define OTV_NEST2_( func0, name0, func1, name1 ) \
+#define OTV_NEST2( x, y )                        \
           FT_BEGIN_STMNT                         \
             valid->nesting_level = 0;            \
-            valid->func[0]       = func0;        \
-            valid->func[1]       = func1;        \
+            valid->func[0]       = OTV_FUNC(x);  \
+            valid->func[1]       = OTV_FUNC(y);  \
           FT_END_STMNT
 
   /* use preprocessor's argument prescan to expand three arguments into six */
-#define OTV_NEST3( x, y, z )  OTV_NEST3_( x, y, z )
-#define OTV_NEST3_( func0, name0, func1, name1, func2, name2 ) \
-          FT_BEGIN_STMNT                                       \
-            valid->nesting_level = 0;                          \
-            valid->func[0]       = func0;                      \
-            valid->func[1]       = func1;                      \
-            valid->func[2]       = func2;                      \
+#define OTV_NEST3( x, y, z )                     \
+          FT_BEGIN_STMNT                         \
+            valid->nesting_level = 0;            \
+            valid->func[0]       = OTV_FUNC(x);  \
+            valid->func[1]       = OTV_FUNC(y);  \
+            valid->func[2]       = OTV_FUNC(z);  \
           FT_END_STMNT
 
 #define OTV_INIT                do ; while ( 0 )
@@ -338,6 +338,7 @@
   /*************************************************************************/
   /*************************************************************************/
 
+#if 0
 #define ChainPosClassSet  otv_x_Ox, "ChainPosClassSet"
 #define ChainPosRuleSet   otv_x_Ox, "ChainPosRuleSet"
 #define ChainSubClassSet  otv_x_Ox, "ChainSubClassSet"
@@ -351,11 +352,27 @@
 #define PosRuleSet        otv_x_Ox, "PosRuleSet"
 #define SubClassSet       otv_x_Ox, "SubClassSet"
 #define SubRuleSet        otv_x_Ox, "SubRuleSet"
+#endif
 
+#define ChainPosClassSetFunc  otv_x_Ox
+#define ChainPosRuleSetFunc   otv_x_Ox
+#define ChainSubClassSetFunc  otv_x_Ox
+#define ChainSubRuleSetFunc   otv_x_Ox
+#define JstfLangSysFunc       otv_x_Ox
+#define JstfMaxFunc           otv_x_Ox
+#define LigGlyphFunc          otv_x_Ox
+#define LigatureArrayFunc     otv_x_Ox
+#define LigatureSetFunc       otv_x_Ox
+#define PosClassSetFunc       otv_x_Ox
+#define PosRuleSetFunc        otv_x_Ox
+#define SubClassSetFunc       otv_x_Ox
+#define SubRuleSetFunc        otv_x_Ox
+
   FT_LOCAL( void )
   otv_x_Ox ( FT_Bytes       table,
              OTV_Validator  valid );
 
+#if 0
 #define AlternateSubstFormat1     otv_u_C_x_Ox, "AlternateSubstFormat1"
 #define ChainContextPosFormat1    otv_u_C_x_Ox, "ChainContextPosFormat1"
 #define ChainContextSubstFormat1  otv_u_C_x_Ox, "ChainContextSubstFormat1"
@@ -363,11 +380,22 @@
 #define ContextSubstFormat1       otv_u_C_x_Ox, "ContextSubstFormat1"
 #define LigatureSubstFormat1      otv_u_C_x_Ox, "LigatureSubstFormat1"
 #define MultipleSubstFormat1      otv_u_C_x_Ox, "MultipleSubstFormat1"
+#endif
 
+#define AlternateSubstFormat1Func     otv_u_C_x_Ox
+#define ChainContextPosFormat1Func    otv_u_C_x_Ox
+#define ChainContextSubstFormat1Func  otv_u_C_x_Ox
+#define ContextPosFormat1Func         otv_u_C_x_Ox
+#define ContextSubstFormat1Func       otv_u_C_x_Ox
+#define LigatureSubstFormat1Func      otv_u_C_x_Ox
+#define MultipleSubstFormat1Func      otv_u_C_x_Ox
+
+
   FT_LOCAL( void )
   otv_u_C_x_Ox( FT_Bytes       table,
                 OTV_Validator  valid );
 
+#if 0
 #define AlternateSet     otv_x_ux, "AlternateSet"
 #define AttachPoint      otv_x_ux, "AttachPoint"
 #define ExtenderGlyph    otv_x_ux, "ExtenderGlyph"
@@ -374,52 +402,93 @@
 #define JstfGPOSModList  otv_x_ux, "JstfGPOSModList"
 #define JstfGSUBModList  otv_x_ux, "JstfGSUBModList"
 #define Sequence         otv_x_ux, "Sequence"
+#endif
+#define AlternateSetFunc     otv_x_ux
+#define AttachPointFunc      otv_x_ux
+#define ExtenderGlyphFunc    otv_x_ux
+#define JstfGPOSModListFunc  otv_x_ux
+#define JstfGSUBModListFunc  otv_x_ux
+#define SequenceFunc         otv_x_ux
 
   FT_LOCAL( void )
   otv_x_ux( FT_Bytes       table,
             OTV_Validator  valid );
 
+#if 0
 #define PosClassRule  otv_x_y_ux_sy, "PosClassRule"
 #define PosRule       otv_x_y_ux_sy, "PosRule"
 #define SubClassRule  otv_x_y_ux_sy, "SubClassRule"
 #define SubRule       otv_x_y_ux_sy, "SubRule"
+#endif
 
+#define PosClassRuleFunc  otv_x_y_ux_sy
+#define PosRuleFunc       otv_x_y_ux_sy
+#define SubClassRuleFunc  otv_x_y_ux_sy
+#define SubRuleFunc       otv_x_y_ux_sy
+
   FT_LOCAL( void )
   otv_x_y_ux_sy( FT_Bytes       table,
                  OTV_Validator  valid );
 
+#if 0
 #define ChainPosClassRule  otv_x_ux_y_uy_z_uz_p_sp, "ChainPosClassRule"
 #define ChainPosRule       otv_x_ux_y_uy_z_uz_p_sp, "ChainPosRule"
 #define ChainSubClassRule  otv_x_ux_y_uy_z_uz_p_sp, "ChainSubClassRule"
 #define ChainSubRule       otv_x_ux_y_uy_z_uz_p_sp, "ChainSubRule"
+#endif
 
+#define ChainPosClassRuleFunc  otv_x_ux_y_uy_z_uz_p_sp
+#define ChainPosRuleFunc       otv_x_ux_y_uy_z_uz_p_sp
+#define ChainSubClassRuleFunc  otv_x_ux_y_uy_z_uz_p_sp
+#define ChainSubRuleFunc       otv_x_ux_y_uy_z_uz_p_sp
+
   FT_LOCAL( void )
   otv_x_ux_y_uy_z_uz_p_sp( FT_Bytes       table,
                            OTV_Validator  valid );
 
+#if 0
 #define ContextPosFormat2    otv_u_O_O_x_Onx, "ContextPosFormat2"
 #define ContextSubstFormat2  otv_u_O_O_x_Onx, "ContextSubstFormat2"
+#endif
 
+#define ContextPosFormat2Func    otv_u_O_O_x_Onx
+#define ContextSubstFormat2Func  otv_u_O_O_x_Onx
+
   FT_LOCAL( void )
   otv_u_O_O_x_Onx( FT_Bytes       table,
                    OTV_Validator  valid );
 
+#if 0
 #define ContextPosFormat3    otv_u_x_y_Ox_sy, "ContextPosFormat3"
 #define ContextSubstFormat3  otv_u_x_y_Ox_sy, "ContextSubstFormat3"
+#endif
 
+#define ContextPosFormat3Func    otv_u_x_y_Ox_sy
+#define ContextSubstFormat3Func  otv_u_x_y_Ox_sy
+
   FT_LOCAL( void )
   otv_u_x_y_Ox_sy( FT_Bytes       table,
                    OTV_Validator  valid );
 
-#define ChainContextPosFormat2    otv_u_O_O_O_O_x_Onx, "ChainContextPosFormat2"
-#define ChainContextSubstFormat2  otv_u_O_O_O_O_x_Onx, "ChainContextSubstFormat2"
+#if 0
+#define ChainContextPosFormat2        otv_u_O_O_O_O_x_Onx, "ChainContextPosFormat2"
+#define ChainContextSubstFormat2      otv_u_O_O_O_O_x_Onx, "ChainContextSubstFormat2"
+#endif
 
+#define ChainContextPosFormat2Func    otv_u_O_O_O_O_x_Onx
+#define ChainContextSubstFormat2Func  otv_u_O_O_O_O_x_Onx
+
   FT_LOCAL( void )
   otv_u_O_O_O_O_x_Onx( FT_Bytes       table,
                        OTV_Validator  valid );
 
-#define ChainContextPosFormat3    otv_u_x_Ox_y_Oy_z_Oz_p_sp, "ChainContextPosFormat3"
-#define ChainContextSubstFormat3  otv_u_x_Ox_y_Oy_z_Oz_p_sp, "ChainContextSubstFormat3"
+#if 0
+#define ChainContextPosFormat3        otv_u_x_Ox_y_Oy_z_Oz_p_sp, "ChainContextPosFormat3"
+#define ChainContextSubstFormat3      otv_u_x_Ox_y_Oy_z_Oz_p_sp, "ChainContextSubstFormat3"
+#endif
+
+#define ChainContextPosFormat3Func    otv_u_x_Ox_y_Oy_z_Oz_p_sp
+#define ChainContextSubstFormat3Func  otv_u_x_Ox_y_Oy_z_Oz_p_sp
 
   FT_LOCAL( void )
   otv_u_x_Ox_y_Oy_z_Oz_p_sp( FT_Bytes       table,
--- a/src/otvalid/otvgdef.c
+++ b/src/otvalid/otvgdef.c
@@ -38,8 +38,8 @@
   /*************************************************************************/
   /*************************************************************************/
 
-#define AttachList    otv_O_x_Ox, "AttachList"
-#define LigCaretList  otv_O_x_Ox, "LigCaretList"
+#define AttachListFunc    otv_O_x_Ox
+#define LigCaretListFunc  otv_O_x_Ox
 
   /* sets valid->extra1 (0)           */
 
@@ -88,7 +88,7 @@
   /*************************************************************************/
   /*************************************************************************/
 
-#define  CaretValue  otv_CaretValue_validate, "CaretValue"
+#define  CaretValueFunc  otv_CaretValue_validate
 
   static void
   otv_CaretValue_validate( FT_Bytes       table,
--- a/src/otvalid/otvgpos.c
+++ b/src/otvalid/otvgpos.c
@@ -48,9 +48,9 @@
   /*************************************************************************/
   /*************************************************************************/
 
-#define BaseArray       otv_x_sxy, "BaseArray"
-#define LigatureAttach  otv_x_sxy, "LigatureAttach"
-#define Mark2Array      otv_x_sxy, "Mark2Array"
+#define BaseArrayFunc       otv_x_sxy
+#define LigatureAttachFunc  otv_x_sxy
+#define Mark2ArrayFunc      otv_x_sxy
 
   /* uses valid->extra1 (counter)                             */
   /* uses valid->extra2 (boolean to handle NULL anchor field) */
@@ -88,8 +88,8 @@
           OTV_SIZE_CHECK( anchor_offset );
           if ( anchor_offset )
             otv_Anchor_validate( table + anchor_offset, valid );
-        }        
-        else  
+        }
+        else
           otv_Anchor_validate( table + anchor_offset, valid );
       }
 
@@ -97,9 +97,9 @@
   }
 
 
-#define MarkBasePosFormat1  otv_u_O_O_u_O_O, "MarkBasePosFormat1"
-#define MarkLigPosFormat1   otv_u_O_O_u_O_O, "MarkLigPosFormat1"
-#define MarkMarkPosFormat1  otv_u_O_O_u_O_O, "MarkMarkPosFormat1"
+#define MarkBasePosFormat1Func  otv_u_O_O_u_O_O
+#define MarkLigPosFormat1Func   otv_u_O_O_u_O_O
+#define MarkMarkPosFormat1Func  otv_u_O_O_u_O_O
 
   /* sets valid->extra1 (class count) */
 
@@ -130,7 +130,7 @@
     otv_MarkArray_validate( table + Array1, valid );
 
     valid->nesting_level++;
-    func          = valid->func[valid->nesting_level];    
+    func          = valid->func[valid->nesting_level];
     valid->extra1 = ClassCount;
 
     func( table + Array2, valid );
@@ -861,8 +861,7 @@
       /* context rules since even invalid glyph indices/classes return  */
       /* meaningful results                                             */
 
-      OTV_NEST3( ChainContextPosFormat2,
-                 ChainPosClassSet, ChainPosClassRule );
+      OTV_NEST3( ChainContextPosFormat2,ChainPosClassSet, ChainPosClassRule );
       OTV_RUN( table, valid );
       break;
 
--- a/src/otvalid/otvgsub.c
+++ b/src/otvalid/otvgsub.c
@@ -200,7 +200,7 @@
   /*************************************************************************/
   /*************************************************************************/
 
-#define Ligature  otv_Ligature_validate, "Ligature"
+#define LigatureFunc  otv_Ligature_validate
 
   /* uses valid->glyph_count */
 
--- a/src/otvalid/otvjstf.c
+++ b/src/otvalid/otvjstf.c
@@ -31,8 +31,8 @@
 #define FT_COMPONENT  trace_otvjstf
 
 
-#define JstfPriority  otv_JstfPriority_validate, "JstfPriority"
-#define JstfLookup    otv_GPOS_subtable_validate, ""
+#define JstfPriorityFunc  otv_JstfPriority_validate
+#define JstfLookupFunc    otv_GPOS_subtable_validate
 
   /* uses valid->extra1 (GSUB lookup count) */
   /* uses valid->extra2 (GPOS lookup count) */
@@ -69,7 +69,7 @@
     table_size = 20;
 
     valid->extra1 = gsub_lookup_count;
-    
+
     OTV_OPTIONAL_OFFSET( ShrinkageEnableGSUB );
     OTV_SIZE_CHECK( ShrinkageEnableGSUB );
     if ( ShrinkageEnableGSUB )
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -2160,7 +2160,7 @@
           if ( clazz->format == format )
           {
             volatile TT_ValidatorRec  valid;
-            FT_Error                  error = SFNT_Err_Ok;
+            volatile FT_Error         error = SFNT_Err_Ok;
 
 
             ft_validator_init( FT_VALIDATOR( &valid ), cmap, limit,
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -124,9 +124,9 @@
       p      = face->horz_metrics;
       limit  = p + face->horz_metrics_size;
     }
-    
+
     k = header->number_Of_HMetrics;
-    
+
     if ( k > 0 )
     {
       if ( idx < (FT_UInt)k )
@@ -134,7 +134,7 @@
         p += 4 * idx;
         if ( p + 4 > limit )
           goto NoData;
-          
+
         *aadvance = FT_NEXT_USHORT( p );
         *abearing = FT_NEXT_SHORT( p );
       }
@@ -143,7 +143,7 @@
         p += 4 * ( k - 1 );
         if ( p + 4 > limit )
           goto NoData;
-          
+
         *aadvance = FT_NEXT_USHORT( p );
         p += 2 + 2 * ( idx - k );
         if ( p + 2 > limit )
@@ -233,8 +233,8 @@
     FT_Byte*  result      = NULL;
     FT_ULong  record_size = face->hdmx_record_size;
     FT_Byte*  record      = face->hdmx_table + 8;
-    
 
+
     for ( nn = 0; nn < face->hdmx_record_count; nn++ )
       if ( face->hdmx_record_sizes[nn] == ppem )
       {
@@ -1774,11 +1774,12 @@
         /*       table in the font.  Otherwise, we use the     */
         /*       values defined in the horizontal header.      */
 
-        height = FT_DivFix( bbox.yMax - bbox.yMin, y_scale );
+        height = (FT_Short)FT_DivFix( bbox.yMax - bbox.yMin, y_scale );
         if ( face->os2.version != 0xFFFFU )
         {
           /* sTypoDescender is negative */
-          max_height = face->os2.sTypoAscender - face->os2.sTypoDescender;
+          max_height     = (FT_Short)(face->os2.sTypoAscender -
+                                      face->os2.sTypoDescender);
 
           top_bearing    = (FT_Short)( ( max_height - height ) / 2 );
           advance_height = (FT_UShort)( max_height + face->os2.sTypoLineGap );
@@ -1785,7 +1786,8 @@
         }
         else
         {
-          max_height = face->horizontal.Ascender + face->horizontal.Descender;
+          max_height = (FT_Short)(face->horizontal.Ascender +
+                                  face->horizontal.Descender);
 
           top_bearing    = (FT_Short)( ( max_height - height ) / 2 );
           advance_height = (FT_UShort)( max_height +