summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Turner <david@freetype.org>2004-01-15 19:07:44 +0000
committerDavid Turner <david@freetype.org>2004-01-15 19:07:44 +0000
commit4632fccb1b44bef8b3c593a646bd8d50089880dc (patch)
tree289fda9d23179a17c60d81bc7ab331c6051881f7
parentedeed6b391a6158eb1948efc28a19694272b580e (diff)
downloadfreetype2-4632fccb1b44bef8b3c593a646bd8d50089880dc.tar.gz
* 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
-rw-r--r--ChangeLog14
-rw-r--r--include/freetype/internal/ftmemory.h5
-rw-r--r--src/autohint/ahhint.c16
-rw-r--r--src/base/ftgloadr.c16
-rw-r--r--src/base/ftglyph.c12
-rw-r--r--src/base/ftoutln.c54
-rw-r--r--src/base/ftstroke.c5
-rw-r--r--src/cff/cffload.c16
-rw-r--r--src/truetype/ttgload.c4
-rw-r--r--src/truetype/ttinterp.c6
10 files changed, 79 insertions, 69 deletions
diff --git a/ChangeLog b/ChangeLog
index 97a77d94f..3399a4f8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-01-14 David Turner <david@freetype.org>
+
+ * 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 <wl@gnu.org>
* 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 <shspamsink@comcast.net>.
2004-01-03 Masatake YAMATO <jet@gyve.org>
diff --git a/include/freetype/internal/ftmemory.h b/include/freetype/internal/ftmemory.h
index 8da5fadc3..c42949a2d 100644
--- a/include/freetype/internal/ftmemory.h
+++ b/include/freetype/internal/ftmemory.h
@@ -180,6 +180,11 @@ FT_BEGIN_HEADER
#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)) )
/*************************************************************************/
/* */
diff --git a/src/autohint/ahhint.c b/src/autohint/ahhint.c
index 93bd3b64e..8e973cbc0 100644
--- 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;
diff --git a/src/base/ftgloadr.c b/src/base/ftgloadr.c
index f4e8a292f..9ee684eda 100644
--- 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;
diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c
index dd6591561..61d4b286d 100644
--- 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;
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index 5bcdf137d..a0781dc3d 100644
--- 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,7 +713,7 @@
FT_Outline_Get_Orientation( FT_Outline* outline )
{
FT_Orientation result = FT_ORIENTATION_TRUETYPE;
-
+
if ( outline && outline->n_points > 0 )
{
@@ -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,13 +737,13 @@
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 )
{
@@ -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;
}
diff --git a/src/base/ftstroke.c b/src/base/ftstroke.c
index 7e0843e1f..63ff3a32b 100644
--- 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 */
{
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index 8f92a425f..a5c88b18b 100644
--- 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 */
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 78eb41a96..6cd9908e5 100644
--- 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) )
/*************************************************************************/
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index 732997323..441ed7827 100644
--- 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;
}