* 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
diff --git a/ChangeLog b/ChangeLog
index 97a77d9..3399a4f 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 8da5fad..c42949a 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 93bd3b6..8e973cb 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 f4e8a29..9ee684e 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 dd65915..61d4b28 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 5bcdf13..a0781dc 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 7e0843e..63ff3a3 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 8f92a42..a5c88b1 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 78eb41a..6cd9908 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 7329973..441ed78 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;
}