formatting, copyright years
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 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
diff --git a/ChangeLog b/ChangeLog
index f6d20cd..087d5dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,26 +1,61 @@
2007-01-04 David Turner <david@freetype.org>
- * src/pfr/pfrobjs.c (pfr_face_init): detect non-scalable fonts
- correctly. fixes bug #17876
+ * src/pfr/pfrobjs.c (pfr_face_init): Detect non-scalable fonts
+ correctly. This fixes Savannah bug #17876.
- * src/truetype/ttobjs.h, src/truetype/ttobjs.c,
- src/truetype/ttgload.c: do not allocate interpreter-specific
- tables in memory if we're not going to load glyphs with it
- anyway.
+
+ Do not allocate interpreter-specific tables in memory if we are not
+ going to load glyphs with the bytecode interpreter anyway.
+
+ * src/truetype/ttgload.c (tt_loader_init): Load execution context
+ only if glyph is hinted.
+ Updated.
+ * src/truetype/ttobjs.h (TT_SizeRec): Add members `bytecode_ready'
+ and `cvs_ready'.
+ Add `tt_size_ready_bytecode' declaration.
+ * src/truetype/ttobjs.c (tt_size_done_bytecode,
+ tt_size_init_bytecode, tt_size_ready_bytecode): New functions.
+ (tt_size_init): Move most code into `tt_size_init_bytecode'.
+ (tt_size_done): Move most code into `tt_size_done_bytecode'.
+ (tt_size_reset): Move some code to `tt_size_ready_bytecode'.
- * src/sfnt/ttmtx.c, include/freetype/internal/tttypes.h:
- don't extract the metrics table from the SFNT font file.
- Instead, reparse it on each glyph load, since the runtime
- difference will not be noticeable, and it can save a lot
- of heap memory when memory-mapped files are not used.
-
- * src/sfnt/ttcmap.c: slight optimization in the CMAP 4 validator
-
- * src/cff/cffload.c, src/cff/cffload.h, src/cff/cffgload.c,
- src/cff/cfftypes.h: formatting + do not load the CFF index
- offsets into memory, since this wastes a *lot* of heap memory
- with large Asian CFF fonts. There is no significant performance
- loss
+
+ Don't extract the metrics table from the SFNT font file. Instead,
+ reparse it on each glyph load. The runtime difference is not
+ noticeable, and it can save a lot of heap memory when memory-mapped
+ files are not used.
+
+ * include/freetype/internal/tttypes.h (TT_FaceRec): Add members
+ `horz_metrics_offset' and `vert_metrics_ofset'.
+ * src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics):
+ Updated.
+
+
+ * src/sfnt/ttcmap.c (tt_cmap4_validate): Slight optimization.
+
+
+ Do not load the CFF index offsets into memory, since this wastes a
+ *lot* of heap memory with large Asian CFF fonts. There is no
+ significant performance loss.
+
+ * src/cff/cffload.h: Add `cff_charset_cid_to_gindex' declaration.
+ * src/cff/cfftypes.h (CFF_IndexRec): Add fields `start' and
+ `data_size'.
+ (CFF_CharsetRec): Add field `num_glyphs'.
+
+ * src/cff/cffload.c (cff_index_read_offset, cff_index_load_offsets,
+ cff_charset_cid_to_gindex): New functions.
+ (cff_new_index): Renamed to...
+ (cff_index_init): This. Update all callers.
+ Updated -- some code has been moved to `cff_index_load_offsets'.
+ (cff_done_index): Renamed to...
+ (cff_index_done): This. Update all callers.
+ (cff_index_get_pointers, cff_index_access_element): Updated to use
+ stream offsets.
+ (cff_charset_compute_cids): Set `num_glyphs' field.
+ (cff_encoding_load): Updated.
+
+ * src/cff/cffgload.c (cff_slot_load): Updated.
2007-01-04 David Turner <david@freetype.org>
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index c031e03..5c5ae61 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -4,7 +4,7 @@
/* */
/* OpenType Glyph Loader (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -2275,14 +2275,14 @@
FT_UInt glyph_index,
FT_Int32 load_flags )
{
- FT_Error error;
- CFF_Decoder decoder;
- TT_Face face = (TT_Face)glyph->root.face;
- FT_Bool hinting;
- CFF_Font cff = (CFF_Font)face->extra.data;
+ FT_Error error;
+ CFF_Decoder decoder;
+ TT_Face face = (TT_Face)glyph->root.face;
+ FT_Bool hinting;
+ CFF_Font cff = (CFF_Font)face->extra.data;
- FT_Matrix font_matrix;
- FT_Vector font_offset;
+ FT_Matrix font_matrix;
+ FT_Vector font_offset;
/* in a CID-keyed font, consider `glyph_index' as a CID and map */
@@ -2424,9 +2424,11 @@
{
CFF_Index csindex = &cff->charstrings_index;
- if (csindex->offsets)
+
+ if ( csindex->offsets )
{
- glyph->root.control_data = csindex->bytes + csindex->offsets[glyph_index] - 1;
+ glyph->root.control_data = csindex->bytes +
+ csindex->offsets[glyph_index] - 1;
glyph->root.control_len = charstring_len;
}
}
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index 988eed0..cbd4fc3 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -4,7 +4,7 @@
/* */
/* OpenType and CFF data/program tables loader (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -193,6 +193,7 @@
#undef FT_COMPONENT
#define FT_COMPONENT trace_cffload
+
/* read an offset from the index's stream current position */
static FT_ULong
cff_index_read_offset( CFF_Index idx,
@@ -203,12 +204,14 @@
FT_Byte tmp[4];
FT_ULong result = 0;
+
if ( !FT_STREAM_READ( tmp, idx->off_size ) )
{
FT_Int nn;
+
for ( nn = 0; nn < idx->off_size; nn++ )
- result = (result << 8) | tmp[nn];
+ result = ( result << 8 ) | tmp[nn];
}
*perror = error;
@@ -233,8 +236,8 @@
if ( !FT_READ_USHORT( count ) &&
count > 0 )
{
- FT_Byte offsize;
- FT_ULong size, last_offset;
+ FT_Byte offsize;
+ FT_ULong size, last_offset;
/* there is at least one element; read the offset size, */
@@ -258,7 +261,7 @@
goto Exit;
size = cff_index_read_offset( idx, &error );
- if (error)
+ if ( error )
goto Exit;
if ( size == 0 )
@@ -316,6 +319,7 @@
FT_Stream stream = idx->stream;
FT_Memory memory = stream->memory;
+
if ( idx->count > 0 && idx->offsets == NULL )
{
FT_Byte offsize = idx->off_size;
@@ -324,11 +328,12 @@
FT_Byte* p_end;
FT_ULong* poff;
- data_size = (FT_ULong)( idx->count + 1 ) * offsize;
+
+ data_size = (FT_ULong)( idx->count + 1 ) * offsize;
if ( FT_NEW_ARRAY( idx->offsets, idx->count + 1 ) ||
- FT_STREAM_SEEK( idx->start + 3 ) ||
- FT_FRAME_ENTER( data_size ) )
+ FT_STREAM_SEEK( idx->start + 3 ) ||
+ FT_FRAME_ENTER( data_size ) )
goto Exit;
poff = idx->offsets;
@@ -361,15 +366,13 @@
}
Exit:
- if (error)
+ if ( error )
FT_FREE( idx->offsets );
return error;
}
-
-
/* allocate a table containing pointers to an index's elements */
static FT_Error
cff_index_get_pointers( CFF_Index idx,
@@ -400,7 +403,7 @@
offset = old_offset;
/* sanity check for invalid offset tables */
- else if ( offset < old_offset || offset-1 >= idx->data_size )
+ else if ( offset < old_offset || offset - 1 >= idx->data_size )
offset = old_offset;
t[n] = idx->bytes + offset - 1;
@@ -434,13 +437,15 @@
/* load offsets from file or the offset table */
if ( !idx->offsets )
{
- FT_ULong pos = element*idx->off_size;
+ FT_ULong pos = element * idx->off_size;
+
if ( FT_STREAM_SEEK( idx->start + 3 + pos ) )
goto Exit;
off1 = cff_index_read_offset( idx, &error );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
if ( off1 != 0 )
{
@@ -760,12 +765,14 @@
{
FT_UInt result = 0;
+
if ( cid < charset->max_cid )
result = charset->cids[cid];
return result;
}
+
static void
cff_charset_free_cids( CFF_Charset charset,
FT_Memory memory )
@@ -1393,10 +1400,14 @@
goto Exit;
/* read the name, top dict, string and global subrs index */
- if ( FT_SET_ERROR( cff_index_init( &font->name_index, stream, 0 )) ||
- FT_SET_ERROR( cff_index_init( &font->font_dict_index, stream, 0 )) ||
- FT_SET_ERROR( cff_index_init( &font->string_index, stream, 0 )) ||
- FT_SET_ERROR( cff_index_init( &font->global_subrs_index, stream, 1 )) )
+ if ( FT_SET_ERROR( cff_index_init( &font->name_index,
+ stream, 0 ) ) ||
+ FT_SET_ERROR( cff_index_init( &font->font_dict_index,
+ stream, 0 ) ) ||
+ FT_SET_ERROR( cff_index_init( &font->string_index,
+ stream, 0 ) ) ||
+ FT_SET_ERROR( cff_index_init( &font->global_subrs_index,
+ stream, 1 ) ) )
goto Exit;
/* well, we don't really forget the `disabled' fonts... */
diff --git a/src/cff/cffload.h b/src/cff/cffload.h
index 13ee09d..068cbb5 100644
--- a/src/cff/cffload.h
+++ b/src/cff/cffload.h
@@ -4,7 +4,7 @@
/* */
/* OpenType & CFF data/program tables loader (specification). */
/* */
-/* Copyright 1996-2001, 2002, 2003 by */
+/* Copyright 1996-2001, 2002, 2003, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -56,6 +56,7 @@ FT_BEGIN_HEADER
cff_charset_cid_to_gindex( CFF_Charset charset,
FT_UInt cid );
+
FT_LOCAL( FT_Error )
cff_font_load( FT_Stream stream,
FT_Int face_index,
diff --git a/src/cff/cfftypes.h b/src/cff/cfftypes.h
index 07edfbd..96301d6 100644
--- a/src/cff/cfftypes.h
+++ b/src/cff/cfftypes.h
@@ -5,7 +5,7 @@
/* Basic OpenType/CFF type definitions and interface (specification */
/* only). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2006 by */
+/* Copyright 1996-2001, 2002, 2003, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -40,7 +40,7 @@ FT_BEGIN_HEADER
/* stream :: The source input stream. */
/* */
/* start :: The position of the first index byte in the */
- /* input stream */
+ /* input stream. */
/* */
/* count :: The number of elements in the index. */
/* */
@@ -49,10 +49,10 @@ FT_BEGIN_HEADER
/* data_offset :: The position of first data byte in the index's */
/* bytes. */
/* */
- /* data_size :: size of data table in this index */
+ /* data_size :: The size of the data table in this index. */
/* */
- /* offsets :: A table of element offsets in the index. must be */
- /* loaded explicitely */
+ /* offsets :: A table of element offsets in the index. Must be */
+ /* loaded explicitly. */
/* */
/* bytes :: If the index is loaded in memory, its bytes. */
/* */
diff --git a/src/pfr/pfrobjs.c b/src/pfr/pfrobjs.c
index 976ab4a..180446d 100644
--- a/src/pfr/pfrobjs.c
+++ b/src/pfr/pfrobjs.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR object methods (body). */
/* */
-/* Copyright 2002, 2003, 2004, 2005, 2006 by */
+/* Copyright 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -122,7 +122,7 @@
if ( error )
goto Exit;
- /* now, set-up all root face fields */
+ /* now set up all root face fields */
{
PFR_PhyFont phy_font = &face->phy_font;
@@ -132,16 +132,17 @@
pfrface->face_flags = FT_FACE_FLAG_SCALABLE;
/* if all characters point to the same gps_offset 0, we */
- /* assume the font only contains bitmaps */
+ /* assume that the font only contains bitmaps */
{
FT_UInt nn;
+
for ( nn = 0; nn < phy_font->num_chars; nn++ )
if ( phy_font->chars[nn].gps_offset != 0 )
break;
if ( nn == phy_font->num_chars )
- pfrface->face_flags = 0; /* not SCALABLE !! */
+ pfrface->face_flags = 0; /* not scalable */
}
if ( (phy_font->flags & PFR_PHY_PROPORTIONAL) == 0 )
diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c
index 424716b..20e8f3a 100644
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -4,7 +4,7 @@
/* */
/* TrueType character mapping table (cmap) support (body). */
/* */
-/* Copyright 2002, 2003, 2004, 2005, 2006 by */
+/* Copyright 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/sfnt/ttmtx.c b/src/sfnt/ttmtx.c
index e3eff29..46e9332 100644
--- a/src/sfnt/ttmtx.c
+++ b/src/sfnt/ttmtx.c
@@ -72,6 +72,7 @@
FT_ULong* ptable_offset;
FT_ULong* ptable_size;
+
if ( vertical )
{
tag = TTAG_vmtx;
@@ -86,7 +87,7 @@
}
error = face->goto_table( face, tag, stream, &table_size );
- if (error)
+ if ( error )
goto Fail;
*ptable_size = table_size;
@@ -366,27 +367,27 @@
{
if ( gindex < (FT_UInt)k )
{
- table_pos += 4*gindex;
- if ( table_pos+6 > table_end )
+ table_pos += 4 * gindex;
+ if ( table_pos + 6 > table_end )
goto NoData;
if ( FT_STREAM_SEEK( table_pos ) ||
FT_READ_USHORT( *aadvance) ||
- FT_READ_SHORT( *abearing ) )
+ FT_READ_SHORT( *abearing ) )
goto NoData;
}
else
{
- table_pos += 4*(k-1);
- if ( table_pos+4 > table_end )
+ table_pos += 4 * ( k - 1 );
+ if ( table_pos + 4 > table_end )
goto NoData;
if ( FT_STREAM_SEEK( table_pos ) ||
FT_READ_USHORT( *aadvance ) )
goto NoData;
- table_pos += 4 + 2*(gindex - k);
- if ( table_pos+2 > table_end )
+ table_pos += 4 + 2 * ( gindex - k );
+ if ( table_pos + 2 > table_end )
*abearing = 0;
else
{
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index a04f914..c595487 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -4,7 +4,7 @@
/* */
/* TrueType Glyph Loader (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index 908194e..dbd2bda 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -4,7 +4,7 @@
/* */
/* Objects manager (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -524,10 +524,11 @@
static void
tt_size_done_bytecode( FT_Size ftsize )
{
- TT_Size size = (TT_Size)ftsize;
- TT_Face face = (TT_Face)ftsize->face;
+ TT_Size size = (TT_Size)ftsize;
+ TT_Face face = (TT_Face)ftsize->face;
FT_Memory memory = face->root.memory;
+
if ( size->debug )
{
/* the debug context must be deleted by the debugger itself */
@@ -561,10 +562,8 @@
}
- /* initialize bytecode-related fields in the size object,
- * should only be needed when bytecode interpretation is
- * really needed
- */
+ /* Initialize bytecode-related fields in the size object. */
+ /* We do this only if bytecode interpretation is really needed. */
static FT_Error
tt_size_init_bytecode( FT_Size ftsize )
{
@@ -646,7 +645,7 @@
error = tt_size_run_fpgm( size );
Exit:
- if (error)
+ if ( error )
tt_size_done_bytecode( ftsize );
return error;
@@ -656,7 +655,8 @@
FT_LOCAL_DEF( FT_Error )
tt_size_ready_bytecode( TT_Size size )
{
- FT_Error error = 0;
+ FT_Error error = TT_Err_Ok;
+
if ( !size->bytecode_ready )
{
@@ -677,7 +677,7 @@
for ( i = 0; i < size->cvt_size; i++ )
size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
- /* All twilight points are originally zero */
+ /* all twilight points are originally zero */
for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ )
{
size->twilight.org[i].x = 0;
@@ -703,13 +703,13 @@
FT_LOCAL_DEF( FT_Error )
tt_size_ready_bytecode( TT_Size size )
{
- FT_UNUSED(ftsize);
+ FT_UNUSED( ftsize );
return 0;
}
-
#endif /* !TT_USE_BYTECODE_INTERPRETER */
+
/*************************************************************************/
/* */
/* <Function> */
@@ -756,7 +756,8 @@
FT_LOCAL_DEF( void )
tt_size_done( FT_Size ttsize ) /* TT_Size */
{
- TT_Size size = (TT_Size)ttsize;
+ TT_Size size = (TT_Size)ttsize;
+
#ifdef TT_USE_BYTECODE_INTERPRETER
if ( size->bytecode_ready )
diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h
index f81328f..652ead3 100644
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -4,7 +4,7 @@
/* */
/* Objects manager (specification). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */