ref: a8bbc267a20c62806a87c8755e2c4bf58acfc7b5
parent: c06aba285fc2223885288dfaab1cd0a8342ae939
author: Werner Lemberg <[email protected]>
date: Sat Jul 1 10:06:46 EDT 2000
Formatting as usual... Adding trivial argument checking to some functions. Added dynamic driver interface to cidriver. Minor `version' fixes for macfont and psnames modules. Removed unnecessary files
--- a/src/base/ftglyph.c
+++ b/src/base/ftglyph.c
@@ -42,6 +42,7 @@
#undef FT_COMPONENT
#define FT_COMPONENT trace_glyph
+
/*************************************************************************/
/*************************************************************************/
/**** ****/
@@ -51,7 +52,6 @@
/*************************************************************************/
-
/*************************************************************************/
/* */
/* <Function> */
@@ -69,6 +69,9 @@
/* <MT-Note> */
/* Yes. */
/* */
+ /* <Note> */
+ /* The result is undefined if either `a' or `b' is zero. */
+ /* */
FT_EXPORT_FUNC( void ) FT_Matrix_Multiply( FT_Matrix* a,
FT_Matrix* b )
{
@@ -75,6 +78,9 @@
FT_Fixed xx, xy, yx, yy;
+ if ( !a || !b )
+ return;
+
xx = FT_MulFix( a->xx, b->xx ) + FT_MulFix( a->xy, b->yx );
xy = FT_MulFix( a->xx, b->xy ) + FT_MulFix( a->xy, b->yy );
yx = FT_MulFix( a->yx, b->xx ) + FT_MulFix( a->yy, b->yx );
@@ -108,6 +114,9 @@
FT_Pos delta, xx, yy;
+ if ( !matrix )
+ return FT_Err_Invalid_Argument;
+
/* compute discriminant */
delta = FT_MulFix( matrix->xx, matrix->yy ) -
FT_MulFix( matrix->xy, matrix->yx );
@@ -137,57 +146,60 @@
/*************************************************************************/
static
- FT_Error ft_bitmap_copy( FT_Memory memory,
- FT_Bitmap* source,
- FT_Bitmap* target )
+ 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 ( pitch < 0 )
+ pitch = -pitch;
+
+ size = (FT_ULong)( pitch * source->rows );
+
if ( !ALLOC( target->buffer, size ) )
MEM_Copy( source->buffer, target->buffer, size );
-
+
return error;
- }
+ }
static
- FT_Error ft_bitmap_glyph_init( FT_BitmapGlyph glyph,
- FT_GlyphSlot slot )
+ FT_Error ft_bitmap_glyph_init( FT_BitmapGlyph glyph,
+ FT_GlyphSlot slot )
{
- 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)
+ 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 )
{
error = FT_Err_Invalid_Glyph_Format;
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;
-
+
if ( slot->flags & ft_glyph_own_bitmap )
- {
slot->flags &= ~ft_glyph_own_bitmap;
- }
else
{
/* copy the bitmap into a new buffer */
error = ft_bitmap_copy( memory, &slot->bitmap, &glyph->bitmap );
}
-
+
Exit:
return error;
- }
+ }
static
@@ -195,46 +207,50 @@
FT_BitmapGlyph target )
{
FT_Memory memory = source->root.library->memory;
-
- target->left = source->left;
- target->top = source->top;
-
+
+
+ target->left = source->left;
+ target->top = source->top;
+
return ft_bitmap_copy( memory, &source->bitmap, &target->bitmap );
- }
+ }
static
- void ft_bitmap_glyph_done( FT_BitmapGlyph glyph )
+ void ft_bitmap_glyph_done( FT_BitmapGlyph glyph )
{
FT_Memory memory = FT_GLYPH(glyph)->library->memory;
-
+
+
FREE( glyph->bitmap.buffer );
}
static
- void ft_bitmap_glyph_bbox( FT_BitmapGlyph glyph,
- FT_BBox *cbox )
+ void ft_bitmap_glyph_bbox( FT_BitmapGlyph glyph,
+ FT_BBox* cbox )
{
cbox->xMin = glyph->left << 6;
- cbox->xMax = cbox->xMin + (glyph->bitmap.width << 6);
+ cbox->xMax = cbox->xMin + ( glyph->bitmap.width << 6 );
cbox->yMax = glyph->top << 6;
- cbox->yMin = cbox->xMax - (glyph->bitmap.rows << 6);
- }
+ cbox->yMin = cbox->xMax - ( glyph->bitmap.rows << 6 );
+ }
- const FT_Glyph_Class ft_bitmap_glyph_class =
+ const FT_Glyph_Class ft_bitmap_glyph_class =
{
sizeof( FT_BitmapGlyphRec ),
ft_glyph_format_bitmap,
- (FT_Glyph_Init_Func) ft_bitmap_glyph_init,
- (FT_Glyph_Done_Func) ft_bitmap_glyph_done,
- (FT_Glyph_Copy_Func) ft_bitmap_glyph_copy,
- (FT_Glyph_Transform_Func) 0,
- (FT_Glyph_BBox_Func) ft_bitmap_glyph_bbox,
- (FT_Glyph_Prepare_Func) 0
+
+ (FT_Glyph_Init_Func) ft_bitmap_glyph_init,
+ (FT_Glyph_Done_Func) ft_bitmap_glyph_done,
+ (FT_Glyph_Copy_Func) ft_bitmap_glyph_copy,
+ (FT_Glyph_Transform_Func)0,
+ (FT_Glyph_BBox_Func) ft_bitmap_glyph_bbox,
+ (FT_Glyph_Prepare_Func) 0
};
+
/*************************************************************************/
/*************************************************************************/
/**** ****/
@@ -243,30 +259,31 @@
/*************************************************************************/
/*************************************************************************/
-
static
- FT_Error ft_outline_glyph_init( FT_OutlineGlyph glyph,
- FT_GlyphSlot slot )
+ FT_Error ft_outline_glyph_init( FT_OutlineGlyph glyph,
+ FT_GlyphSlot slot )
{
- FT_Error error = FT_Err_Ok;
- FT_Library library = FT_GLYPH(glyph)->library;
- FT_Outline* source = &slot->outline;
- FT_Outline* target = &glyph->outline;
-
+ FT_Error error = FT_Err_Ok;
+ FT_Library library = FT_GLYPH(glyph)->library;
+ FT_Outline* source = &slot->outline;
+ FT_Outline* target = &glyph->outline;
+
+
/* check format in glyph slot */
- if (slot->format != ft_glyph_format_outline)
+ if ( slot->format != ft_glyph_format_outline )
{
error = FT_Err_Invalid_Glyph_Format;
goto Exit;
}
-
+
/* allocate new outline */
error = FT_Outline_New( library, source->n_points, source->n_contours,
&glyph->outline );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
- /* copy it.. */
+ /* copy it */
MEM_Copy( target->points, source->points,
source->n_points * sizeof ( FT_Vector ) );
@@ -281,12 +298,13 @@
Exit:
return error;
- }
+ }
+
static
void ft_outline_glyph_done( FT_OutlineGlyph glyph )
{
- FT_Outline_Done( FT_GLYPH(glyph)->library, &glyph->outline );
+ FT_Outline_Done( FT_GLYPH( glyph )->library, &glyph->outline );
}
@@ -295,34 +313,39 @@
FT_OutlineGlyph target )
{
FT_Error error;
- FT_Library library = FT_GLYPH(source)->library;
-
+ FT_Library library = FT_GLYPH( source )->library;
+
+
error = FT_Outline_New( library, source->outline.n_points,
source->outline.n_contours, &target->outline );
- if (!error)
+ if ( !error )
FT_Outline_Copy( &source->outline, &target->outline );
-
+
return error;
}
+
static
void ft_outline_glyph_transform( FT_OutlineGlyph glyph,
FT_Matrix* matrix,
FT_Vector* delta )
{
- if (matrix)
+ if ( matrix )
FT_Outline_Transform( &glyph->outline, matrix );
- if (delta)
+
+ if ( delta )
FT_Outline_Translate( &glyph->outline, delta->x, delta->y );
}
+
static
void ft_outline_glyph_bbox( FT_OutlineGlyph glyph,
- FT_BBox *bbox )
+ FT_BBox* bbox )
{
FT_Outline_Get_CBox( &glyph->outline, bbox );
- }
+ }
+
static
FT_Error ft_outline_glyph_prepare( FT_OutlineGlyph glyph,
FT_GlyphSlot slot )
@@ -330,21 +353,25 @@
slot->format = ft_glyph_format_outline;
slot->outline = glyph->outline;
slot->outline.flags &= ~ft_outline_owner;
+
return FT_Err_Ok;
- }
+ }
- const FT_Glyph_Class ft_outline_glyph_class =
+
+ const FT_Glyph_Class ft_outline_glyph_class =
{
sizeof( FT_OutlineGlyphRec ),
ft_glyph_format_outline,
- (FT_Glyph_Init_Func) ft_outline_glyph_init,
- (FT_Glyph_Done_Func) ft_outline_glyph_done,
- (FT_Glyph_Copy_Func) ft_outline_glyph_copy,
- (FT_Glyph_Transform_Func) ft_outline_glyph_transform,
- (FT_Glyph_BBox_Func) ft_outline_glyph_bbox,
- (FT_Glyph_Prepare_Func) ft_outline_glyph_prepare
+
+ (FT_Glyph_Init_Func) ft_outline_glyph_init,
+ (FT_Glyph_Done_Func) ft_outline_glyph_done,
+ (FT_Glyph_Copy_Func) ft_outline_glyph_copy,
+ (FT_Glyph_Transform_Func)ft_outline_glyph_transform,
+ (FT_Glyph_BBox_Func) ft_outline_glyph_bbox,
+ (FT_Glyph_Prepare_Func) ft_outline_glyph_prepare
};
+
/*************************************************************************/
/*************************************************************************/
/**** ****/
@@ -354,200 +381,207 @@
/*************************************************************************/
static
- FT_Error ft_new_glyph( FT_Library library,
- const FT_Glyph_Class* clazz,
- FT_Glyph *aglyph )
+ FT_Error ft_new_glyph( FT_Library library,
+ const FT_Glyph_Class* clazz,
+ FT_Glyph* aglyph )
{
FT_Memory memory = library->memory;
FT_Error error;
FT_Glyph glyph;
-
+
+
*aglyph = 0;
+
if ( !ALLOC( glyph, clazz->glyph_size ) )
{
glyph->library = library;
glyph->clazz = clazz;
glyph->format = clazz->glyph_format;
-
+
*aglyph = glyph;
}
+
return error;
- }
+ }
- /***********************************************************************
- *
- * <Function>
- * FT_Glyph_Copy
- *
- * <Description>
- * A function used to copy one glyph image.
- *
- * <Input>
- * source :: handle to source glyph object
- *
- * <Output>
- * target :: handle to target glyph object. 0 in case of error
- *
- * <Return>
- * Error code. 0 means success.
- *
- ***********************************************************************/
-
- FT_EXPORT_FUNC(FT_Error) FT_Glyph_Copy( FT_Glyph source,
- FT_Glyph *target )
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Glyph_Copy */
+ /* */
+ /* <Description> */
+ /* A function used to copy a glyph image. */
+ /* */
+ /* <Input> */
+ /* source :: A handle to the source glyph object. */
+ /* */
+ /* <Output> */
+ /* target :: A handle to the target glyph object. 0 in case of */
+ /* error. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ FT_EXPORT_FUNC( FT_Error ) FT_Glyph_Copy( FT_Glyph source,
+ FT_Glyph* target )
{
FT_Glyph copy;
FT_Error error;
const FT_Glyph_Class* clazz;
- *target = 0;
-
+
/* check arguments */
- if (!source || !source->clazz)
+ if ( !target || !source || !source->clazz )
{
error = FT_Err_Invalid_Argument;
goto Exit;
}
-
+
+ *target = 0;
+
clazz = source->clazz;
error = ft_new_glyph( source->library, clazz, © );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
- if (clazz->glyph_copy)
+ if ( clazz->glyph_copy )
error = clazz->glyph_copy( source, copy );
-
- if (error)
+
+ if ( error )
FT_Done_Glyph( copy );
else
*target = copy;
-
+
Exit:
return error;
- }
+ }
- /***********************************************************************
- *
- * <Function>
- * FT_Get_Glyph
- *
- * <Description>
- * A function used to extract one glyph image from a slot..
- *
- * <Input>
- * slot :: handle to source glyph slot.
- *
- * <Output>
- * aglyph :: handle to the glyph object.
- *
- * <Return>
- * Error code. 0 means success.
- *
- * <Note>
- *
- *
- ***********************************************************************/
-
- FT_EXPORT_FUNC(FT_Error) FT_Get_Glyph( FT_GlyphSlot slot,
- FT_Glyph *aglyph )
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_Glyph */
+ /* */
+ /* <Description> */
+ /* A function used to extract a glyph image from a slot. */
+ /* */
+ /* <Input> */
+ /* slot :: A handle to the source glyph slot. */
+ /* */
+ /* <Output> */
+ /* aglyph :: A handle to the glyph object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ FT_EXPORT_FUNC( FT_Error ) FT_Get_Glyph( FT_GlyphSlot slot,
+ FT_Glyph* aglyph )
{
FT_Library library = slot->library;
FT_Error error;
FT_Glyph glyph;
-
+
const FT_Glyph_Class* clazz = 0;
-
- /* if it's a bitmap, that's easy :-) */
- if (slot->format == ft_glyph_format_bitmap)
+
+
+ if ( !slot )
+ return FT_Err_Invalid_Slot_Handle;
+
+ if ( !glyph )
+ return FT_Err_Invalid_Argument;
+
+ /* if it is a bitmap, that's easy :-) */
+ if ( slot->format == ft_glyph_format_bitmap )
clazz = &ft_bitmap_glyph_class;
- /* it it's an outline too */
- else if (slot->format == ft_glyph_format_outline)
+ /* it it is an outline too */
+ else if ( slot->format == ft_glyph_format_outline )
clazz = &ft_outline_glyph_class;
-
+
else
{
/* try to find a renderer that supports the glyph image format */
FT_Renderer render = FT_Lookup_Renderer( library, slot->format, 0 );
- if (render)
+
+
+ if ( render )
clazz = &render->glyph_class;
}
-
- if (!clazz)
+
+ if ( !clazz )
{
error = FT_Err_Invalid_Glyph_Format;
goto Exit;
}
-
+
/* create FT_Glyph object */
error = ft_new_glyph( library, clazz, &glyph );
- if (error) goto Exit;
-
- /* copy advance while convert it to 16.16 format */
+ if ( error )
+ goto Exit;
+
+ /* copy advance while converting it to 16.16 format */
glyph->advance.x = slot->advance.x << 10;
glyph->advance.y = slot->advance.y << 10;
-
+
/* now import the image from the glyph slot */
error = clazz->glyph_init( glyph, slot );
-
- /* if an error occured, destroy the glyph */
- if (error)
+
+ /* if an error occurred, destroy the glyph */
+ if ( error )
FT_Done_Glyph( glyph );
else
*aglyph = glyph;
-
+
Exit:
return error;
- }
+ }
-
-
- /***********************************************************************
- *
- * <Function>
- * FT_Glyph_Transform
- *
- * <Description>
- * Transforms a glyph image, when it's format is scalable
- *
- * <Input>
- * glyph :: handle to target glyph object
- *
- * matrix :: pointer to 2x2 matrix to apply
- *
- * delta :: pointer to a 2d vector to apply. coordinates are
- * expressed in 1/64th of a pixel..
- *
- * <Return>
- * error code (is not 0, the glyph format is not scalable).
- *
- * <Note>
- * the 2x2 transform matrix is also applied to the glyph's
- * advance vector
- *
- ***********************************************************************/
-
- FT_EXPORT_FUNC(FT_Error) FT_Glyph_Transform( FT_Glyph glyph,
- FT_Matrix* matrix,
- FT_Vector* delta )
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Glyph_Transform */
+ /* */
+ /* <Description> */
+ /* Transforms a glyph image if its format is scalable. */
+ /* */
+ /* <Input> */
+ /* glyph :: A handle to the target glyph object. */
+ /* */
+ /* matrix :: A pointer to a 2x2 matrix to apply. */
+ /* */
+ /* delta :: A pointer to a 2d vector to apply. Coordinates are */
+ /* expressed in 1/64th of a pixel. */
+ /* */
+ /* <Return> */
+ /* FreeType error code (the glyph format is not scalable if it is */
+ /* not zero). */
+ /* */
+ /* <Note> */
+ /* The 2x2 transformation matrix is also applied to the glyph's */
+ /* advance vector. */
+ /*
+ FT_EXPORT_FUNC( FT_Error ) FT_Glyph_Transform( FT_Glyph glyph,
+ FT_Matrix* matrix,
+ FT_Vector* delta )
{
const FT_Glyph_Class* clazz;
FT_Error error = FT_Err_Ok;
-
- if (!glyph || !glyph->clazz)
+
+
+ if ( !glyph || !glyph->clazz )
error = FT_Err_Invalid_Argument;
else
{
clazz = glyph->clazz;
- if (clazz->glyph_transform)
+ if ( clazz->glyph_transform )
{
/* transform glyph image */
clazz->glyph_transform( glyph, matrix, delta );
-
+
/* transform advance vector */
- if (matrix)
+ if ( matrix )
FT_Vector_Transform( &glyph->advance, matrix );
}
else
@@ -554,81 +588,82 @@
error = FT_Err_Invalid_Glyph_Format;
}
return error;
- }
-
- /***********************************************************************
- *
- * <Function>
- * FT_Glyph_Get_CBox
- *
- * <Description>
- * Returns the glyph image's bounding box.
- *
- * <Input>
- * glyph :: handle to source glyph object
- * mode :: a set of bit flags that indicate how to interpret
- * the meaning of the box's coordinates
- *
- * <Output>
- * box :: the glyph bounding box. Coordinates are expressed in
- * 1/64th of pixels, it is grid-fitted..
- *
- * <Note>
- * Coordinates are relative to the glyph origin, using the Y-upwards
- * convention..
- *
- * if 'ft_glyph_bbox_subpixels' is set in "mode", the bbox coordinates
- * are returned in 26.6 pixels (i.e. 1/64th of pixels).
- *
- * otherwise, coordinates are in integer pixels.
- *
- * note that the maximum coordinates are exclusive, which means that
- * once can compute the width and height of the glyph image (be it
- * in integer or 26.6 pixels) as:
- *
- * width = bbox.xMax - bbox.xMin;
- * height = bbox.yMax - bbox.yMin;
- *
- * Note also that for 26.6 coordinates, if the 'ft_glyph_bbox_gridfit'
- * flag is set in "mode", the coordinates will also be grid-fitted,
- * which corresponds to:
- *
- * bbox.xMin = FLOOR(bbox.xMin);
- * bbox.yMin = FLOOR(bbox.yMin);
- * bbox.xMax = CEILING(bbox.xMax);
- * bbox.yMax = CEILING(bbox.yMax);
- *
- ***********************************************************************/
+ }
- FT_EXPORT_FUNC(void) FT_Glyph_Get_CBox( FT_Glyph glyph,
- FT_UInt bbox_mode,
- FT_BBox *cbox )
- {
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Glyph_Get_CBox */
+ /* */
+ /* <Description> */
+ /* Returns the glyph image's bounding box. */
+ /* */
+ /* <Input> */
+ /* glyph :: A handle to the source glyph object. */
+ /* */
+ /* mode :: A set of bit flags that indicate how to interpret the */
+ /* returned bounding box values. */
+ /* */
+ /* <Output> */
+ /* box :: The glyph bounding box. Coordinates are expressed in */
+ /* 1/64th of pixels if it is grid-fitted. */
+ /* */
+ /* <Note> */
+ /* Coordinates are relative to the glyph origin, using the Y-upwards */
+ /* convention. */
+ /* */
+ /* If `ft_glyph_bbox_subpixels' is set in `mode', the bbox */
+ /* coordinates are returned in 26.6 pixels (i.e. 1/64th of pixels). */
+ /* Otherwise, coordinates are expressed in integer pixels. */
+ /* */
+ /* Note that the maximum coordinates are exclusive, which means that */
+ /* one can compute the width and height of the glyph image (be it in */
+ /* integer or 26.6 pixels) as: */
+ /* */
+ /* width = bbox.xMax - bbox.xMin; */
+ /* height = bbox.yMax - bbox.yMin; */
+ /* */
+ /* Note also that for 26.6 coordinates, if the */
+ /* `ft_glyph_bbox_gridfit' flag is set in `mode;, the coordinates */
+ /* will also be grid-fitted, which corresponds to: */
+ /* */
+ /* bbox.xMin = FLOOR(bbox.xMin); */
+ /* bbox.yMin = FLOOR(bbox.yMin); */
+ /* bbox.xMax = CEILING(bbox.xMax); */
+ /* bbox.yMax = CEILING(bbox.yMax); */
+ /* */
+ FT_EXPORT_FUNC( void ) FT_Glyph_Get_CBox( FT_Glyph glyph,
+ FT_UInt bbox_mode,
+ FT_BBox* cbox )
+ {
const FT_Glyph_Class* clazz;
FT_Error error = FT_Err_Ok;
-
- if (!glyph || !glyph->clazz)
+
+
+ if ( !cbox || !glyph || !glyph->clazz )
error = FT_Err_Invalid_Argument;
else
{
clazz = glyph->clazz;
- if (!clazz->glyph_bbox)
+ if ( !clazz->glyph_bbox )
error = FT_Err_Invalid_Glyph_Format;
else
{
/* retrieve bbox in 26.6 coordinates */
clazz->glyph_bbox( glyph, cbox );
-
+
/* perform grid fitting if needed */
- if (bbox_mode & ft_glyph_bbox_gridfit)
+ if ( bbox_mode & ft_glyph_bbox_gridfit )
{
cbox->xMin &= -64;
cbox->yMin &= -64;
- cbox->xMax = (cbox->xMax+63) & -64;
- cbox->yMax = (cbox->yMax+63) & -64;
+ cbox->xMax = ( cbox->xMax + 63 ) & -64;
+ cbox->yMax = ( cbox->yMax + 63 ) & -64;
}
+
/* convert to integer pixels if needed */
- if (!(bbox_mode & ft_glyph_bbox_subpixels))
+ if ( !( bbox_mode & ft_glyph_bbox_subpixels ) )
{
cbox->xMin >>= 6;
cbox->yMin >>= 6;
@@ -641,118 +676,128 @@
}
- /***********************************************************************
- *
- * <Function>
- * FT_Glyph_To_Bitmap
- *
- * <Description>
- * converts a given glyph object to a bitmap glyph object
- *
- * <InOut>
- * glyph :: pointer to a handle to the target glyph
- *
- * <Input>
- * render_mode :: a set of bit flags that describe how
- *
- * origin :: pointer to a vector used to translate the glyph image
- * before rendering. Can be 0 (for no translation). The
- * origin is expressed in 26.6 pixels..
- *
- * destroy :: a boolean that indicates that the original glyph image
- * should be destroyed by this function. The glyph is
- * never destroyed in case of error..
- *
- * <Return>
- * Error code. 0 means success
- *
- * <Note>
- * the glyph image is translated with the "origin" vector before
- * rendering.. In case of error, it it translated back to its original
- * position and the glyph is untouched..
- *
- * The first parameter is a pointer to a FT_Glyph handle, that
- * will be replaced by this function. Typically, you would use:
- *
- * {
- * FT_Glyph glyph;
- * FT_BitmapGlyph glyph_bitmap;
- *
- * // load glyph
- * error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT );
- *
- * // extract glyph image
- * error = FT_Get_Glyph( face->glyph, &glyph );
- *
- * // convert to a bitmap (default render mode + destroy old)
- * if (glyph->format != ft_glyph_format_bitmap)
- * {
- * error = FT_Glyph_To_Bitmap( &glyph, ft_render_mode_default, 0, 1 );
- * if (error) // glyph unchanged..
- * }
- *
- * // access bitmap content by typecasting
- * glyph_bitmap = (FT_BitmapGlyph)glyph;
- *
- * // do funny stuff with it, like blitting/drawing
- * ....
- *
- * // discard glyph image (bitmap or not)
- * FT_Done_Glyph( glyph );
- *
- *
- * This function will always fail if the glyph's format isn't scalable
- *
- ***********************************************************************/
-
- FT_EXPORT_FUNC(FT_Error) FT_Glyph_To_Bitmap( FT_Glyph *the_glyph,
- FT_ULong render_mode,
- FT_Vector* origin,
- FT_Bool destroy )
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Glyph_To_Bitmap */
+ /* */
+ /* <Description> */
+ /* Converts a given glyph object to a bitmap glyph object. */
+ /* */
+ /* <InOut> */
+ /* glyph :: A pointer to a handle to the target glyph. */
+ /* */
+ /* <Input> */
+ /* render_mode :: A set of bit flags that describe how the data is */
+ /* */
+ /* */
+ /* origin :: A pointer to a vector used to translate the glyph */
+ /* image before rendering. Can be 0 (if no */
+ /* translation). The origin is expressed in */
+ /* 26.6 pixels. */
+ /* */
+ /* destroy :: A boolean that indicates that the original glyph */
+ /* image should be destroyed by this function. It is */
+ /* never destroyed in case of error. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* The glyph image is translated with the `origin' vector before */
+ /* rendering. In case of error, it it translated back to its */
+ /* original position and the glyph is left untouched. */
+ /* */
+ /* The first parameter is a pointer to a FT_Glyph handle, that will */
+ /* be replaced by this function. Typically, you would use (omitting */
+ /* error handling): */
+ /* */
+ /* */
+ /* { */
+ /* FT_Glyph glyph; */
+ /* FT_BitmapGlyph glyph_bitmap; */
+ /* */
+ /* */
+ /* // load glyph */
+ /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT ); */
+ /* */
+ /* // extract glyph image */
+ /* error = FT_Get_Glyph( face->glyph, &glyph ); */
+ /* */
+ /* // convert to a bitmap (default render mode + destroy old) */
+ /* if ( glyph->format != ft_glyph_format_bitmap ) */
+ /* { */
+ /* error = FT_Glyph_To_Bitmap( &glyph, ft_render_mode_default, */
+ /* 0, 1 ); */
+ /* if ( error ) // glyph unchanged */
+ /* ... */
+ /* } */
+ /* */
+ /* // access bitmap content by typecasting */
+ /* glyph_bitmap = (FT_BitmapGlyph)glyph; */
+ /* */
+ /* // do funny stuff with it, like blitting/drawing */
+ /* ... */
+ /* */
+ /* // discard glyph image (bitmap or not) */
+ /* FT_Done_Glyph( glyph ); */
+ /* } */
+ /* */
+ /* */
+ /* This function will always fail if the glyph's format isn't */
+ /* scalable. */
+ /* */
+ FT_EXPORT_FUNC( FT_Error ) FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
+ FT_ULong render_mode,
+ FT_Vector* origin,
+ FT_Bool destroy )
{
FT_GlyphSlotRec dummy;
FT_Error error;
FT_Glyph glyph;
FT_BitmapGlyph bitmap;
-
+
const FT_Glyph_Class* clazz;
-
- /* check arguments */
- if (!the_glyph || !*the_glyph)
+
+
+ /* check argument */
+ if ( !the_glyph )
goto Bad;
-
- /* we render the glyph into a glyph bitmap using a "dummy" glyph slot */
- /* then calling FT_Render_Glyph_Internal.. */
-
+
+ /* we render the glyph into a glyph bitmap using a `dummy' glyph slot */
+ /* then calling FT_Render_Glyph_Internal() */
+
glyph = *the_glyph;
- if (!glyph)
+ if ( !glyph )
goto Bad;
-
+
clazz = glyph->clazz;
- if (!clazz || !clazz->glyph_prepare)
+ if ( !clazz || !clazz->glyph_prepare )
goto Bad;
-
- MEM_Set( &dummy, 0, sizeof(dummy) );
+
+ MEM_Set( &dummy, 0, sizeof ( dummy ) );
dummy.library = glyph->library;
dummy.format = clazz->glyph_format;
-
- /* if "origin" is set, translate the glyph image */
- if (origin)
+
+ /* if `origin' is set, translate the glyph image */
+ if ( origin )
FT_Glyph_Transform( glyph, 0, origin );
- /* create result bitmap glyph */
+ /* create result bitmap glyph */
error = ft_new_glyph( glyph->library, &ft_bitmap_glyph_class,
(FT_Glyph*)&bitmap );
- if (error) goto Exit;
-
+ if ( error )
+ goto Exit;
+
/* prepare dummy slot for rendering */
error = clazz->glyph_prepare( glyph, &dummy ) ||
FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode );
-
- if (!destroy && origin)
+
+ if ( !destroy && origin )
{
FT_Vector v;
-
+
+
v.x = -origin->x;
v.y = -origin->y;
FT_Glyph_Transform( glyph, 0, &v );
@@ -759,59 +804,59 @@
}
/* in case of succes, copy the bitmap to the glyph bitmap */
- if (!error)
+ if ( !error )
{
error = ft_bitmap_glyph_init( bitmap, &dummy );
- if (error)
+ if ( error )
{
- /* thus should never happen, but let's be safe.. */
- FT_Done_Glyph( FT_GLYPH(bitmap) );
+ /* this should never happen, but let's be safe */
+ FT_Done_Glyph( FT_GLYPH( bitmap ) );
goto Exit;
}
-
- if (destroy)
+
+ if ( destroy )
FT_Done_Glyph( glyph );
-
- *the_glyph = FT_GLYPH(bitmap);
+
+ *the_glyph = FT_GLYPH( bitmap );
}
-
+
Exit:
return error;
-
+
Bad:
error = FT_Err_Invalid_Argument;
goto Exit;
- }
+ }
- /***********************************************************************
- *
- * <Function>
- * FT_Done_Glyph
- *
- * <Description>
- * Destroys a given glyph..
- *
- * <Input>
- * glyph :: handle to target glyph object
- *
- ***********************************************************************/
- FT_EXPORT_FUNC(void) FT_Done_Glyph( FT_Glyph glyph )
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Done_Glyph */
+ /* */
+ /* <Description> */
+ /* Destroys a given glyph. */
+ /* */
+ /* <Input> */
+ /* glyph :: A handle to the target glyph object. */
+ /* */
+ FT_EXPORT_FUNC( void ) FT_Done_Glyph( FT_Glyph glyph )
{
- if (glyph)
+ if ( glyph )
{
FT_Memory memory = glyph->library->memory;
const FT_Glyph_Class* clazz = glyph->clazz;
- if (clazz->glyph_done)
+
+ if ( clazz->glyph_done )
clazz->glyph_done( glyph );
-
+
FREE( glyph );
}
}
-
+#if 0
/*************************************************************************/
/*************************************************************************/
@@ -820,8 +865,6 @@
/**** ****/
/*************************************************************************/
/*************************************************************************/
-
-#if 0
/* Compute the norm of a vector */
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -664,6 +664,7 @@
FT_Memory memory = driver->root.memory;
FT_Error error = FT_Err_Ok;
+
slot->library = driver->root.library;
if ( FT_DRIVER_USES_OUTLINES( driver ) )
@@ -2040,8 +2041,9 @@
/* */
/* right_glyph :: The index of the right glyph in the kern pair. */
/* */
- /* kern_mode :: see FT_Kerning_Mode for more info. Determines the */
- /* scale/dimension of the returned kerning vector */
+ /* kern_mode :: See FT_Kerning_Mode() for more information. */
+ /* Determines the scale/dimension of the returned */
+ /* kerning vector. */
/* */
/* <Output> */
/* kerning :: The kerning vector. This is in font units for */
@@ -2057,16 +2059,17 @@
/* kernings, are out of the scope of this API function -- they can be */
/* implemented through format-specific interfaces. */
/* */
- FT_EXPORT_FUNC(FT_Error) FT_Get_Kerning( FT_Face face,
- FT_UInt left_glyph,
- FT_UInt right_glyph,
- FT_UInt kern_mode,
- FT_Vector* kerning )
+ FT_EXPORT_FUNC( FT_Error ) FT_Get_Kerning( FT_Face face,
+ FT_UInt left_glyph,
+ FT_UInt right_glyph,
+ FT_UInt kern_mode,
+ FT_Vector* kerning )
{
FT_Error error = FT_Err_Ok;
FT_Driver driver;
FT_Memory memory;
+
if ( !face )
return FT_Err_Invalid_Face_Handle;
@@ -2083,17 +2086,17 @@
right_glyph,
kerning );
}
- if (!error)
+ if ( !error )
{
- if (kern_mode != ft_kerning_unscaled)
+ if ( kern_mode != ft_kerning_unscaled )
{
kerning->x = FT_MulFix( kerning->x, face->size->metrics.x_scale );
kerning->y = FT_MulFix( kerning->y, face->size->metrics.y_scale );
- if (kern_mode != ft_kerning_unfitted)
+ if ( kern_mode != ft_kerning_unfitted )
{
- kerning->x = (kerning->x+32) & -64;
- kerning->y = (kerning->y+32) & -64;
+ kerning->x = ( kerning->x + 32 ) & -64;
+ kerning->y = ( kerning->y + 32 ) & -64;
}
}
}
@@ -2617,9 +2620,9 @@
/* slot :: A handle to the glyph slot containing the image to */
/* convert. */
/* */
- /* render_mode :: this is the render mode used to render the glyph */
- /* image into a bitmap. See FT_Render_Mode for a list */
- /* of possible values. */
+ /* render_mode :: This is the render mode used to render the glyph */
+ /* image into a bitmap. See FT_Render_Mode() for a */
+ /* list of possible values. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -815,6 +815,7 @@
FT_Vector* vec = outline->points;
FT_Vector* limit = vec + outline->n_points;
+
for ( ; vec < limit; vec++ )
FT_Vector_Transform( vec, matrix );
}
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -22,6 +22,7 @@
#include <freetype/internal/ftstream.h>
#include <freetype/ftoutln.h>
+
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -862,7 +863,7 @@
if ( ip[0] != 12 || ip[1] != 17 )
{
FT_ERROR(( "CID_Parse_CharStrings:" ));
- FT_ERROR(( " 'pop' expected, found (%d %d)\n",
+ FT_ERROR(( " `pop' expected, found (%d %d)\n",
ip[0], ip[1] ));
goto Syntax_Error;
}
--- a/src/cid/cidparse.h
+++ b/src/cid/cidparse.h
@@ -62,7 +62,7 @@
/* memory :: The memory object used for memory operations */
/* (allocation resp. reallocation). */
/* */
- typedef struct CID_Table_
+ typedef struct CID_Table_
{
FT_Byte* block; /* current memory block */
FT_Int cursor; /* current cursor in memory block */
@@ -81,8 +81,8 @@
LOCAL_DEF
FT_Error CID_New_Table( CID_Table* table,
- FT_Int count,
- CID_Memory memory );
+ FT_Int count,
+ CID_Memory memory );
LOCAL_DEF
FT_Error CID_Add_Table( CID_Table* table,
@@ -168,15 +168,15 @@
FT_Long CID_ToInt( CID_Parser* parser );
LOCAL_DEF
- FT_Int CID_ToCoordArray( CID_Parser* parser,
- FT_Int max_coords,
- FT_Short* coords );
+ FT_Int CID_ToCoordArray( CID_Parser* parser,
+ FT_Int max_coords,
+ FT_Short* coords );
LOCAL_DEF
- FT_Int CID_ToFixedArray( CID_Parser* parser,
- FT_Int max_values,
- FT_Fixed* values,
- FT_Int power_ten );
+ FT_Int CID_ToFixedArray( CID_Parser* parser,
+ FT_Int max_values,
+ FT_Fixed* values,
+ FT_Int power_ten );
LOCAL_DEF
void CID_Skip_Spaces( CID_Parser* parser );
@@ -183,7 +183,7 @@
/* simple enumeration type used to identify token types */
- typedef enum CID_Token_Type_
+ typedef enum CID_Token_Type_
{
t1_token_none = 0,
t1_token_any,
@@ -197,7 +197,7 @@
/* a simple structure used to identify tokens */
- typedef struct CID_Token_Rec_
+ typedef struct CID_Token_Rec_
{
FT_Byte* start; /* first character of token in input stream */
FT_Byte* limit; /* first character after the token */
@@ -207,12 +207,12 @@
LOCAL_DEF
- void CID_ToToken( CID_Parser* parser,
+ void CID_ToToken( CID_Parser* parser,
CID_Token_Rec* token );
/* enumeration type used to identify object fields */
- typedef enum CID_Field_Type_
+ typedef enum CID_Field_Type_
{
t1_field_none = 0,
t1_field_bool,
@@ -228,7 +228,7 @@
} CID_Field_Type;
- typedef enum CID_Field_Location_
+ typedef enum CID_Field_Location_
{
t1_field_cid_info,
t1_field_font_dict,
@@ -245,7 +245,7 @@
CID_Parser* parser );
/* structure type used to model object fields */
- typedef struct CID_Field_Rec_
+ typedef struct CID_Field_Rec_
{
const char* ident; /* field identifier */
CID_Field_Location location;
@@ -313,19 +313,19 @@
#define CID_FIELD_NUM_TABLE( _ident, _fname, _fmax ) \
CID_NEW_TABLE_FIELD( _ident, t1_field_integer_array, \
- _fname, _fmax )
+ _fname, _fmax )
#define CID_FIELD_FIXED_TABLE( _ident, _fname, _fmax ) \
CID_NEW_TABLE_FIELD( _ident, t1_field_fixed_array, \
- _fname, _fmax )
+ _fname, _fmax )
#define CID_FIELD_NUM_TABLE2( _ident, _fname, _fmax ) \
CID_NEW_TABLE_FIELD2( _ident, t1_field_integer_array, \
- _fname, _fmax )
+ _fname, _fmax )
#define CID_FIELD_FIXED_TABLE2( _ident, _fname, _fmax ) \
CID_NEW_TABLE_FIELD2( _ident, t1_field_fixed_array, \
- _fname, _fmax )
+ _fname, _fmax )
#define CID_FIELD_CALLBACK( _ident, _name ) \
CID_NEW_CALLBACK_FIELD( _ident, parse_ ## _name )
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -47,7 +47,7 @@
}
-#if 0 /* unimplemented for now.. */
+#if 0 /* unimplemented yet */
static
FT_Error cid_Get_Kerning( T1_Face face,
@@ -174,7 +174,7 @@
const FT_Driver_Class t1cid_driver_class =
{
- /* firs of all, the FT_Module_Class fields */
+ /* first of all, the FT_Module_Class fields */
{
ft_module_font_driver | ft_module_driver_scalable,
sizeof( FT_DriverRec ),
@@ -213,6 +213,37 @@
(FTDriver_getAdvances) 0
};
+
+
+#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* getDriverClass */
+ /* */
+ /* <Description> */
+ /* This function is used when compiling the TrueType driver as a */
+ /* shared library (`.DLL' or `.so'). It will be used by the */
+ /* high-level library of FreeType to retrieve the address of the */
+ /* driver's generic interface. */
+ /* */
+ /* It shouldn't be implemented in a static build, as each driver must */
+ /* have the same function as an exported entry point. */
+ /* */
+ /* <Return> */
+ /* The address of the TrueType's driver generic interface. The */
+ /* format-specific interface can then be retrieved through the method */
+ /* interface->get_format_interface. */
+ /* */
+ EXPORT_FUNC( FT_Driver_Class* ) getDriverClass( void )
+ {
+ return &t1cid_driver_class;
+ }
+
+
+#endif /* CONFIG_OPTION_DYNAMIC_DRIVERS */
/* END */
--- a/src/cid/cidtokens.h
+++ b/src/cid/cidtokens.h
@@ -74,19 +74,19 @@
#define T1TYPE T1_Private
#define T1CODE t1_field_private
- CID_FIELD_NUM ( "UniqueID", unique_id )
- CID_FIELD_NUM ( "lenIV", lenIV )
- CID_FIELD_NUM ( "LanguageGroup", language_group )
- CID_FIELD_NUM ( "password", password )
+ CID_FIELD_NUM ( "UniqueID", unique_id )
+ CID_FIELD_NUM ( "lenIV", lenIV )
+ CID_FIELD_NUM ( "LanguageGroup", language_group )
+ CID_FIELD_NUM ( "password", password )
- CID_FIELD_FIXED ( "BlueScale", blue_scale )
- CID_FIELD_NUM ( "BlueShift", blue_shift )
- CID_FIELD_NUM ( "BlueFuzz", blue_fuzz )
+ CID_FIELD_FIXED ( "BlueScale", blue_scale )
+ CID_FIELD_NUM ( "BlueShift", blue_shift )
+ CID_FIELD_NUM ( "BlueFuzz", blue_fuzz )
- CID_FIELD_NUM_TABLE( "BlueValues", blue_values, 14 )
- CID_FIELD_NUM_TABLE( "OtherBlues", other_blues, 10 )
- CID_FIELD_NUM_TABLE( "FamilyBlues", family_blues, 14 )
- CID_FIELD_NUM_TABLE( "FamilyOtherBlues", family_other_blues, 10 )
+ CID_FIELD_NUM_TABLE ( "BlueValues", blue_values, 14 )
+ CID_FIELD_NUM_TABLE ( "OtherBlues", other_blues, 10 )
+ CID_FIELD_NUM_TABLE ( "FamilyBlues", family_blues, 14 )
+ CID_FIELD_NUM_TABLE ( "FamilyOtherBlues", family_other_blues, 10 )
CID_FIELD_NUM_TABLE2( "StdHW", standard_width, 1 )
CID_FIELD_NUM_TABLE2( "StdVW", standard_height, 1 )
--- a/src/cid/rules.mk
+++ b/src/cid/rules.mk
@@ -31,10 +31,10 @@
# CID driver sources (i.e., C files)
#
-CID_DRV_SRC := $(CID_DIR_)cidparse.c \
- $(CID_DIR_)cidload.c \
- $(CID_DIR_)cidriver.c \
- $(CID_DIR_)cidgload.c \
+CID_DRV_SRC := $(CID_DIR_)cidparse.c \
+ $(CID_DIR_)cidload.c \
+ $(CID_DIR_)cidriver.c \
+ $(CID_DIR_)cidgload.c \
$(CID_DIR_)cidobjs.c
# CID driver headers
--- a/src/macfond/fonddrvr.c
+++ b/src/macfond/fonddrvr.c
@@ -514,8 +514,8 @@
sizeof ( FT_DriverRec ),
"fond", /* driver name */
- 100, /* driver version == 1.0 */
- 200, /* driver requires FreeType 2.0 or above */
+ 0x10000L, /* driver version == 1.0 */
+ 0x20000L, /* driver requires FreeType 2.0 or above */
(void*)0,
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -20,7 +20,7 @@
#include <freetype/internal/ftobjs.h>
#include <psmodule.h>
-#include <stdlib.h>
+#include <stdlib.h> /* for qsort() */
#include <string.h> /* for strcmp(), strncpy() */
@@ -27,8 +27,8 @@
#ifndef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
- /* see the python script `freetype2/docs/glnames.py' which is used */
- /* to generate the following tables... */
+ /* see the Python script `freetype2/docs/glnames.py' which is used */
+ /* to generate the following file */
#include <pstables.h>
@@ -53,7 +53,12 @@
glyph_name[1] == 'n' &&
glyph_name[2] == 'i' )
{
- /* determine wether the following characters are hexadecimal */
+ /* determine whether the next four characters following are */
+ /* hexadecimal. */
+
+ /* XXX: Add code to deal with ligatures, i.e. glyph names like */
+ /* `uniXXXXYYYYZZZZ'... */
+
FT_Int count;
FT_ULong value = 0;
const char* p = glyph_name + 4;
@@ -74,11 +79,13 @@
else
d += 10;
}
- /* exit if a non-uppercase-hexadecimal character was found */
+
+ /* exit if a non-uppercase hexadecimal character was found */
if ( d >= 16 )
break;
value = ( value << 4 ) + d;
+
if ( count == 0 )
return value;
}
@@ -92,8 +99,10 @@
p = glyph_name;
+
while ( *p && *p != '.' )
p++;
+
len = p - glyph_name;
if ( *p && len < 64 )
@@ -104,7 +113,7 @@
}
}
- /* now, lookup the glyph in the Adobe Glyph List */
+ /* now, look up the glyph in the Adobe Glyph List */
for ( n = 0; n < NUM_ADOBE_GLYPHS; n++ )
{
const char* name = t1_standard_glyphs[n];
@@ -156,6 +165,7 @@
map = table->maps;
+
for ( n = 0; n < num_glyphs; n++ )
{
const char* gname = glyph_names[n];
@@ -164,6 +174,7 @@
if ( gname )
{
uni_char = PS_Unicode_Value( gname );
+
if ( uni_char && uni_char != 0xFFFF )
{
map->unicode = uni_char;
@@ -175,6 +186,7 @@
/* now, compress the table a bit */
count = map - table->maps;
+
if ( count > 0 && REALLOC( table->maps,
num_glyphs * sizeof ( PS_UniMap ),
count * sizeof ( PS_UniMap ) ) )
@@ -205,6 +217,7 @@
/* perform a binary search on the table */
+
min = table->maps;
max = min + table->num_maps - 1;
@@ -280,8 +293,8 @@
sizeof( FT_ModuleRec ),
"psnames", /* driver name */
- 100, /* driver version */
- 200, /* driver requires FreeType 2 or above */
+ 0x10000L, /* driver version */
+ 0x20000L, /* driver requires FreeType 2 or above */
#ifdef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
0,
--- a/src/psnames/psnames.c
+++ b/src/psnames/psnames.c
@@ -1,2 +1,24 @@
+/***************************************************************************/
+/* */
+/* psnames.c */
+/* */
+/* FreeType PSNames module component (body only). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
#define FT_MAKE_OPTION_SINGLE_OBJECT
+
#include <psmodule.c>
+
+
+/* END */
--- a/src/raster1/ftraster.c
+++ b/src/raster1/ftraster.c
@@ -28,7 +28,8 @@
/*************************************************************************/
/* */
- /* A simple technical note on how the raster works: */
+ /* A simple technical note on how the raster works */
+ /* ----------------------------------------------- */
/* */
/* Converting an outline into a bitmap is achieved in several steps: */
/* */
@@ -60,7 +61,7 @@
/* */
/* ^ ^ */
/* | | */
- /* start of render pool top */
+ /* start of render pool top */
/* */
/* The top of the profile stack is kept in the `top' variable. */
/* */
@@ -84,7 +85,7 @@
/* */
/* ^ ^ */
/* | | */
- /* maxBuff sizeBuff = end of pool */
+ /* maxBuff sizeBuff = end of pool */
/* */
/* This list is later used during the sweep phase in order to */
/* optimize performance (see technical note on the sweep below). */
@@ -176,7 +177,7 @@
#define Raster_Err_Gray_Unsupported -5
#define Raster_Err_Unsupported -6
- /* FMulDiv means `Fast MulDiv', it is used in case where `b' is */
+ /* FMulDiv means `Fast MulDiv'; it is used in case where `b' is */
/* typically a small value and the result of a*b is known to fit into */
/* 32 bits. */
#define FMulDiv( a, b, c ) ( (a) * (b) / (c) )
@@ -303,6 +304,7 @@
#ifdef TT_STATIC_RASTER
+
#define RAS_ARGS /* void */
#define RAS_ARG /* void */
@@ -311,8 +313,10 @@
#define UNUSED_RASTER do ; while ( 0 )
+
#else /* TT_STATIC_RASTER */
+
#define RAS_ARGS TRaster_Instance* raster,
#define RAS_ARG TRaster_Instance* raster
@@ -321,6 +325,7 @@
#define UNUSED_RASTER UNUSED( raster )
+
#endif /* TT_STATIC_RASTER */
@@ -394,6 +399,7 @@
PProfile fProfile; /* head of linked list of profiles */
PProfile gProfile; /* contour's first profile in case */
/* of impact */
+
TStates state; /* rendering state */
FT_Bitmap target; /* description of target bit/pixmap */
@@ -422,6 +428,7 @@
/* Render_Glyph. Note that there is */
/* no horizontal pass during gray */
/* rendering. */
+
TPoint arcs[2 * MaxBezier + 1]; /* The Bezier stack */
TBand band_stack[16]; /* band stack used for sub-banding */
@@ -442,6 +449,7 @@
/* graylevels pixmaps. */
/* gray_lines is a buffer holding two */
/* monochrome scanlines */
+
Short gray_width; /* width in bytes of one monochrome */
/* intermediate scanline of gray_lines. */
/* Each gray pixel takes 2 bits long there */
@@ -779,7 +787,7 @@
static
void Split_Conic( TPoint* base )
{
- Long a, b;
+ Long a, b;
base[4].x = base[2].x;
@@ -794,8 +802,8 @@
b = base[1].y = ( base[0].y + b ) / 2;
base[2].y = ( a + b ) / 2;
- /* hand optimized. gcc doesn't seem too good at common expression */
- /* substitution and instruction scheduling ;-) */
+ /* hand optimized. gcc doesn't seem to be too good at common */
+ /* expression substitution and instruction scheduling ;-) */
}
@@ -867,9 +875,12 @@
/* SUCCESS on success, FAILURE on render pool overflow. */
/* */
static
- Bool Line_Up( RAS_ARGS Long x1, Long y1,
- Long x2, Long y2,
- Long miny, Long maxy )
+ Bool Line_Up( RAS_ARGS Long x1,
+ Long y1,
+ Long x2,
+ Long y2,
+ Long miny,
+ Long maxy )
{
Long Dx, Dy;
Int e1, e2, f1, f2, size; /* XXX: is `Short' sufficient? */
@@ -1003,9 +1014,12 @@
/* SUCCESS on success, FAILURE on render pool overflow. */
/* */
static
- Bool Line_Down( RAS_ARGS Long x1, Long y1,
- Long x2, Long y2,
- Long miny, Long maxy )
+ Bool Line_Down( RAS_ARGS Long x1,
+ Long y1,
+ Long x2,
+ Long y2,
+ Long miny,
+ Long maxy )
{
Bool result, fresh;
@@ -1275,8 +1289,8 @@
switch ( ras.state )
{
case Ascending:
- if ( Line_Up ( RAS_VARS ras.lastX, ras.lastY,
- x, y, ras.minY, ras.maxY ) )
+ if ( Line_Up( RAS_VARS ras.lastX, ras.lastY,
+ x, y, ras.minY, ras.maxY ) )
return FAILURE;
break;
@@ -1498,7 +1512,7 @@
}
else
{
- state_bez = y1 <= y4 ? Ascending : Descending;
+ state_bez = ( y1 <= y4 ) ? Ascending : Descending;
/* detect a change of direction */
if ( ras.state != state_bez )
@@ -1659,60 +1673,58 @@
}
case FT_Curve_Tag_Conic: /* consume conic arcs */
- {
- v_control.x = SCALED( point[0].x );
- v_control.y = SCALED( point[0].y );
+ v_control.x = SCALED( point[0].x );
+ v_control.y = SCALED( point[0].y );
- if ( flipped )
- SWAP_( v_control.x, v_control.y );
+ if ( flipped )
+ SWAP_( v_control.x, v_control.y );
- Do_Conic:
- if ( point < limit )
- {
- FT_Vector v_middle;
- Long x, y;
+ Do_Conic:
+ if ( point < limit )
+ {
+ FT_Vector v_middle;
+ Long x, y;
- point++;
- tags++;
- tag = FT_CURVE_TAG( tags[0] );
+ point++;
+ tags++;
+ tag = FT_CURVE_TAG( tags[0] );
- x = SCALED( point[0].x );
- y = SCALED( point[0].y );
+ x = SCALED( point[0].x );
+ y = SCALED( point[0].y );
- if ( flipped )
- SWAP_( x, y );
+ if ( flipped )
+ SWAP_( x, y );
- if ( tag == FT_Curve_Tag_On )
- {
- if ( Conic_To( RAS_VARS v_control.x, v_control.y, x, y ) )
- goto Fail;
- continue;
- }
-
- if ( tag != FT_Curve_Tag_Conic )
- goto Invalid_Outline;
-
- v_middle.x = ( v_control.x + x ) / 2;
- v_middle.y = ( v_control.y + y ) / 2;
-
- if ( Conic_To( RAS_VARS v_control.x, v_control.y,
- v_middle.x, v_middle.y ) )
+ if ( tag == FT_Curve_Tag_On )
+ {
+ if ( Conic_To( RAS_VARS v_control.x, v_control.y, x, y ) )
goto Fail;
+ continue;
+ }
- v_control.x = x;
- v_control.y = y;
+ if ( tag != FT_Curve_Tag_Conic )
+ goto Invalid_Outline;
- goto Do_Conic;
- }
+ v_middle.x = ( v_control.x + x ) / 2;
+ v_middle.y = ( v_control.y + y ) / 2;
if ( Conic_To( RAS_VARS v_control.x, v_control.y,
- v_start.x, v_start.y ) )
+ v_middle.x, v_middle.y ) )
goto Fail;
- goto Close;
+ v_control.x = x;
+ v_control.y = y;
+
+ goto Do_Conic;
}
+ if ( Conic_To( RAS_VARS v_control.x, v_control.y,
+ v_start.x, v_start.y ) )
+ goto Fail;
+
+ goto Close;
+
default: /* FT_Curve_Tag_Cubic */
{
Long x1, y1, x2, y2, x3, y3;
@@ -2005,8 +2017,8 @@
/* */
/* Vertical Sweep Procedure Set */
/* */
- /* These four routines are used during the vertical black/white */
- /* sweep phase by the generic Draw_Sweep() function. */
+ /* These four routines are used during the vertical black/white sweep */
+ /* phase by the generic Draw_Sweep() function. */
/* */
/*************************************************************************/
@@ -2057,14 +2069,16 @@
if ( e2 >= 0 && e1 < ras.bWidth )
{
- if ( e1 < 0 ) e1 = 0;
- if ( e2 >= ras.bWidth ) e2 = ras.bWidth - 1;
+ if ( e1 < 0 )
+ e1 = 0;
+ if ( e2 >= ras.bWidth )
+ e2 = ras.bWidth - 1;
c1 = (Short)( e1 >> 3 );
c2 = (Short)( e2 >> 3 );
- f1 = (unsigned char)0xFF >> ( e1 & 7 );
- f2 = ~((unsigned char)0x7F >> ( e2 & 7 ));
+ f1 = (unsigned char)0xFF >> ( e1 & 7 );
+ f2 = ~( (unsigned char)0x7F >> ( e2 & 7 ) );
if ( ras.gray_min_x > c1 ) ras.gray_min_x = c1;
if ( ras.gray_max_x < c2 ) ras.gray_max_x = c2;
@@ -2447,6 +2461,7 @@
Int last_bit = last_pixel & 3;
Bool over = 0;
+
if ( ras.gray_max_x >= last_cell && last_bit != 3 )
{
ras.gray_max_x = last_cell - 1;
@@ -2625,13 +2640,13 @@
static
Bool Draw_Sweep( RAS_ARG )
{
- Short y, y_change, y_height;
+ Short y, y_change, y_height;
- PProfile P, Q, P_Left, P_Right;
+ PProfile P, Q, P_Left, P_Right;
- Short min_Y, max_Y, top, bottom, dropouts;
+ Short min_Y, max_Y, top, bottom, dropouts;
- Long x1, x2, xs, e1, e2;
+ Long x1, x2, xs, e1, e2;
TProfileList wait;
TProfileList draw_left, draw_right;
@@ -2647,8 +2662,8 @@
/* first, compute min and max Y */
P = ras.fProfile;
- max_Y = (short)TRUNC( ras.minY );
- min_Y = (short)TRUNC( ras.maxY );
+ max_Y = (Short)TRUNC( ras.minY );
+ min_Y = (Short)TRUNC( ras.maxY );
while ( P )
{
@@ -2783,9 +2798,9 @@
P_Right = P_Right->link;
}
- /* now perform the dropouts _after_ the span drawing */
- /* drop-outs processing has been moved out of the loop */
- /* for performance tuning */
+ /* now perform the dropouts _after_ the span drawing -- */
+ /* drop-outs processing has been moved out of the loop */
+ /* for performance tuning */
if ( dropouts > 0 )
goto Scan_DropOuts;
@@ -3032,7 +3047,6 @@
ras.dropOutControl = 2;
ras.second_pass = !( ras.outline.flags & ft_outline_single_pass );
-
/* Vertical Sweep */
ras.band_top = 0;
@@ -3055,7 +3069,7 @@
ras.Proc_Sweep_Step = Vertical_Gray_Sweep_Step;
error = Render_Single_Pass( RAS_VARS 0 );
- if (error)
+ if ( error )
return error;
/* Horizontal Sweep */
@@ -3071,7 +3085,7 @@
ras.band_stack[0].y_max = ras.target.width * 2 - 1;
error = Render_Single_Pass( RAS_VARS 1 );
- if (error)
+ if ( error )
return error;
}
@@ -3084,10 +3098,11 @@
FT_Error Render_Gray_Glyph( RAS_ARG )
{
UNUSED_RASTER;
+
return FT_Err_Cannot_Render_Glyph;
}
-#endif
+#endif /* FT_RASTER_OPTION_ANTI_ALIASING */
static
@@ -3096,6 +3111,7 @@
FT_UInt n;
FT_ULong c;
+
/* setup count table */
for ( n = 0; n < 256; n++ )
{
@@ -3110,23 +3126,27 @@
}
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
+
/* set default 5-levels gray palette */
for ( n = 0; n < 5; n++ )
raster->grays[n] = n * 255 / 4;
raster->gray_width = RASTER_GRAY_LINES / 2;
+
#endif
}
+
/**** RASTER OBJECT CREATION: In standalone mode, we simply use *****/
/**** a static object. *****/
+
#ifdef _STANDALONE_
static
- int ft_black_new( void* memory,
- FT_Raster *araster )
+ int ft_black_new( void* memory,
+ FT_Raster *araster )
{
static FT_RasterRec_ the_raster;
@@ -3183,9 +3203,9 @@
static
- void ft_black_reset( TRaster_Instance* raster,
- const char* pool_base,
- long pool_size )
+ void ft_black_reset( TRaster_Instance* raster,
+ const char* pool_base,
+ long pool_size )
{
if ( raster && pool_base && pool_size >= 4096 )
{
@@ -3202,6 +3222,7 @@
const char* palette )
{
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
+
if ( mode == FT_MAKE_TAG( 'p', 'a', 'l', '5' ) )
{
/* set 5-levels gray palette */
@@ -3211,10 +3232,13 @@
raster->grays[3] = palette[3];
raster->grays[4] = palette[4];
}
+
#else
- UNUSED(raster);
- UNUSED(mode);
- UNUSED(palette);
+
+ UNUSED( raster );
+ UNUSED( mode );
+ UNUSED( palette );
+
#endif
}
@@ -3250,7 +3274,7 @@
ras.outline = *outline;
ras.target = *target_map;
- return ( params->flags & ft_raster_flag_aa
+ return ( ( params->flags & ft_raster_flag_aa )
? Render_Gray_Glyph( raster )
: Render_Glyph( raster ) );
}
--- a/src/raster1/ftraster.h
+++ b/src/raster1/ftraster.h
@@ -25,6 +25,7 @@
#include <freetype/ftimage.h>
+
/*************************************************************************/
/* */
/* Uncomment the following line if you are using ftraster.c as a */
@@ -33,14 +34,15 @@
/* #define _STANDALONE_ */
#ifndef FT_EXPORT_VAR
-#define FT_EXPORT_VAR(x) extern x
+#define FT_EXPORT_VAR( x ) extern x
#endif
- FT_EXPORT_VAR(FT_Raster_Funcs) ft_standard_raster;
+ FT_EXPORT_VAR( FT_Raster_Funcs ) ft_standard_raster;
#ifdef __cplusplus
}
#endif
+
#endif /* FTRASTER_H */
--- a/src/raster1/ftrend1.c
+++ b/src/raster1/ftrend1.c
@@ -1,49 +1,75 @@
+/***************************************************************************/
+/* */
+/* ftrend1.c */
+/* */
+/* The FreeType glyph rasterizer interface (body). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
#include <freetype/internal/ftobjs.h>
#include <freetype/ftoutln.h>
-#include <raster1.h>
+#include <ftrend1.h>
#include <ftraster.h>
- /* initialise renderer - init its raster */
- static FT_Error ft_raster1_init( FT_Renderer render )
+
+ /* initialize renderer -- init its raster */
+ static
+ FT_Error ft_raster1_init( FT_Renderer render )
{
- FT_Library library = FT_MODULE_LIBRARY(render);
+ FT_Library library = FT_MODULE_LIBRARY( render );
+
render->clazz->raster_class->raster_reset( render->raster,
- library->raster_pool, library->raster_pool_size );
+ library->raster_pool,
+ library->raster_pool_size );
- return 0;
+ return FT_Err_Ok;
}
-
- /* sets render-specific mode */
- static FT_Error ft_raster1_set_mode( FT_Renderer render,
- FT_ULong mode_tag,
- FT_Pointer data )
+ /* set render-specific mode */
+ static
+ FT_Error ft_raster1_set_mode( FT_Renderer render,
+ FT_ULong mode_tag,
+ FT_Pointer data )
{
/* we simply pass it to the raster */
- return render->clazz->raster_class->raster_set_mode(
- render->raster, mode_tag, data );
+ return render->clazz->raster_class->raster_set_mode( render->raster,
+ mode_tag,
+ data );
}
- /* transform a given glyph image */
- static FT_Error ft_raster1_transform( FT_Renderer render,
- FT_GlyphSlot slot,
- FT_Matrix* matrix,
- FT_Vector* delta )
+
+ /* transform a given glyph image */
+ static
+ FT_Error ft_raster1_transform( FT_Renderer render,
+ FT_GlyphSlot slot,
+ FT_Matrix* matrix,
+ FT_Vector* delta )
{
FT_Error error = FT_Err_Ok;
- if (slot->format != render->glyph_format)
+
+ if ( slot->format != render->glyph_format )
{
error = FT_Err_Invalid_Argument;
goto Exit;
}
- if (matrix)
+ if ( matrix )
FT_Outline_Transform( &slot->outline, matrix );
- if (delta)
+ if ( delta )
FT_Outline_Translate( &slot->outline, delta->x, delta->y );
Exit:
@@ -50,23 +76,26 @@
return error;
}
- /* return the glyph's control box */
- static void ft_raster1_get_cbox( FT_Renderer render,
- FT_GlyphSlot slot,
- FT_BBox *cbox )
+
+ /* return the glyph's control box */
+ static
+ void ft_raster1_get_cbox( FT_Renderer render,
+ FT_GlyphSlot slot,
+ FT_BBox* cbox )
{
- MEM_Set( cbox, 0, sizeof(*cbox) );
+ MEM_Set( cbox, 0, sizeof ( *cbox ) );
- if (slot->format == render->glyph_format)
+ if ( slot->format == render->glyph_format )
FT_Outline_Get_CBox( &slot->outline, cbox );
}
- /* convert a slot's glyph image into a bitmap */
- static FT_Error ft_raster1_render( FT_Renderer render,
- FT_GlyphSlot slot,
- FT_UInt mode,
- FT_Vector* origin )
+ /* convert a slot's glyph image into a bitmap */
+ static
+ FT_Error ft_raster1_render( FT_Renderer render,
+ FT_GlyphSlot slot,
+ FT_UInt mode,
+ FT_Vector* origin )
{
FT_Error error;
FT_Outline* outline;
@@ -77,8 +106,9 @@
FT_Raster_Params params;
+
/* check glyph image format */
- if (slot->format != render->glyph_format)
+ if ( slot->format != render->glyph_format )
{
error = FT_Err_Invalid_Argument;
goto Exit;
@@ -88,13 +118,13 @@
if ( mode != ft_render_mode_mono )
{
/* raster1 is only capable of producing monochrome bitmaps */
- if (render->clazz == &ft_raster1_renderer_class)
+ if ( render->clazz == &ft_raster1_renderer_class )
return FT_Err_Cannot_Render_Glyph;
}
else
{
/* raster5 is only capable of producing 5-gray-levels bitmaps */
- if (render->clazz == &ft_raster5_renderer_class)
+ if ( render->clazz == &ft_raster5_renderer_class )
return FT_Err_Cannot_Render_Glyph;
}
@@ -101,7 +131,7 @@
outline = &slot->outline;
/* translate the outline to the new origin if needed */
- if (origin)
+ if ( origin )
FT_Outline_Translate( outline, origin->x, origin->y );
/* compute the control box, and grid fit it */
@@ -109,32 +139,32 @@
cbox.xMin &= -64;
cbox.yMin &= -64;
- cbox.xMax = (cbox.xMax+63) & -64;
- cbox.yMax = (cbox.yMax+63) & -64;
+ cbox.xMax = ( cbox.xMax + 63 ) & -64;
+ cbox.yMax = ( cbox.yMax + 63 ) & -64;
- width = (cbox.xMax - cbox.xMin) >> 6;
- height = (cbox.yMax - cbox.yMin) >> 6;
+ width = ( cbox.xMax - cbox.xMin ) >> 6;
+ height = ( cbox.yMax - cbox.yMin ) >> 6;
bitmap = &slot->bitmap;
memory = render->root.memory;
/* release old bitmap buffer */
- if ((slot->flags & ft_glyph_own_bitmap))
+ if ( slot->flags & ft_glyph_own_bitmap )
{
- FREE(bitmap->buffer);
+ FREE( bitmap->buffer );
slot->flags &= ~ft_glyph_own_bitmap;
}
/* allocate new one, depends on pixel format */
- if (!(mode & ft_render_mode_mono))
+ if ( !( mode & ft_render_mode_mono ) )
{
/* we pad to 32 bits, only for backwards compatibility with FT 1.x */
- pitch = (width+3) & -4;
+ pitch = ( width + 3 ) & -4;
bitmap->pixel_mode = ft_pixel_mode_grays;
bitmap->num_grays = 256;
}
else
{
- pitch = (width+7) >> 3;
+ pitch = ( width + 7 ) >> 3;
bitmap->pixel_mode = ft_pixel_mode_mono;
}
@@ -142,7 +172,7 @@
bitmap->rows = height;
bitmap->pitch = pitch;
- if (ALLOC( bitmap->buffer, (FT_ULong)pitch * height ))
+ if ( ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
goto Exit;
slot->flags |= ft_glyph_own_bitmap;
@@ -160,7 +190,8 @@
/* render outline into the bitmap */
error = render->raster_render( render->raster, ¶ms );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
slot->format = ft_glyph_format_bitmap;
slot->bitmap_left = cbox.xMin >> 6;
@@ -171,7 +202,7 @@
}
- const FT_Renderer_Class ft_raster1_renderer_class =
+ const FT_Renderer_Class ft_raster1_renderer_class =
{
{
ft_module_renderer,
@@ -178,30 +209,30 @@
sizeof( FT_RendererRec ),
"raster1",
- 0x10000,
- 0x20000,
+ 0x10000L,
+ 0x20000L,
0, /* module specific interface */
- (FT_Module_Constructor) ft_raster1_init,
- (FT_Module_Destructor) 0,
- (FT_Module_Requester) 0
+ (FT_Module_Constructor)ft_raster1_init,
+ (FT_Module_Destructor) 0,
+ (FT_Module_Requester) 0
},
ft_glyph_format_outline,
- (FTRenderer_render) ft_raster1_render,
- (FTRenderer_transform) ft_raster1_transform,
- (FTRenderer_getCBox) ft_raster1_get_cbox,
- (FTRenderer_setMode) ft_raster1_set_mode,
+ (FTRenderer_render) ft_raster1_render,
+ (FTRenderer_transform)ft_raster1_transform,
+ (FTRenderer_getCBox) ft_raster1_get_cbox,
+ (FTRenderer_setMode) ft_raster1_set_mode,
- (FT_Raster_Funcs*) &ft_standard_raster
+ (FT_Raster_Funcs*) &ft_standard_raster
};
- /* this renderer is _NOT_ part of the default modules, you'll need */
- /* to register it by hand in your application. It should only be */
- /* used for backwards-compatibility with FT 1.x anyway.. */
+ /* this renderer is _NOT_ part of the default modules, you'll need */
+ /* to register it by hand in your application. It should only be */
+ /* used for backwards-compatibility with FT 1.x anyway. */
const FT_Renderer_Class ft_raster5_renderer_class =
{
{
@@ -209,24 +240,25 @@
sizeof( FT_RendererRec ),
"raster5",
- 0x10000,
- 0x20000,
+ 0x10000L,
+ 0x20000L,
0, /* module specific interface */
- (FT_Module_Constructor) ft_raster1_init,
- (FT_Module_Destructor) 0,
- (FT_Module_Requester) 0
+ (FT_Module_Constructor)ft_raster1_init,
+ (FT_Module_Destructor) 0,
+ (FT_Module_Requester) 0
},
ft_glyph_format_outline,
- (FTRenderer_render) ft_raster1_render,
- (FTRenderer_transform) ft_raster1_transform,
- (FTRenderer_getCBox) ft_raster1_get_cbox,
- (FTRenderer_setMode) ft_raster1_set_mode,
+ (FTRenderer_render) ft_raster1_render,
+ (FTRenderer_transform)ft_raster1_transform,
+ (FTRenderer_getCBox) ft_raster1_get_cbox,
+ (FTRenderer_setMode) ft_raster1_set_mode,
- (FT_Raster_Funcs*) &ft_standard_raster
+ (FT_Raster_Funcs*) &ft_standard_raster
};
+/* END */
--- a/src/raster1/ftrend1.h
+++ b/src/raster1/ftrend1.h
@@ -1,14 +1,37 @@
+/***************************************************************************/
+/* */
+/* ftrend1.h */
+/* */
+/* The FreeType glyph rasterizer interface (specification). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
#ifndef FTREND1_H
#define FTREND1_H
#include <freetype/ftrender.h>
- FT_EXPORT_VAR(const FT_Renderer_Class) ft_raster1_renderer_class;
- /* this renderer is _NOT_ part of the default modules, you'll need */
- /* to register it by hand in your application. It should only be */
- /* used for backwards-compatibility with FT 1.x anyway.. */
- /* */
- FT_EXPORT_VAR(const FT_Renderer_Class) ft_raster5_renderer_class;
+ FT_EXPORT_VAR( const FT_Renderer_Class ) ft_raster1_renderer_class;
+ /* this renderer is _NOT_ part of the default modules, you'll need */
+ /* to register it by hand in your application. It should only be */
+ /* used for backwards-compatibility with FT 1.x anyway. */
+ /* */
+ FT_EXPORT_VAR( const FT_Renderer_Class ) ft_raster5_renderer_class;
+
+
#endif /* FTREND1_H */
+
+
+/* END */
--- a/src/raster1/raster1.c
+++ b/src/raster1/raster1.c
@@ -1,4 +1,25 @@
+/***************************************************************************/
+/* */
+/* raster1.c */
+/* */
+/* FreeType monochrome rasterer module component (body only). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
#define FT_MAKE_OPTION_SINGLE_OBJECT
+
#include <ftraster.c>
#include <ftrend1.c>
+
+/* END */
--- a/src/raster1/rules.mk
+++ b/src/raster1/rules.mk
@@ -13,16 +13,16 @@
# fully.
-# renderer driver directory
+# raster1 driver directory
#
RAS1_DIR := $(SRC_)raster1
RAS1_DIR_ := $(RAS1_DIR)$(SEP)
-
# additional include flags used when compiling the driver
#
RAS1_INCLUDE := $(RAS1_DIR)
+
# compilation flags for the driver
#
RAS1_CFLAGS := $(RAS1_INCLUDE:%=$I%)
@@ -29,17 +29,18 @@
RAS1_COMPILE := $(FT_COMPILE) $(RAS1_CFLAGS)
-# RASTER1 driver sources (i.e., C files)
+# raster1 driver sources (i.e., C files)
#
-RAS1_DRV_SRC := $(RAS1_DIR_)ftraster.c \
+RAS1_DRV_SRC := $(RAS1_DIR_)ftraster.c \
$(RAS1_DIR_)ftrend1.c
-# RASTER1 driver headers
+
+# raster1 driver headers
#
-RAS1_DRV_H := $(RAS1_DRV_SRC:%c=%h)
+RAS1_DRV_H := $(RAS1_DRV_SRC:%.c=%.h)
-# RASTER1 driver object(s)
+# raster1 driver object(s)
#
# RAS1_DRV_OBJ_M is used during `multi' builds.
# RAS1_DRV_OBJ_S is used during `single' builds.
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -25,7 +25,9 @@
#include <ttcmap.h>
#include <sfobjs.h>
+#include <string.h> /* for strcmp() */
+
static
void* get_sfnt_table( TT_Face face,
FT_Sfnt_Tag tag )
@@ -84,7 +86,8 @@
}
- static const SFNT_Interface sfnt_interface =
+ static
+ const SFNT_Interface sfnt_interface =
{
TT_Goto_Table,
@@ -115,23 +118,31 @@
TT_Load_PCLT,
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
+
/* see `ttsbit.h' */
TT_Load_SBit_Strikes,
TT_Load_SBit_Image,
TT_Free_SBit_Strikes,
+
#else /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
+
0,
0,
0,
+
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
+
/* see `ttpost.h' */
TT_Get_PS_Name,
TT_Free_Post_Names,
+
#else /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
+
0,
0,
+
#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
/* see `ttcmap.h' */
@@ -140,7 +151,8 @@
};
- const FT_Module_Class sfnt_module_class =
+ const
+ FT_Module_Class sfnt_module_class =
{
0, /* not a font driver or renderer */
sizeof( FT_ModuleRec ),
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -64,7 +64,7 @@
{
if ( rec->nameID == nameid )
{
- /* found the name - now create an ASCII string from it */
+ /* found the name -- now create an ASCII string from it */
FT_Bool found = 0;
@@ -136,7 +136,8 @@
} TEncoding;
- static const TEncoding tt_encodings[] =
+ static
+ const TEncoding tt_encodings[] =
{
{ TT_PLATFORM_ISO, -1, ft_encoding_unicode },
@@ -231,7 +232,8 @@
#undef LOAD_
-#define LOAD_( x ) ( (error = sfnt->load_##x( face, stream )) != TT_Err_Ok )
+#define LOAD_( x ) ( ( error = sfnt->load_##x( face, stream ) ) \
+ != TT_Err_Ok )
LOCAL_FUNC
@@ -382,6 +384,7 @@
}
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
+
if ( face->num_sbit_strikes )
{
face->root.num_fixed_sizes = face->num_sbit_strikes;
@@ -399,11 +402,14 @@
}
}
else
+
#else /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
+
{
root->num_fixed_sizes = 0;
root->available_sizes = 0;
}
+
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
/*********************************************************************/
@@ -442,8 +448,8 @@
root->underline_position = face->postscript.underlinePosition;
root->underline_thickness = face->postscript.underlineThickness;
- /* root->max_points - already set up */
- /* root->max_contours - already set up */
+ /* root->max_points -- already set up */
+ /* root->max_contours -- already set up */
}
Exit:
@@ -485,7 +491,7 @@
face->num_tables = 0;
/* freeing the character mapping tables */
- if (sfnt && sfnt->load_charmaps )
+ if ( sfnt && sfnt->load_charmaps )
{
FT_UShort n;