ref: 4632fccb1b44bef8b3c593a646bd8d50089880dc
parent: edeed6b391a6158eb1948efc28a19694272b580e
author: David Turner <[email protected]>
date: Thu Jan 15 14:07:44 EST 2004
* include/freetype/internal/ftmemory.h, src/autohint/ahhint.c, src/base/ftgloadr.c, src/base/ftglyph.c, src/base/ftoutln.c, src/base/ftstroke.c, src/cff/cffload.c, src/truetype/ttgload.c, src/truetype/ttinterp.c: introducing the new FT_ARRAY_COPY and FT_ARRAY_MOVE macros to make copying arrays easier
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-01-14 David Turner <[email protected]>
+
+ * include/freetype/internal/ftmemory.h,
+ src/autohint/ahhint.c, src/base/ftgloadr.c,
+ src/base/ftglyph.c, src/base/ftoutln.c,
+ src/base/ftstroke.c, src/cff/cffload.c, src/truetype/ttgload.c,
+ src/truetype/ttinterp.c:
+
+ introducing the new FT_ARRAY_COPY and FT_ARRAY_MOVE macros
+ to make copying arrays easier
+
+
2004-01-14 Werner Lemberg <[email protected]>
* src/cff/cffload.c (cff_font_load): Load charstrings_index earlier.
@@ -19,7 +31,7 @@
(cff_get_cmap_info): New function.
(cff_service_get_cmap_info) New entry for cff_services.
- * src/sfnt/ttcmap0.c: Exit loop after a format match has been found.
+ * src/sfnt/ttcmap0.c: Exit loop after a format match has been found.
Suggested by Steve Hartwell <[email protected]>.
2004-01-03 Masatake YAMATO <[email protected]>
--- a/include/freetype/internal/ftmemory.h
+++ b/include/freetype/internal/ftmemory.h
@@ -180,6 +180,11 @@
#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) )
+#define FT_ARRAY_COPY( dest, source, count ) \
+ FT_MEM_COPY( dest, source, (count)*sizeof(*(dest)) )
+
+#define FT_ARRAY_MOVE( dest, source, count ) \
+ FT_MEM_MOVE( dest, source, (count)*sizeof(*(dest)) )
/*************************************************************************/
/* */
--- a/src/autohint/ahhint.c
+++ b/src/autohint/ahhint.c
@@ -1494,14 +1494,14 @@
if ( error )
goto Exit;
- FT_MEM_COPY( gloader->current.extra_points, slot->outline.points,
- slot->outline.n_points * sizeof ( FT_Vector ) );
+ FT_ARRAY_COPY( gloader->current.extra_points, slot->outline.points,
+ slot->outline.n_points );
- FT_MEM_COPY( gloader->current.outline.contours, slot->outline.contours,
- slot->outline.n_contours * sizeof ( short ) );
+ FT_ARRAY_COPY( gloader->current.outline.contours, slot->outline.contours,
+ slot->outline.n_contours );
- FT_MEM_COPY( gloader->current.outline.tags, slot->outline.tags,
- slot->outline.n_points * sizeof ( char ) );
+ FT_ARRAY_COPY( gloader->current.outline.tags, slot->outline.tags,
+ slot->outline.n_points );
gloader->current.outline.n_points = slot->outline.n_points;
gloader->current.outline.n_contours = slot->outline.n_contours;
@@ -1580,8 +1580,8 @@
if ( error )
goto Exit;
- FT_MEM_COPY( gloader->current.subglyphs, slot->subglyphs,
- num_subglyphs * sizeof ( FT_SubGlyph ) );
+ FT_ARRAY_COPY( gloader->current.subglyphs, slot->subglyphs,
+ num_subglyphs );
gloader->current.num_subglyphs = num_subglyphs;
num_base_subgs = gloader->base.num_subglyphs;
--- a/src/base/ftgloadr.c
+++ b/src/base/ftgloadr.c
@@ -337,17 +337,17 @@
FT_Outline* in = &source->base.outline;
- FT_MEM_COPY( out->points, in->points,
- num_points * sizeof ( FT_Vector ) );
- FT_MEM_COPY( out->tags, in->tags,
- num_points * sizeof ( char ) );
- FT_MEM_COPY( out->contours, in->contours,
- num_contours * sizeof ( short ) );
+ FT_ARRAY_COPY( out->points, in->points,
+ num_points );
+ FT_ARRAY_COPY( out->tags, in->tags,
+ num_points );
+ FT_ARRAY_COPY( out->contours, in->contours,
+ num_contours );
/* do we need to copy the extra points? */
if ( target->use_extra && source->use_extra )
- FT_MEM_COPY( target->base.extra_points, source->base.extra_points,
- num_points * sizeof ( FT_Vector ) );
+ FT_ARRAY_COPY( target->base.extra_points, source->base.extra_points,
+ num_points );
out->n_points = (short)num_points;
out->n_contours = (short)num_contours;
--- a/src/base/ftglyph.c
+++ b/src/base/ftglyph.c
@@ -253,14 +253,14 @@
goto Exit;
/* copy it */
- FT_MEM_COPY( target->points, source->points,
- source->n_points * sizeof ( FT_Vector ) );
+ FT_ARRAY_COPY( target->points, source->points,
+ source->n_points );
- FT_MEM_COPY( target->tags, source->tags,
- source->n_points * sizeof ( FT_Byte ) );
+ FT_ARRAY_COPY( target->tags, source->tags,
+ source->n_points );
- FT_MEM_COPY( target->contours, source->contours,
- source->n_contours * sizeof ( FT_Short ) );
+ 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;
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -358,14 +358,14 @@
source->n_contours != target->n_contours )
return FT_Err_Invalid_Argument;
- FT_MEM_COPY( target->points, source->points,
- source->n_points * sizeof ( FT_Vector ) );
+ FT_ARRAY_COPY( target->points, source->points,
+ source->n_points );
- FT_MEM_COPY( target->tags, source->tags,
- source->n_points * sizeof ( FT_Byte ) );
+ FT_ARRAY_COPY( target->tags, source->tags,
+ source->n_points );
- FT_MEM_COPY( target->contours, source->contours,
- source->n_contours * sizeof ( FT_Short ) );
+ FT_ARRAY_COPY( target->contours, source->contours,
+ source->n_contours );
/* copy all flags, except the `FT_OUTLINE_OWNER' one */
is_owner = target->flags & FT_OUTLINE_OWNER;
@@ -662,10 +662,10 @@
FT_Long pos;
FT_Int first;
FT_Int last;
-
+
} FT_OrientationExtremumRec;
-
+
static FT_Orientation
ft_orientation_extremum_compute( FT_OrientationExtremumRec* extremum,
FT_Outline* outline )
@@ -673,36 +673,36 @@
FT_Vector *point, *first, *last, *prev, *next;
FT_Vector* points = outline->points;
FT_Angle angle_in, angle_out;
-
+
/* compute the previous and next points in the same contour */
point = points + extremum->index;
first = points + extremum->first;
last = points + extremum->last;
-
+
do
{
prev = ( point == first ) ? last : point - 1;
-
+
if ( prev == point )
return FT_ORIENTATION_TRUETYPE; /* degenerate case */
-
+
} while ( prev->x != point->x || prev->y != point->y );
-
+
do
{
next = ( point == last ) ? first : point + 1;
-
+
if ( next == point )
return FT_ORIENTATION_TRUETYPE; /* shouldn't happen */
-
+
} while ( next->x != point->x || next->y != point->y );
-
+
/* now compute the orientation of the `out' vector relative */
/* to the `in' vector. */
angle_in = FT_Atan2( point->x - prev->x, point->y - prev->y );
angle_out = FT_Atan2( next->x - point->x, next->y - point->y );
-
+
return ( FT_Angle_Diff( angle_in, angle_out ) >= 0 )
? FT_ORIENTATION_TRUETYPE
: FT_ORIENTATION_POSTSCRIPT;
@@ -713,8 +713,8 @@
FT_Outline_Get_Orientation( FT_Outline* outline )
{
FT_Orientation result = FT_ORIENTATION_TRUETYPE;
-
+
if ( outline && outline->n_points > 0 )
{
FT_OrientationExtremumRec xmin, ymin, xmax, ymax;
@@ -721,11 +721,11 @@
FT_Int n;
FT_Int first, last;
FT_Vector* points = outline->points;
-
+
xmin.pos = ymin.pos = +32768L;
xmax.pos = ymax.pos = -32768L;
-
+
xmin.index = ymin.index = xmax.index = ymax.index = -1;
first = 0;
@@ -737,14 +737,14 @@
if ( last > first + 1 )
{
FT_Int i;
-
+
for ( i = first; i < last; i++ )
{
FT_Pos x = points[i].x;
FT_Pos y = points[i].y;
-
+
if ( x < xmin.pos )
{
xmin.pos = x;
@@ -775,21 +775,21 @@
}
}
}
-
+
if ( xmin.index >= 0 )
result = ft_orientation_extremum_compute( &xmin, outline );
-
+
else if ( xmax.index >= 0 )
result = ft_orientation_extremum_compute( &xmax, outline );
-
+
else if ( ymin.index >= 0 )
result = ft_orientation_extremum_compute( &ymin, outline );
-
+
else if ( ymax.index >= 0 )
result = ft_orientation_extremum_compute( &ymax, outline );
}
}
-
+
return result;
}
--- a/src/base/ftstroke.c
+++ b/src/base/ftstroke.c
@@ -580,9 +580,8 @@
FT_Outline* outline )
{
/* copy point locations */
- FT_MEM_COPY( outline->points + outline->n_points,
- border->points,
- border->num_points * sizeof ( FT_Vector ) );
+ FT_ARRAY_COPY( outline->points + outline->n_points,
+ border->points, border->num_points );
/* copy tags */
{
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -1624,8 +1624,7 @@
goto Exit;
/* Copy the predefined charset into the allocated memory. */
- FT_MEM_COPY( charset->sids, cff_isoadobe_charset,
- num_glyphs * sizeof ( FT_UShort ) );
+ FT_ARRAY_COPY( charset->sids, cff_isoadobe_charset, num_glyphs );
break;
@@ -1643,8 +1642,7 @@
goto Exit;
/* Copy the predefined charset into the allocated memory. */
- FT_MEM_COPY( charset->sids, cff_expert_charset,
- num_glyphs * sizeof ( FT_UShort ) );
+ FT_ARRAY_COPY( charset->sids, cff_expert_charset, num_glyphs );
break;
@@ -1662,8 +1660,7 @@
goto Exit;
/* Copy the predefined charset into the allocated memory. */
- FT_MEM_COPY( charset->sids, cff_expertsubset_charset,
- num_glyphs * sizeof ( FT_UShort ) );
+ FT_ARRAY_COPY( charset->sids, cff_expertsubset_charset, num_glyphs );
break;
@@ -1909,15 +1906,12 @@
{
case 0:
/* First, copy the code to SID mapping. */
- FT_MEM_COPY( encoding->sids, cff_standard_encoding,
- 256 * sizeof ( FT_UShort ) );
-
+ FT_ARRAY_COPY( encoding->sids, cff_standard_encoding, 256 );
goto Populate;
case 1:
/* First, copy the code to SID mapping. */
- FT_MEM_COPY( encoding->sids, cff_expert_encoding,
- 256 * sizeof ( FT_UShort ) );
+ FT_ARRAY_COPY( encoding->sids, cff_expert_encoding, 256 );
Populate:
/* Construct code to GID mapping from code to SID mapping */
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -163,10 +163,10 @@
#define cur_to_org( n, zone ) \
- FT_MEM_COPY( (zone)->org, (zone)->cur, (n) * sizeof ( FT_Vector ) )
+ FT_ARRAY_COPY( (zone)->org, (zone)->cur, (n) )
#define org_to_cur( n, zone ) \
- FT_MEM_COPY( (zone)->cur, (zone)->org, (n) * sizeof ( FT_Vector ) )
+ FT_ARRAY_COPY( (zone)->cur, (zone)->org, (n) )
/*************************************************************************/
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -4106,9 +4106,9 @@
K = CUR.stack[CUR.args - L];
- FT_MEM_MOVE( &CUR.stack[CUR.args - L ],
- &CUR.stack[CUR.args - L + 1],
- ( L - 1 ) * sizeof ( FT_Long ) );
+ FT_ARRAY_MOVE( &CUR.stack[CUR.args - L ],
+ &CUR.stack[CUR.args - L + 1],
+ ( L - 1 ) );
CUR.stack[CUR.args - 1] = K;
}