shithub: freetype+ttf2subf

Download patch

ref: ffa033b1bc91a10275f3e01da3971f24cc58a4b5
parent: da245ee30ad989c4281acb7fe3e948e929c203f7
author: Werner Lemberg <[email protected]>
date: Fri Aug 19 04:56:29 EDT 2005

* src/truetype/ttgload.c (load_truetype_glyph): Fix compiler
warnings.

Formatting.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-08-19  Werner Lemberg  <[email protected]>
+
+	* src/truetype/ttgload.c (load_truetype_glyph): Fix compiler
+	warnings.
+
 2005-08-16  Chia I Wu  <[email protected]>
 
 	* src/truetype/ttinterp.c, src/truetype/ttinterp.h: Update copyright
@@ -6,37 +11,48 @@
 2005-08-16  Chia I Wu  <[email protected]>
 
 	* src/truetype/ttinterp.c, src/truetype/ttinterp.h: Remove original
-	TT_Done_Context and rename TT_Destroy_Context to TT_Done_Context with
-	slight changes.
+	TT_Done_Context and rename TT_Destroy_Context to TT_Done_Context
+	with slight changes.
+	Update all callers.
+	(TT_New_Context): Now takes TT_Driver argument directly.
+	Update all callers.
 
 	* src/truetype/ttobjs.h (tt_slot_init): New function.
-
-	* src/truetype/ttobjs.c (tt_driver_init): Initialize execution context
-	here.
+	* src/truetype/ttobjs.c (tt_driver_init): Initialize execution
+	context here.
 	(tt_slot_init): New function to create extra points for the internal
-	glyph loader. We then use it directly, instead of face's glyph loader,
-	when loading glyph.
+	glyph loader.  We then use it directly, instead of face's glyph
+	loader, when loading glyph.
 
-	* src/truetype/ttdriver.c: Use tt_slot_init for glyph slot
-	initialization.
-	(TT_Load_Glyph): Load flag dependencies are handled here.
-	Return error if size is NULL.
+	* src/truetype/ttdriver.c (tt_driver_class): Use tt_slot_init for
+	glyph slot initialization.
+	(Load_Glyph): Load flag dependencies are handled here.  Return error
+	if size is NULL.
 
-	* src/truetype/ttgload.c: Heavy cleanup and refactor.
+	* src/truetype/ttgload.c: Heavy cleanup and refactoring.
+	(org_to_cur): Removed.
+	(TT_Load_Simple_Glyph): Call FT_GlyphLoader_CheckPoints.
 	(TT_Hint_Glyph): New funcion to hint a zone, prepared by caller.
-	(TT_Process_Simple_Glyph): Use loader->pp's instead of recalculating.
+	(TT_Process_Simple_Glyph): s/load/loader/.
+	Use loader->pp values instead of recalculation.
 	Use TT_Hint_Glyph.
-	No need to save/restore loader->stream before/after
+	No need to save/restore loader->stream before and after
 	TT_Vary_Get_Glyph_Deltas now.
-	(TT_LOADER_SET_PP): New macro to calculate and set the four phantom points.
-	(TT_Process_Composite_Component, TT_Process_Composite_Glyph,
-	load_truetype_glyph): Refactor load_truetype_glyph into these three functions.
-	Never set exec->glyphSize to 0. (close #13107)
+	(TT_LOADER_SET_PP): New macro to calculate and set the four phantom
+	points.
+	(load_truetype_glyph): Never set exec->glyphSize to 0.  This closes
+	Savannah bug #13107.
 	Forget glyph frame before calling TT_Process_Simple_Glyph.
-	(TT_Load_Glyph, load_sbit_image, tt_loader_init): Refactor TT_Load_Glyph into
-	these three functions.
-	Set various fields of `glyph' here, instead of in load_truetype_glyph
-	and compute_glyph_metrics.
+	Use TT_LOADER_SET_PP.
+	Scale all four phantom points.
+	Split off some functionality to ...
+	(TT_Process_Composite_Component, TT_Process_Composite_Glyph): These
+	new functions.
+	(TT_Load_Glyph): Set various fields of `glyph' here, not in
+	load_truetype_glyph and compute_glyph_metrics.
+	Split off some functionality to ...
+	(load_sbit_image, tt_loader_init): These new functions.
+	(compute_glyph_metrics): Call FT_Outline_Get_CBox.
 
 2005-08-08  Werner Lemberg  <[email protected]>
 
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -955,14 +955,14 @@
     FT_Pos          x, y;
     
 
-    have_scale = ( subglyph->flags & ( WE_HAVE_A_SCALE     |
-                                       WE_HAVE_AN_XY_SCALE |
-                                       WE_HAVE_A_2X2       ) );
+    have_scale = subglyph->flags & ( WE_HAVE_A_SCALE     |
+                                     WE_HAVE_AN_XY_SCALE |
+                                     WE_HAVE_A_2X2       );
 
     /* perform the transform required for this subglyph */
     if ( have_scale )
     {
-      FT_UInt i;
+      FT_UInt  i;
 
 
       for ( i = num_base_points; i < num_points; i++ )
@@ -978,17 +978,15 @@
       FT_Vector*  p2;
 
 
-      /* match l-th point of the newly loaded component to the k-th point of  */
-      /* the previously loaded components.                                    */
+      /* match l-th point of the newly loaded component to the k-th point */
+      /* of the previously loaded components.                             */
 
       /* change to the point numbers used by our outline */
       k += start_point;
       l += num_base_points;
-      if ( k >= (FT_UInt)num_base_points ||
-           l >= (FT_UInt)num_points  )
-      {
+      if ( k >= num_base_points ||
+           l >= num_points      )
         return TT_Err_Invalid_Composite;
-      }
 
       p1 = gloader->base.outline.points + k;
       p2 = gloader->base.outline.points + l;
@@ -1004,9 +1002,9 @@
       if ( !x && !y )
         return TT_Err_Ok;
 
-/* Use a default value dependent on                                     */
-/* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED.  This is useful for old TT */
-/* fonts which don't set the xxx_COMPONENT_OFFSET bit.                  */
+  /* Use a default value dependent on                                     */
+  /* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED.  This is useful for old TT */
+  /* fonts which don't set the xxx_COMPONENT_OFFSET bit.                  */
 
       if ( have_scale &&
 #ifdef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
@@ -1017,10 +1015,10 @@
       {
 #if 0
 
-/*************************************************************************/
-/*                                                                       */
-/* This algorithm is what Apple documents.  But it doesn't work.         */
-/*                                                                       */
+  /*************************************************************************/
+  /*                                                                       */
+  /* This algorithm is what Apple documents.  But it doesn't work.         */
+  /*                                                                       */
         int  a = subglyph->transform.xx > 0 ?  subglyph->transform.xx
                                             : -subglyph->transform.xx;
         int  b = subglyph->transform.yx > 0 ?  subglyph->transform.yx
@@ -1042,10 +1040,10 @@
 
 #else /* 0 */
 
-/*************************************************************************/
-/*                                                                       */
-/* This algorithm is a guess and works much better than the above.       */
-/*                                                                       */
+  /*************************************************************************/
+  /*                                                                       */
+  /* This algorithm is a guess and works much better than the above.       */
+  /*                                                                       */
         FT_Fixed  mac_xscale = FT_SqrtFixed(
                                  FT_MulFix( subglyph->transform.xx,
                                             subglyph->transform.xx ) +
@@ -1067,8 +1065,8 @@
 
       if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
       {
-        FT_Fixed    x_scale = ((TT_Size)loader->size)->metrics.x_scale;
-        FT_Fixed    y_scale = ((TT_Size)loader->size)->metrics.y_scale;
+        FT_Fixed  x_scale = ((TT_Size)loader->size)->metrics.x_scale;
+        FT_Fixed  y_scale = ((TT_Size)loader->size)->metrics.y_scale;
 
 
         x = FT_MulFix( x, x_scale );
@@ -1113,7 +1111,9 @@
     outline = &loader->gloader->base.outline;
 
     /* make room for phantom points */
-    error = FT_GlyphLoader_CheckPoints( loader->gloader, outline->n_points + 4, 0 );
+    error = FT_GlyphLoader_CheckPoints( loader->gloader,
+                                        outline->n_points + 4,
+                                        0 );
     if ( error )
       return error;
 
@@ -1137,7 +1137,7 @@
       /* TT_Load_Composite_Glyph only gives us the offset of instructions */
       /* so we read them here */
       if ( FT_STREAM_SEEK( loader->ins_pos ) ||
-           FT_READ_USHORT( n_ins ) )
+           FT_READ_USHORT( n_ins )           )
         return error;
 
       FT_TRACE5(( "  Instructions size = %d\n", n_ins ));
@@ -1161,7 +1161,8 @@
 
 #endif
 
-    tt_prepare_zone( &loader->zone, &loader->gloader->base, start_point, start_contour );
+    tt_prepare_zone( &loader->zone, &loader->gloader->base,
+                     start_point, start_contour );
     loader->zone.n_points += 4;
 
     return TT_Hint_Glyph( loader, 1 );
@@ -1283,9 +1284,10 @@
           goto Exit;
         left_bearing  = (FT_Short)metrics.bearing_x;
         advance_width = (FT_UShort)metrics.advance;
+
 # if 0
 
-      /* GWW: Do I do the same for vertical metrics ??? */
+        /* GWW: Do I do the same for vertical metrics ??? */
         metrics.bearing_x = 0;
         metrics.bearing_y = top_bearing;
         metrics.advance = advance_height;
@@ -1316,7 +1318,7 @@
     }
 
     /* Set `offset' to the start of the glyph relative to the start of */
-    /* the 'glyf' table, and `byte_len' to the length of the glyph in  */
+    /* the `glyf' table, and `byte_len' to the length of the glyph in  */
     /* bytes.                                                          */
 
 #ifdef FT_CONFIG_OPTION_INCREMENTAL
@@ -1346,7 +1348,8 @@
 
 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
 
-      offset = tt_face_get_location( face, glyph_index, (FT_UInt*)&loader->byte_len );
+      offset = tt_face_get_location( face, glyph_index,
+                                     (FT_UInt*)&loader->byte_len );
 
     if ( loader->byte_len == 0 )
     {
@@ -1525,7 +1528,7 @@
       /*********************************************************************/
 
       {
-        FT_Int       n, num_base_points;
+        FT_UInt      n, num_base_points;
         FT_SubGlyph  subglyph       = 0;
 
         FT_UInt      num_points     = start_point;
@@ -1536,7 +1539,7 @@
         FT_GlyphLoader_Add( gloader );
 
         /* read each subglyph independently */
-        for ( n = 0; n < (FT_Int)num_subglyphs; n++ )
+        for ( n = 0; n < num_subglyphs; n++ )
         {
           FT_Vector  pp[4];
 
@@ -1815,6 +1818,7 @@
 
 
 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
+
   static FT_Error
   load_sbit_image( TT_Size       size,
                    TT_GlyphSlot  glyph,
@@ -1827,6 +1831,7 @@
     FT_Error            error;
     TT_SBit_MetricsRec  metrics;
 
+
     face   = (TT_Face)glyph->face;
     sfnt   = (SFNT_Service)face->sfnt;
     stream = face->root.stream;
@@ -1869,9 +1874,10 @@
 
     return error;
   }
-#endif
 
+#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
 
+
   static FT_Error
   tt_loader_init( TT_Loader     loader,
                   TT_Size       size,
@@ -1878,11 +1884,11 @@
                   TT_GlyphSlot  glyph,
                   FT_Int32      load_flags )
   {
-    TT_Face         face;
-    FT_Stream       stream;
+    TT_Face    face;
+    FT_Stream  stream;
 
 
-    face = (TT_Face)glyph->face;
+    face   = (TT_Face)glyph->face;
     stream = face->root.stream;
 
     FT_MEM_ZERO( loader, sizeof ( TT_LoaderRec ) );
@@ -1934,6 +1940,8 @@
 
     {
       FT_Error  error = face->goto_table( face, TTAG_glyf, stream, 0 );
+
+
       if ( error )
       {
         FT_ERROR(( "TT_Load_Glyph: could not access glyph table\n" ));
@@ -1946,6 +1954,7 @@
     {
       FT_GlyphLoader  gloader = glyph->internal->loader;
 
+
       FT_GlyphLoader_Rewind( gloader );
       loader->gloader = gloader;
     }
@@ -2010,7 +2019,7 @@
     /*                                                 */
     /* XXX: The convention should be emphasized in     */
     /*      the documents because it can be confusing. */
-    if ( size->strike_index != 0xFFFFU &&
+    if ( size->strike_index != 0xFFFFU           &&
          ( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
     {
       error = load_sbit_image( size, glyph, glyph_index, load_flags );
@@ -2042,7 +2051,7 @@
       }
       else
       {
-        glyph->outline = loader.gloader->base.outline;
+        glyph->outline        = loader.gloader->base.outline;
         glyph->outline.flags &= ~FT_OUTLINE_SINGLE_PASS;
 
         /* translate array so that (0,0) is the glyph's origin */
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -444,7 +444,7 @@
 
   /*************************************************************************/
   /*                                                                       */
-  /* Slot functions                                                      */
+  /* Slot functions                                                        */
   /*                                                                       */
   FT_LOCAL( FT_Error )
   tt_slot_init( FT_GlyphSlot  slot );