/[freetype]/freetype2/src/base/ftglyph.c
ViewVC logotype

Diff of /freetype2/src/base/ftglyph.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.66 by wl, Wed May 11 20:04:35 2005 UTC revision 1.67 by wl, Fri May 20 21:52:18 2005 UTC
# Line 31  Line 31 
31  #include <ft2build.h>  #include <ft2build.h>
32  #include FT_GLYPH_H  #include FT_GLYPH_H
33  #include FT_OUTLINE_H  #include FT_OUTLINE_H
34    #include FT_BITMAP_H
35  #include FT_INTERNAL_OBJECTS_H  #include FT_INTERNAL_OBJECTS_H
36    
37    
# Line 114  Line 115 
115    /*************************************************************************/    /*************************************************************************/
116    /*************************************************************************/    /*************************************************************************/
117    
   static FT_Error  
   ft_bitmap_copy( FT_Memory   memory,  
                   FT_Bitmap*  source,  
                   FT_Bitmap*  target )  
   {  
     FT_Error  error;  
     FT_Int    pitch = source->pitch;  
     FT_ULong  size;  
   
   
     *target = *source;  
   
     if ( pitch < 0 )  
       pitch = -pitch;  
   
     size = (FT_ULong)( pitch * source->rows );  
   
     if ( !FT_ALLOC( target->buffer, size ) )  
       FT_MEM_COPY( target->buffer, source->buffer, size );  
   
     return error;  
   }  
   
   
118    FT_CALLBACK_DEF( FT_Error )    FT_CALLBACK_DEF( FT_Error )
119    ft_bitmap_glyph_init( FT_Glyph      bitmap_glyph,    ft_bitmap_glyph_init( FT_Glyph      bitmap_glyph,
120                          FT_GlyphSlot  slot )                          FT_GlyphSlot  slot )
# Line 145  Line 122 
122      FT_BitmapGlyph  glyph   = (FT_BitmapGlyph)bitmap_glyph;      FT_BitmapGlyph  glyph   = (FT_BitmapGlyph)bitmap_glyph;
123      FT_Error        error   = FT_Err_Ok;      FT_Error        error   = FT_Err_Ok;
124      FT_Library      library = FT_GLYPH( glyph )->library;      FT_Library      library = FT_GLYPH( glyph )->library;
     FT_Memory       memory  = library->memory;  
125    
126    
127      if ( slot->format != FT_GLYPH_FORMAT_BITMAP )      if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
# Line 154  Line 130 
130        goto Exit;        goto Exit;
131      }      }
132    
133      /* grab the bitmap in the slot - do lazy copying whenever possible */      glyph->left = slot->bitmap_left;
134      glyph->bitmap = slot->bitmap;      glyph->top  = slot->bitmap_top;
     glyph->left   = slot->bitmap_left;  
     glyph->top    = slot->bitmap_top;  
135    
136        /* do lazy copying whenever possible */
137      if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )      if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
138        {
139          glyph->bitmap = slot->bitmap;
140        slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;        slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
141        }
142      else      else
143      {      {
144        /* copy the bitmap into a new buffer */        FT_Bitmap_New( &glyph->bitmap );
145        error = ft_bitmap_copy( memory, &slot->bitmap, &glyph->bitmap );        error = FT_Bitmap_Copy( library, &slot->bitmap, &glyph->bitmap );
146      }      }
147    
148    Exit:    Exit:
# Line 176  Line 154 
154    ft_bitmap_glyph_copy( FT_Glyph  bitmap_source,    ft_bitmap_glyph_copy( FT_Glyph  bitmap_source,
155                          FT_Glyph  bitmap_target )                          FT_Glyph  bitmap_target )
156    {    {
157      FT_BitmapGlyph  source = (FT_BitmapGlyph)bitmap_source;      FT_Library      library = bitmap_source->library;
158      FT_BitmapGlyph  target = (FT_BitmapGlyph)bitmap_target;      FT_BitmapGlyph  source  = (FT_BitmapGlyph)bitmap_source;
159      FT_Memory       memory = bitmap_source->library->memory;      FT_BitmapGlyph  target  = (FT_BitmapGlyph)bitmap_target;
160    
161    
162      target->left = source->left;      target->left = source->left;
163      target->top  = source->top;      target->top  = source->top;
164    
165      return ft_bitmap_copy( memory, &source->bitmap, &target->bitmap );      return FT_Bitmap_Copy( library, &source->bitmap, &target->bitmap );
166    }    }
167    
168    
169    FT_CALLBACK_DEF( void )    FT_CALLBACK_DEF( void )
170    ft_bitmap_glyph_done( FT_Glyph  bitmap_glyph )    ft_bitmap_glyph_done( FT_Glyph  bitmap_glyph )
171    {    {
172      FT_BitmapGlyph  glyph  = (FT_BitmapGlyph)bitmap_glyph;      FT_BitmapGlyph  glyph   = (FT_BitmapGlyph)bitmap_glyph;
173      FT_Memory       memory = FT_GLYPH( glyph )->library->memory;      FT_Library      library = FT_GLYPH( glyph )->library;
174    
175    
176      FT_FREE( glyph->bitmap.buffer );      FT_Bitmap_Done( library, &glyph->bitmap );
177    }    }
178    
179    
# Line 261  Line 239 
239      if ( error )      if ( error )
240        goto Exit;        goto Exit;
241    
242      /* copy it */      FT_Outline_Copy( source, target );
     FT_ARRAY_COPY( target->points, source->points, source->n_points );  
   
     FT_ARRAY_COPY( target->tags, source->tags, source->n_points );  
   
     FT_ARRAY_COPY( target->contours, source->contours, source->n_contours );  
   
     /* copy all flags, except the `FT_OUTLINE_OWNER' one */  
     target->flags = source->flags | FT_OUTLINE_OWNER;  
243    
244    Exit:    Exit:
245      return error;      return error;

Legend:
Removed from v.1.66  
changed lines
  Added in v.1.67

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26