shithub: freetype+ttf2subf

Download patch

ref: f6294399056077c92367301623c093db285dadbf
parent: d88a0c9e64b69242d29bcfaf6ab71139528de8f5
author: Werner Lemberg <[email protected]>
date: Sat Jan 6 02:47:45 EST 2007

formatting, copyright years

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,26 +1,61 @@
 2007-01-04  David Turner  <[email protected]>
 
-	* 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
+	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.
 
-	* 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
+	* 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  <[email protected]>
 
--- 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;
           }
         }
--- 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,7 +366,7 @@
     }
 
   Exit:
-    if (error)
+    if ( error )
       FT_FREE( idx->offsets );
 
     return error;
@@ -368,8 +373,6 @@
   }
 
 
-
-
   /* 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,6 +765,7 @@
   {
     FT_UInt  result = 0;
 
+
     if ( cid < charset->max_cid )
       result = charset->cids[cid];
 
@@ -766,6 +772,7 @@
     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... */
--- 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,       */
@@ -55,6 +55,7 @@
   FT_LOCAL( FT_UInt )
   cff_charset_cid_to_gindex( CFF_Charset  charset,
                              FT_UInt      cid );
+
 
   FT_LOCAL( FT_Error )
   cff_font_load( FT_Stream  stream,
--- 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 @@
   /*    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 @@
   /*    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.        */
   /*                                                                       */
--- 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 )
--- 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,       */
--- 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,19 +367,19 @@
     {
       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 ) ||
@@ -385,8 +386,8 @@
              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
         {
--- 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,       */
--- 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,8 +655,9 @@
   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 )
     {
       error = tt_size_init_bytecode( (FT_Size)size );
@@ -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 )
--- 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,       */