shithub: freetype+ttf2subf

Download patch

ref: 74abee8e2ea269b983916b8eb55bef385b98f2e2
parent: 7ed5a057cf778864883a4b814aeaed8d103fc2a7
author: David Turner <[email protected]>
date: Tue Jun 27 19:31:53 EDT 2000

various cleanups to reduce compiler warnings

git/fs: mount .git/fs: mount/attach disallowed
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -440,8 +440,8 @@
   }
 
 
-  BASE_FUNC( FT_Error )  FT_GlyphLoader_Create_Extra(
-                           FT_GlyphLoader*  loader )
+
+  BASE_FUNC(FT_Error)  FT_GlyphLoader_Create_Extra( FT_GlyphLoader*  loader )
   {
     FT_Error   error;
     FT_Memory  memory = loader->memory;
@@ -881,6 +881,8 @@
   }
 
 
+  static  FT_Renderer  ft_lookup_glyph_renderer( FT_GlyphSlot  slot );
+  
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
@@ -926,7 +928,7 @@
     if ( !face || !face->size || !face->glyph )
       return FT_Err_Invalid_Face_Handle;
 
-    if ( glyph_index >= face->num_glyphs )
+    if ( glyph_index >= (FT_UInt)face->num_glyphs )
       return FT_Err_Invalid_Argument;
 
     slot = face->glyph;
@@ -1388,7 +1390,6 @@
           FT_Int         num_params = 0;
           FT_Parameter*  params     = 0;
 
-
           driver = FT_DRIVER( cur[0] );
 
           if ( args->flags & ft_open_params )
@@ -2213,16 +2214,20 @@
   /*************************************************************************/
 
  /* lookup a renderer by glyph format in the library's list */
-  static FT_Renderer  ft_lookup_renderer( FT_Library       library,
-                                          FT_Glyph_Format  format,
-                                          FT_ListNode*     node )
+  BASE_FUNC(FT_Renderer)  FT_Lookup_Renderer( FT_Library       library,
+                                              FT_Glyph_Format  format,
+                                              FT_ListNode     *node )
   {
     FT_ListNode   cur    = library->renderers.head;
     FT_Renderer   result = 0;
 
     
-    if ( node )
+    if (node)
+    {
+      if (*node)
+        cur = (*node)->next;
       *node = 0;
+    }
       
     while ( cur )
     {
@@ -2237,6 +2242,7 @@
         result = renderer;
         break;
       }
+      cur = cur->next;
     }
 
     return result;
@@ -2243,7 +2249,7 @@
   }
 
   
-  static  FT_Renderer  ft_lookup_glyph_renderer( FT_GlyphSlot  slot )
+  static FT_Renderer  ft_lookup_glyph_renderer( FT_GlyphSlot  slot )
   {
     FT_Face     face    = slot->face;
     FT_Library  library = FT_FACE_LIBRARY( face );
@@ -2261,7 +2267,7 @@
   {
     FT_Renderer  renderer;
 
-    renderer = ft_lookup_renderer( library, ft_glyph_format_outline, 0 );
+    renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, 0 );
     library->cur_renderer = renderer;
   }
 
@@ -2364,7 +2370,7 @@
   FT_EXPORT_FUNC( FT_Renderer )  FT_Get_Renderer( FT_Library       library,
                                                   FT_Glyph_Format  format )
   {
-    return  ft_lookup_renderer( library, format, 0 );
+    return  FT_Lookup_Renderer( library, format, 0 );
   }                                               
 
 
@@ -2409,7 +2415,7 @@
       error = FT_Err_Invalid_Argument;
       goto Exit;
     }
-      
+
     FT_List_Up( &library->renderers, node );
     
     if ( renderer->glyph_format == ft_glyph_format_outline )
@@ -2433,75 +2439,108 @@
   }                                           
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    FT_Render_Glyph                                                    */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Converts a given glyph image to a bitmap.  It does so by           */
-  /*    inspecting the glyph image format, find the relevant renderer, and */
-  /*    invoke it.                                                         */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    slot        :: A handle to the glyph slot containing the image to  */
-  /*                   convert.                                            */
-  /*                                                                       */
-  /*    render_mode :: A set of bit flags indicating which kind of bitmap  */
-  /*                   to render.  For now, only                           */
-  /*                   `ft_render_mode_anti_alias' is supported by the     */
-  /*                   available renderers, but others could appear later  */
-  /*                   (e.g. optimized for TV or LCD).                     */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    FreeType error code.  0 means success.                             */
-  /*                                                                       */
-  /* <Note>                                                                */
-  /*    In case of success, the renderer will be used to convert glyph     */
-  /*    images in the renderer's known format into bitmaps.                */
-  /*                                                                       */
-  /*    This doesn't change the current renderer for other formats.        */
-  /*                                                                       */
-  /*    The slot's native image should be considered lost after the        */
-  /*    conversion.                                                        */
-  /*                                                                       */
-  FT_EXPORT_FUNC( FT_Error )  FT_Render_Glyph( FT_GlyphSlot  slot,
-                                               FT_UInt       render_mode )
+<<<<<<< ftobjs.c
+ /*************************************************************************
+  *
+  *  <Function>
+  *     FT_Render_Glyph
+  *
+  *  <Description>
+  *     Converts a given glyph image to a bitmap. It does so by inspecting
+  *     the glyph image format, find the relevant renderer, and invoke it
+  *
+  *  <Input>
+  *     slot        :: handle to the glyph slot containing the image to
+  *                    convert
+  *
+  *     render_mode :: a set of bit flags indicating which kind of bitmap
+  *                    to render. For now, only 'ft_render_mode_anti_alias'
+  *                    is supported by the available renderers, but others
+  *                    could appear later (e.g. LCD or TV optimised)
+  *
+  *  <Return>
+  *     Error code. 0 means success.
+  *
+  *  <Note>
+  *     in case of success, the renderer will be used to convert glyph
+  *     images in the renderer's known format into bitmaps.
+  *
+  *     This doesn't change the current renderer for other formats..
+  *
+  *     The slot's native image should be considered lost after the
+  *     conversion..
+  *
+  *************************************************************************/
+
+  LOCAL_FUNC
+  FT_Error   FT_Render_Glyph_Internal( FT_Library    library,
+                                       FT_GlyphSlot  slot,
+                                       FT_UInt       render_mode )
   {
     FT_Error     error = FT_Err_Ok;
     FT_Renderer  renderer;
 
       
-    if ( slot )
+    /* if it's already a bitmap, no need to do anything */
+    switch (slot->format)
     {
-      FT_Face           face    = slot->face;
-      FT_Library        library = FT_FACE_LIBRARY( face );
-
-
-      /* if it is already a bitmap, no need to do anything */
-      switch ( slot->format )
-      {
-      case ft_glyph_format_bitmap:  /* already a bitmap, don't do anything */
+      case ft_glyph_format_bitmap:   /* already a bitmap, don't do anything */
         break;
-        
+      
       default:
+      {
+        FT_ListNode  node   = 0;
+        FT_Bool      update = 0;
+        
         /* small shortcut for the very common case */
-        if ( slot->format == ft_glyph_format_outline )
+        if (slot->format == ft_glyph_format_outline)
+        {
           renderer = library->cur_renderer;
+          node     = library->renderers.head;
+        }
         else
-          renderer = ft_lookup_renderer( library, slot->format, 0 );
-            
+          renderer = FT_Lookup_Renderer( library, slot->format, &node );
+
         error = FT_Err_Unimplemented_Feature;
-        if ( renderer )
-          error = renderer->render( renderer, slot, render_mode );
+        while (renderer)
+        {
+          error = renderer->render( renderer, slot, render_mode, 0 );
+          if (!error || error != FT_Err_Cannot_Render_Glyph) break;
+
+          /* FT_Err_Cannot_Render_Glyph is returned when the render mode */
+          /* is unsupported by the current renderer for this glyph image */
+          /* format..                                                    */
+          
+          /* now, look for another renderer that supports the same  */
+          /* format..                                              */
+          renderer = FT_Lookup_Renderer( library, slot->format, &node );
+          update   = 1;
+        }
+
+        /* if we changed the current renderer for the glyph image format */
+        /* we need to select it as the next current one..                */
+        if (!error && update && renderer)
+          FT_Set_Renderer( library, renderer, 0, 0 );
       }
     }
-    else
-      error = FT_Err_Invalid_Argument;
     
     return error;
   }
 
+
+
+  FT_EXPORT_FUNC(FT_Error)  FT_Render_Glyph( FT_GlyphSlot  slot,
+                                             FT_UInt       render_mode )
+  {
+    FT_Library   library;
+    
+    if (!slot)
+      return FT_Err_Invalid_Argument;
+      
+    library = FT_FACE_LIBRARY(slot->face);
+    return FT_Render_Glyph_Internal( library, slot, render_mode );
+  }
+
   
   /*************************************************************************/
   /*************************************************************************/
@@ -2904,7 +2943,7 @@
   FT_EXPORT_FUNC( FT_Error )  FT_Done_Library( FT_Library  library )
   {
     FT_Memory  memory;
-    FT_Int     n;
+    FT_UInt    n;
 
 
     if ( !library )
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -604,36 +604,34 @@
                                                  FT_Outline*        outline,
                                                  FT_Raster_Params*  params )
   {
-    FT_Error           error;
-    FT_Renderer        renderer;
+    FT_Error         error;
+    FT_Bool          update   = 0;
+    FT_Renderer      renderer = library->cur_renderer;
+    FT_ListNode      node     = library->renderers.head;
 
-
-    if ( !library )
+    params->source = (void*)outline;
+        
+    error = FT_Err_Cannot_Render_Glyph;
+    while (renderer)
     {
-      error = FT_Err_Invalid_Library_Handle;
-      goto Exit;
-    }
+      error = renderer->raster_render( renderer->raster, params );
+      if (!error || error != FT_Err_Cannot_Render_Glyph) break;
 
-    if ( !outline || !params )
-    {
-      error = FT_Err_Invalid_Argument;
-      goto Exit;
+      /* FT_Err_Cannot_Render_Glyph is returned when the render mode */
+      /* is unsupported by the current renderer for this glyph image */
+      /* format..                                                    */
+      
+      /* now, look for another renderer that supports the same  */
+      /* format..                                              */
+      renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, &node );
+      update   = 1;
     }
 
-    /* retrieve the current outline renderer */
-    renderer = library->cur_renderer;
-    if ( !renderer )
-    {
-      /* XXXX: should use another error code */
-      error = FT_Err_Invalid_Argument;
-      goto Exit;
-    }
-
-    params->source = (void*)outline;
-    
-    error = renderer->raster_render( renderer->raster, params );
-
-  Exit:
+    /* if we changed the current renderer for the glyph image format */
+    /* we need to select it as the next current one..                */
+    if (!error && update && renderer)
+      FT_Set_Renderer( library, renderer, 0, 0 );
+      
     return error;
   }
 
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -853,7 +853,7 @@
 
         FT_GlyphLoader_Add( gloader );
         
-        for ( n = 0; n < num_subglyphs; n++ )
+        for ( n = 0; n < (FT_Int)num_subglyphs; n++ )
         {
           FT_Vector  pp1, pp2;
           FT_Pos     x, y;
@@ -915,13 +915,12 @@
 
           if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) )
           {
-            FT_Int      k = subglyph->arg1;
+            FT_UInt     k = subglyph->arg1;
             FT_UInt     l = subglyph->arg2;
             FT_Vector*  p1;
             FT_Vector*  p2;
 
-
-            if ( start_point + k >= num_base_points          ||
+            if ( start_point + k >= (FT_UInt)num_base_points ||
                                l >= (FT_UInt)num_new_points  )
             {
               error = TT_Err_Invalid_Composite;