* docs/CHANGES: Updated.

* src/base/ftbitmap.c: Don't include FT_FREETYPE_H and FT_IMAGE_H
but FT_BITMAP_H.
(FT_Bitmap_Copy): New function (from ftglyph.c).

* include/freetype/ftbitmap.h (FT_Bitmap_Copy): New public
definition.

* src/base/ftglyph.c: Include FT_BITMAP_H.
(ft_bitmap_copy): Move to ftbitmap.c.
(ft_bitmap_glyph_init): Remove `memory' variable.
Create new bitmap object if FT_GLYPH_OWN_BITMAP isn't set.
(ft_bitmap_glyph_copy): Use FT_Bitmap_Copy.
(ft_bitmap_glyph_done): Use FT_Bitmap_Done.
(ft_outline_glyph_init): Use FT_Outline_Copy.

* src/base/ftoutln.c (FT_Outline_Copy): Handle source == target.
(FT_Outline_Done_Internal): Check for valid `memory' pointer.
(FT_Outline_Translate, FT_Outline_Reverse, FT_Outline_Render,
FT_Outline_Transform): Check for valid `outline' pointer.

* src/base/ftobjs.c (FT_New_GlyphSlot): Prepend glyph slot to
face->glyph, otherwise a new second glyph slot cannot be created.
(FT_Done_GlyphSlot): Fix memory leak.
(FT_Open_Face): Updated -- face->glyph is already managed by
FT_New_GlyphSlot.

* src/type42/t42objs.c (T42_GlyphSlot_Done): Updated.
This commit is contained in:
Werner Lemberg 2005-05-20 21:52:19 +00:00
parent 7f69b656c2
commit 9d1b2e0289
8 changed files with 187 additions and 97 deletions

View File

@ -1,3 +1,37 @@
2005-05-20 Werner Lemberg <wl@gnu.org>
* docs/CHANGES: Updated.
2005-05-20 Chia I Wu <b90201047@ntu.edu.tw>
* src/base/ftbitmap.c: Don't include FT_FREETYPE_H and FT_IMAGE_H
but FT_BITMAP_H.
(FT_Bitmap_Copy): New function (from ftglyph.c).
* include/freetype/ftbitmap.h (FT_Bitmap_Copy): New public
definition.
* src/base/ftglyph.c: Include FT_BITMAP_H.
(ft_bitmap_copy): Move to ftbitmap.c.
(ft_bitmap_glyph_init): Remove `memory' variable.
Create new bitmap object if FT_GLYPH_OWN_BITMAP isn't set.
(ft_bitmap_glyph_copy): Use FT_Bitmap_Copy.
(ft_bitmap_glyph_done): Use FT_Bitmap_Done.
(ft_outline_glyph_init): Use FT_Outline_Copy.
* src/base/ftoutln.c (FT_Outline_Copy): Handle source == target.
(FT_Outline_Done_Internal): Check for valid `memory' pointer.
(FT_Outline_Translate, FT_Outline_Reverse, FT_Outline_Render,
FT_Outline_Transform): Check for valid `outline' pointer.
* src/base/ftobjs.c (FT_New_GlyphSlot): Prepend glyph slot to
face->glyph, otherwise a new second glyph slot cannot be created.
(FT_Done_GlyphSlot): Fix memory leak.
(FT_Open_Face): Updated -- face->glyph is already managed by
FT_New_GlyphSlot.
* src/type42/t42objs.c (T42_GlyphSlot_Done): Updated.
2005-05-20 Kirill Smelkov <kirr@mns.spb.ru>
* include/freetype/ftimage.h (FT_Raster_Params),

View File

@ -60,9 +60,10 @@ LATEST CHANGES BETWEEN 2.1.10 and 2.1.9
for errors in those tables while accessing them.
- A new API in FT_BITMAP_H (`FT_Bitmap_New', `FT_Bitmap_Convert',
`FT_Bitmap_Done') has been added. Its use is to convert
an FT_Bitmap structure in 1bpp, 2bpp, 4bpp, or 8bpp format into
another 8bpp FT_Bitmap, probably using a different pitch.
`FT_Bitmap_Copy', `FT_Bitmap_Done') has been added. Its use is
to convert an FT_Bitmap structure in 1bpp, 2bpp, 4bpp, or 8bpp
format into another 8bpp FT_Bitmap, probably using a different
pitch.
- The method how BDF and PCF bitmap fonts are accessed has been
refined. Formerly, FT_Set_Pixel_Sizes and FT_Set_Char_Size

View File

@ -5,7 +5,7 @@
/* FreeType utility functions for converting 1bpp, 2bpp, 4bpp, and 8bpp */
/* bitmaps into 8bpp format (specification). */
/* */
/* Copyright 2004 by */
/* Copyright 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -66,6 +66,29 @@ FT_BEGIN_HEADER
FT_Bitmap_New( FT_Bitmap *abitmap );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Bitmap_Copy */
/* */
/* <Description> */
/* Copies an bitmap into another one. */
/* */
/* <Input> */
/* source :: A handle to the source bitmap. */
/* */
/* <Output> */
/* target :: A handle to the target bitmap. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Copy( FT_Library library,
const FT_Bitmap *source,
FT_Bitmap *target);
/*************************************************************************/
/* */
/* <Function> */

View File

@ -5,7 +5,7 @@
/* FreeType utility functions for converting 1bpp, 2bpp, 4bpp, and 8bpp */
/* bitmaps into 8bpp format (body). */
/* */
/* Copyright 2004 by */
/* Copyright 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -18,8 +18,7 @@
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_IMAGE_H
#include FT_BITMAP_H
#include FT_INTERNAL_OBJECTS_H
@ -36,6 +35,65 @@
}
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Copy( FT_Library library,
const FT_Bitmap *source,
FT_Bitmap *target)
{
FT_Memory memory = library->memory;
FT_Error error = FT_Err_Ok;
FT_Int pitch = source->pitch;
FT_ULong size;
if ( source == target )
return FT_Err_Ok;
if ( source->buffer == NULL )
{
*target = *source;
return FT_Err_Ok;
}
if ( pitch < 0 )
pitch = -pitch;
size = (FT_ULong)( pitch * source->rows );
if ( target->buffer )
{
FT_Int target_pitch = target->pitch;
FT_ULong target_size;
if ( target_pitch < 0 )
target_pitch = -target_pitch;
target_size = (FT_ULong)( target_pitch * target->rows );
if ( target_size != size )
FT_QREALLOC( target->buffer, target_size, size );
}
else
FT_QALLOC( target->buffer, size );
if ( !error )
{
unsigned char *p;
p = target->buffer;
*target = *source;
target->buffer = p;
FT_MEM_COPY( target->buffer, source->buffer, size );
}
return error;
}
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )

View File

@ -31,6 +31,7 @@
#include <ft2build.h>
#include FT_GLYPH_H
#include FT_OUTLINE_H
#include FT_BITMAP_H
#include FT_INTERNAL_OBJECTS_H
@ -114,30 +115,6 @@
/*************************************************************************/
/*************************************************************************/
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;
}
FT_CALLBACK_DEF( FT_Error )
ft_bitmap_glyph_init( FT_Glyph bitmap_glyph,
FT_GlyphSlot slot )
@ -145,7 +122,6 @@
FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph;
FT_Error error = FT_Err_Ok;
FT_Library library = FT_GLYPH( glyph )->library;
FT_Memory memory = library->memory;
if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
@ -154,17 +130,19 @@
goto Exit;
}
/* grab the bitmap in the slot - do lazy copying whenever possible */
glyph->bitmap = slot->bitmap;
glyph->left = slot->bitmap_left;
glyph->top = slot->bitmap_top;
glyph->left = slot->bitmap_left;
glyph->top = slot->bitmap_top;
/* do lazy copying whenever possible */
if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
{
glyph->bitmap = slot->bitmap;
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
else
{
/* copy the bitmap into a new buffer */
error = ft_bitmap_copy( memory, &slot->bitmap, &glyph->bitmap );
FT_Bitmap_New( &glyph->bitmap );
error = FT_Bitmap_Copy( library, &slot->bitmap, &glyph->bitmap );
}
Exit:
@ -176,26 +154,26 @@
ft_bitmap_glyph_copy( FT_Glyph bitmap_source,
FT_Glyph bitmap_target )
{
FT_BitmapGlyph source = (FT_BitmapGlyph)bitmap_source;
FT_BitmapGlyph target = (FT_BitmapGlyph)bitmap_target;
FT_Memory memory = bitmap_source->library->memory;
FT_Library library = bitmap_source->library;
FT_BitmapGlyph source = (FT_BitmapGlyph)bitmap_source;
FT_BitmapGlyph target = (FT_BitmapGlyph)bitmap_target;
target->left = source->left;
target->top = source->top;
return ft_bitmap_copy( memory, &source->bitmap, &target->bitmap );
return FT_Bitmap_Copy( library, &source->bitmap, &target->bitmap );
}
FT_CALLBACK_DEF( void )
ft_bitmap_glyph_done( FT_Glyph bitmap_glyph )
{
FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph;
FT_Memory memory = FT_GLYPH( glyph )->library->memory;
FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph;
FT_Library library = FT_GLYPH( glyph )->library;
FT_FREE( glyph->bitmap.buffer );
FT_Bitmap_Done( library, &glyph->bitmap );
}
@ -261,15 +239,7 @@
if ( error )
goto Exit;
/* copy it */
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;
FT_Outline_Copy( source, target );
Exit:
return error;

View File

@ -348,11 +348,9 @@
FT_GlyphSlot slot;
if ( !face || !aslot || !face->driver )
if ( !face || !face->driver )
return FT_Err_Invalid_Argument;
*aslot = 0;
driver = face->driver;
clazz = driver->clazz;
memory = driver->root.memory;
@ -370,8 +368,15 @@
goto Exit;
}
*aslot = slot;
slot->next = face->glyph;
face->glyph = slot;
if ( aslot )
*aslot = slot;
}
else if ( aslot )
*aslot = 0;
Exit:
FT_TRACE4(( "FT_New_GlyphSlot: Return %d\n", error ));
@ -386,26 +391,31 @@
{
if ( slot )
{
FT_Driver driver = slot->face->driver;
FT_Memory memory = driver->root.memory;
FT_GlyphSlot* parent;
FT_GlyphSlot cur;
FT_Driver driver = slot->face->driver;
FT_Memory memory = driver->root.memory;
FT_GlyphSlot prev;
FT_GlyphSlot cur;
/* Remove slot from its parent face's list */
parent = &slot->face->glyph;
cur = *parent;
prev = NULL;
cur = slot->face->glyph;
while ( cur )
{
if ( cur == slot )
{
*parent = cur->next;
if ( !prev )
slot->face->glyph = cur->next;
else
prev->next = cur->next;
ft_glyphslot_done( slot );
FT_FREE( slot );
break;
}
cur = cur->next;
prev = cur;
cur = cur->next;
}
}
}
@ -1677,18 +1687,11 @@
FT_List_Add( &face->driver->faces_list, node );
/* now allocate a glyph slot object for the face */
{
FT_GlyphSlot slot;
FT_TRACE4(( "FT_Open_Face: Creating glyph slot\n" ));
FT_TRACE4(( "FT_Open_Face: Creating glyph slot\n" ));
error = FT_New_GlyphSlot( face, &slot );
if ( error )
goto Fail;
face->glyph = slot;
}
error = FT_New_GlyphSlot( face, NULL );
if ( error )
goto Fail;
/* finally, allocate a size object for the face */
{

View File

@ -358,6 +358,9 @@
source->n_contours != target->n_contours )
return FT_Err_Invalid_Argument;
if ( source == target )
return FT_Err_Ok;
FT_ARRAY_COPY( target->points, source->points, source->n_points );
FT_ARRAY_COPY( target->tags, source->tags, source->n_points );
@ -379,7 +382,7 @@
FT_Outline_Done_Internal( FT_Memory memory,
FT_Outline* outline )
{
if ( outline )
if ( memory && outline )
{
if ( outline->flags & FT_OUTLINE_OWNER )
{
@ -472,6 +475,9 @@
FT_Vector* vec = outline->points;
if ( !outline )
return;
for ( n = 0; n < outline->n_points; n++ )
{
vec->x += xOffset;
@ -490,6 +496,9 @@
FT_Int first, last;
if ( !outline )
return;
first = 0;
for ( n = 0; n < outline->n_contours; n++ )
@ -553,7 +562,7 @@
if ( !library )
return FT_Err_Invalid_Library_Handle;
if ( !params )
if ( !outline || !params )
return FT_Err_Invalid_Argument;
renderer = library->cur_renderer;
@ -644,10 +653,16 @@
FT_Outline_Transform( const FT_Outline* outline,
const FT_Matrix* matrix )
{
FT_Vector* vec = outline->points;
FT_Vector* limit = vec + outline->n_points;
FT_Vector* vec;
FT_Vector* limit;
if ( !outline || !matrix )
return;
vec = outline->points;
limit = vec + outline->n_points;
for ( ; vec < limit; vec++ )
FT_Vector_Transform( vec, matrix );
}

View File

@ -4,7 +4,7 @@
/* */
/* Type 42 objects manager (body). */
/* */
/* Copyright 2002, 2003, 2004 by Roberto Alameda. */
/* Copyright 2002, 2003, 2004, 2005 by Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
@ -515,21 +515,7 @@
FT_LOCAL_DEF( void )
T42_GlyphSlot_Done( T42_GlyphSlot slot )
{
FT_Face face = slot->root.face;
T42_Face t42face = (T42_Face)face;
FT_GlyphSlot cur = t42face->ttf_face->glyph;
while ( cur )
{
if ( cur == slot->ttslot )
{
FT_Done_GlyphSlot( slot->ttslot );
break;
}
cur = cur->next;
}
FT_Done_GlyphSlot( slot->ttslot );
}