summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/sfnt/ttload.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/sfnt/ttload.c')
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttload.c719
1 files changed, 394 insertions, 325 deletions
diff --git a/src/3rdparty/freetype/src/sfnt/ttload.c b/src/3rdparty/freetype/src/sfnt/ttload.c
index a86a546c3d..7b44e9cd2e 100644
--- a/src/3rdparty/freetype/src/sfnt/ttload.c
+++ b/src/3rdparty/freetype/src/sfnt/ttload.c
@@ -1,57 +1,58 @@
-/***************************************************************************/
-/* */
-/* ttload.c */
-/* */
-/* Load the basic TrueType tables, i.e., tables that can be either in */
-/* TTF or OTF fonts (body). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#include <ft2build.h>
-#include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_STREAM_H
-#include FT_TRUETYPE_TAGS_H
+/****************************************************************************
+ *
+ * ttload.c
+ *
+ * Load the basic TrueType tables, i.e., tables that can be either in
+ * TTF or OTF fonts (body).
+ *
+ * Copyright (C) 1996-2023 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/tttags.h>
#include "ttload.h"
#include "sferrors.h"
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
+ /**************************************************************************
+ *
+ * The macro FT_COMPONENT is used in trace mode. It is an implicit
+ * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
+ * messages during execution.
+ */
#undef FT_COMPONENT
-#define FT_COMPONENT trace_ttload
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_lookup_table */
- /* */
- /* <Description> */
- /* Looks for a TrueType table by name. */
- /* */
- /* <Input> */
- /* face :: A face object handle. */
- /* */
- /* tag :: The searched tag. */
- /* */
- /* <Return> */
- /* A pointer to the table directory entry. 0 if not found. */
- /* */
+#define FT_COMPONENT ttload
+
+
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_lookup_table
+ *
+ * @Description:
+ * Looks for a TrueType table by name.
+ *
+ * @Input:
+ * face ::
+ * A face object handle.
+ *
+ * tag ::
+ * The searched tag.
+ *
+ * @Return:
+ * A pointer to the table directory entry. 0 if not found.
+ */
FT_LOCAL_DEF( TT_Table )
tt_face_lookup_table( TT_Face face,
FT_ULong tag )
@@ -63,8 +64,8 @@
#endif
- FT_TRACE4(( "tt_face_lookup_table: %08p, `%c%c%c%c' -- ",
- face,
+ FT_TRACE4(( "tt_face_lookup_table: %p, `%c%c%c%c' -- ",
+ (void *)face,
(FT_Char)( tag >> 24 ),
(FT_Char)( tag >> 16 ),
(FT_Char)( tag >> 8 ),
@@ -101,27 +102,31 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_goto_table */
- /* */
- /* <Description> */
- /* Looks for a TrueType table by name, then seek a stream to it. */
- /* */
- /* <Input> */
- /* face :: A face object handle. */
- /* */
- /* tag :: The searched tag. */
- /* */
- /* stream :: The stream to seek when the table is found. */
- /* */
- /* <Output> */
- /* length :: The length of the table if found, undefined otherwise. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_goto_table
+ *
+ * @Description:
+ * Looks for a TrueType table by name, then seek a stream to it.
+ *
+ * @Input:
+ * face ::
+ * A face object handle.
+ *
+ * tag ::
+ * The searched tag.
+ *
+ * stream ::
+ * The stream to seek when the table is found.
+ *
+ * @Output:
+ * length ::
+ * The length of the table if found, undefined otherwise.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_goto_table( TT_Face face,
FT_ULong tag,
@@ -200,9 +205,8 @@
if ( FT_STREAM_READ_FIELDS( table_dir_entry_fields, &table ) )
{
- nn--;
FT_TRACE2(( "check_table_dir:"
- " can read only %d table%s in font (instead of %d)\n",
+ " can read only %hu table%s in font (instead of %hu)\n",
nn, nn == 1 ? "" : "s", sfnt->num_tables ));
sfnt->num_tables = nn;
break;
@@ -212,7 +216,7 @@
if ( table.Offset > stream->size )
{
- FT_TRACE2(( "check_table_dir: table entry %d invalid\n", nn ));
+ FT_TRACE2(( "check_table_dir: table entry %hu invalid\n", nn ));
continue;
}
else if ( table.Length > stream->size - table.Offset )
@@ -227,7 +231,7 @@
valid_entries++;
else
{
- FT_TRACE2(( "check_table_dir: table entry %d invalid\n", nn ));
+ FT_TRACE2(( "check_table_dir: table entry %hu invalid\n", nn ));
continue;
}
}
@@ -309,28 +313,31 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_font_dir */
- /* */
- /* <Description> */
- /* Loads the header of a SFNT font file. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* */
- /* stream :: The input stream. */
- /* */
- /* <Output> */
- /* sfnt :: The SFNT header. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* The stream cursor must be at the beginning of the font directory. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_font_dir
+ *
+ * @Description:
+ * Loads the header of a SFNT font file.
+ *
+ * @Input:
+ * face ::
+ * A handle to the target face object.
+ *
+ * stream ::
+ * The input stream.
+ *
+ * @Output:
+ * sfnt ::
+ * The SFNT header.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ *
+ * @Note:
+ * The stream cursor must be at the beginning of the font directory.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_load_font_dir( TT_Face face,
FT_Stream stream )
@@ -354,7 +361,7 @@
};
- FT_TRACE2(( "tt_face_load_font_dir: %08p\n", face ));
+ FT_TRACE2(( "tt_face_load_font_dir: %p\n", (void *)face ));
/* read the offset table */
@@ -373,7 +380,7 @@
/* load the table directory */
- FT_TRACE2(( "-- Number of tables: %10u\n", sfnt.num_tables ));
+ FT_TRACE2(( "-- Number of tables: %10hu\n", sfnt.num_tables ));
FT_TRACE2(( "-- Format version: 0x%08lx\n", sfnt.format_tag ));
if ( sfnt.format_tag != TTAG_OTTO )
@@ -388,7 +395,15 @@
}
}
else
+ {
valid_entries = sfnt.num_tables;
+ if ( !valid_entries )
+ {
+ FT_TRACE2(( "tt_face_load_font_dir: no valid tables found\n" ));
+ error = FT_THROW( Unknown_File_Format );
+ goto Exit;
+ }
+ }
face->num_tables = valid_entries;
face->format_tag = sfnt.format_tag;
@@ -400,9 +415,9 @@
FT_FRAME_ENTER( sfnt.num_tables * 16L ) )
goto Exit;
- FT_TRACE2(( "\n"
- " tag offset length checksum\n"
- " ----------------------------------\n" ));
+ FT_TRACE2(( "\n" ));
+ FT_TRACE2(( " tag offset length checksum\n" ));
+ FT_TRACE2(( " ----------------------------------\n" ));
valid_entries = 0;
for ( nn = 0; nn < sfnt.num_tables; nn++ )
@@ -489,53 +504,66 @@
FT_FRAME_EXIT();
- FT_TRACE2(( "table directory loaded\n\n" ));
+ if ( !valid_entries )
+ {
+ FT_TRACE2(( "tt_face_load_font_dir: no valid tables found\n" ));
+ error = FT_THROW( Unknown_File_Format );
+ goto Exit;
+ }
+
+ FT_TRACE2(( "table directory loaded\n" ));
+ FT_TRACE2(( "\n" ));
Exit:
return error;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_any */
- /* */
- /* <Description> */
- /* Loads any font table into client memory. */
- /* */
- /* <Input> */
- /* face :: The face object to look for. */
- /* */
- /* tag :: The tag of table to load. Use the value 0 if you want */
- /* to access the whole font file, else set this parameter */
- /* to a valid TrueType table tag that you can forge with */
- /* the MAKE_TT_TAG macro. */
- /* */
- /* offset :: The starting offset in the table (or the file if */
- /* tag == 0). */
- /* */
- /* length :: The address of the decision variable: */
- /* */
- /* If length == NULL: */
- /* Loads the whole table. Returns an error if */
- /* `offset' == 0! */
- /* */
- /* If *length == 0: */
- /* Exits immediately; returning the length of the given */
- /* table or of the font file, depending on the value of */
- /* `tag'. */
- /* */
- /* If *length != 0: */
- /* Loads the next `length' bytes of table or font, */
- /* starting at offset `offset' (in table or font too). */
- /* */
- /* <Output> */
- /* buffer :: The address of target buffer. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_any
+ *
+ * @Description:
+ * Loads any font table into client memory.
+ *
+ * @Input:
+ * face ::
+ * The face object to look for.
+ *
+ * tag ::
+ * The tag of table to load. Use the value 0 if you want
+ * to access the whole font file, else set this parameter
+ * to a valid TrueType table tag that you can forge with
+ * the MAKE_TT_TAG macro.
+ *
+ * offset ::
+ * The starting offset in the table (or the file if
+ * tag == 0).
+ *
+ * length ::
+ * The address of the decision variable:
+ *
+ * If length == NULL:
+ * Loads the whole table. Returns an error if
+ * `offset' == 0!
+ *
+ * If *length == 0:
+ * Exits immediately; returning the length of the given
+ * table or of the font file, depending on the value of
+ * `tag'.
+ *
+ * If *length != 0:
+ * Loads the next `length' bytes of table or font,
+ * starting at offset `offset' (in table or font too).
+ *
+ * @Output:
+ * buffer ::
+ * The address of target buffer.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_load_any( TT_Face face,
FT_ULong tag,
@@ -586,22 +614,24 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_generic_header */
- /* */
- /* <Description> */
- /* Loads the TrueType table `head' or `bhed'. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* */
- /* stream :: The input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_generic_header
+ *
+ * @Description:
+ * Loads the TrueType table `head' or `bhed'.
+ *
+ * @Input:
+ * face ::
+ * A handle to the target face object.
+ *
+ * stream ::
+ * The input stream.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
static FT_Error
tt_face_load_generic_header( TT_Face face,
FT_Stream stream,
@@ -622,10 +652,10 @@
FT_FRAME_LONG ( Magic_Number ),
FT_FRAME_USHORT( Flags ),
FT_FRAME_USHORT( Units_Per_EM ),
- FT_FRAME_LONG ( Created[0] ),
- FT_FRAME_LONG ( Created[1] ),
- FT_FRAME_LONG ( Modified[0] ),
- FT_FRAME_LONG ( Modified[1] ),
+ FT_FRAME_ULONG ( Created[0] ),
+ FT_FRAME_ULONG ( Created[1] ),
+ FT_FRAME_ULONG ( Modified[0] ),
+ FT_FRAME_ULONG ( Modified[1] ),
FT_FRAME_SHORT ( xMin ),
FT_FRAME_SHORT ( yMin ),
FT_FRAME_SHORT ( xMax ),
@@ -648,8 +678,8 @@
if ( FT_STREAM_READ_FIELDS( header_fields, header ) )
goto Exit;
- FT_TRACE3(( "Units per EM: %4u\n", header->Units_Per_EM ));
- FT_TRACE3(( "IndexToLoc: %4d\n", header->Index_To_Loc_Format ));
+ FT_TRACE3(( "Units per EM: %4hu\n", header->Units_Per_EM ));
+ FT_TRACE3(( "IndexToLoc: %4hd\n", header->Index_To_Loc_Format ));
Exit:
return error;
@@ -676,22 +706,24 @@
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_maxp */
- /* */
- /* <Description> */
- /* Loads the maximum profile into a face object. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* */
- /* stream :: The input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_maxp
+ *
+ * @Description:
+ * Loads the maximum profile into a face object.
+ *
+ * @Input:
+ * face ::
+ * A handle to the target face object.
+ *
+ * stream ::
+ * The input stream.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_load_maxp( TT_Face face,
FT_Stream stream )
@@ -769,37 +801,39 @@
if ( maxProfile->maxTwilightPoints > ( 0xFFFFU - 4 ) )
{
FT_TRACE0(( "tt_face_load_maxp:"
- " too much twilight points in `maxp' table;\n"
- " "
+ " too much twilight points in `maxp' table;\n" ));
+ FT_TRACE0(( " "
" some glyphs might be rendered incorrectly\n" ));
maxProfile->maxTwilightPoints = 0xFFFFU - 4;
}
}
- FT_TRACE3(( "numGlyphs: %u\n", maxProfile->numGlyphs ));
+ FT_TRACE3(( "numGlyphs: %hu\n", maxProfile->numGlyphs ));
Exit:
return error;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_name */
- /* */
- /* <Description> */
- /* Loads the name records. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* */
- /* stream :: The input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_name
+ *
+ * @Description:
+ * Loads the name records.
+ *
+ * @Input:
+ * face ::
+ * A handle to the target face object.
+ *
+ * stream ::
+ * The input stream.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_load_name( TT_Face face,
FT_Stream stream )
@@ -809,6 +843,8 @@
FT_ULong table_pos, table_len;
FT_ULong storage_start, storage_limit;
TT_NameTable table;
+ TT_Name names = NULL;
+ TT_LangTag langTags = NULL;
static const FT_Frame_Field name_table_fields[] =
{
@@ -889,14 +925,14 @@
storage_start += 2 + 4 * table->numLangTagRecords;
/* allocate language tag records array */
- if ( FT_NEW_ARRAY( table->langTags, table->numLangTagRecords ) ||
- FT_FRAME_ENTER( table->numLangTagRecords * 4 ) )
+ if ( FT_QNEW_ARRAY( langTags, table->numLangTagRecords ) ||
+ FT_FRAME_ENTER( table->numLangTagRecords * 4 ) )
goto Exit;
/* load language tags */
{
- TT_LangTag entry = table->langTags;
- TT_LangTag limit = entry + table->numLangTagRecords;
+ TT_LangTag entry = langTags;
+ TT_LangTag limit = FT_OFFSET( entry, table->numLangTagRecords );
for ( ; entry < limit; entry++ )
@@ -911,7 +947,13 @@
/* invalid entry; ignore it */
entry->stringLength = 0;
}
+
+ /* mark the string as not yet loaded */
+ entry->string = NULL;
}
+
+ table->langTags = langTags;
+ langTags = NULL;
}
FT_FRAME_EXIT();
@@ -920,14 +962,15 @@
}
/* allocate name records array */
- if ( FT_NEW_ARRAY( table->names, table->numNameRecords ) ||
- FT_FRAME_ENTER( table->numNameRecords * 12 ) )
+ if ( FT_QNEW_ARRAY( names, table->numNameRecords ) ||
+ FT_FRAME_ENTER( table->numNameRecords * 12 ) )
goto Exit;
/* load name records */
{
- TT_Name entry = table->names;
+ TT_Name entry = names;
FT_UInt count = table->numNameRecords;
+ FT_UInt valid = 0;
for ( ; count > 0; count-- )
@@ -960,15 +1003,20 @@
}
}
+ /* mark the string as not yet converted */
+ entry->string = NULL;
+
+ valid++;
entry++;
}
/* reduce array size to the actually used elements */
- count = (FT_UInt)( entry - table->names );
- (void)FT_RENEW_ARRAY( table->names,
- table->numNameRecords,
- count );
- table->numNameRecords = count;
+ FT_MEM_QRENEW_ARRAY( names,
+ table->numNameRecords,
+ valid );
+ table->names = names;
+ names = NULL;
+ table->numNameRecords = valid;
}
FT_FRAME_EXIT();
@@ -977,21 +1025,24 @@
face->num_names = (FT_UShort)table->numNameRecords;
Exit:
+ FT_FREE( names );
+ FT_FREE( langTags );
return error;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_free_name */
- /* */
- /* <Description> */
- /* Frees the name records. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_free_name
+ *
+ * @Description:
+ * Frees the name records.
+ *
+ * @Input:
+ * face ::
+ * A handle to the target face object.
+ */
FT_LOCAL_DEF( void )
tt_face_free_name( TT_Face face )
{
@@ -1030,23 +1081,25 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_cmap */
- /* */
- /* <Description> */
- /* Loads the cmap directory in a face object. The cmaps themselves */
- /* are loaded on demand in the `ttcmap.c' module. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* */
- /* stream :: A handle to the input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_cmap
+ *
+ * @Description:
+ * Loads the cmap directory in a face object. The cmaps themselves
+ * are loaded on demand in the `ttcmap.c' module.
+ *
+ * @Input:
+ * face ::
+ * A handle to the target face object.
+ *
+ * stream ::
+ * A handle to the input stream.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_load_cmap( TT_Face face,
@@ -1068,22 +1121,24 @@
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_os2 */
- /* */
- /* <Description> */
- /* Loads the OS2 table. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* */
- /* stream :: A handle to the input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_os2
+ *
+ * @Description:
+ * Loads the OS2 table.
+ *
+ * @Input:
+ * face ::
+ * A handle to the target face object.
+ *
+ * stream ::
+ * A handle to the input stream.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_load_os2( TT_Face face,
FT_Stream stream )
@@ -1217,33 +1272,35 @@
}
}
- FT_TRACE3(( "sTypoAscender: %4d\n", os2->sTypoAscender ));
- FT_TRACE3(( "sTypoDescender: %4d\n", os2->sTypoDescender ));
- FT_TRACE3(( "usWinAscent: %4u\n", os2->usWinAscent ));
- FT_TRACE3(( "usWinDescent: %4u\n", os2->usWinDescent ));
- FT_TRACE3(( "fsSelection: 0x%2x\n", os2->fsSelection ));
+ FT_TRACE3(( "sTypoAscender: %4hd\n", os2->sTypoAscender ));
+ FT_TRACE3(( "sTypoDescender: %4hd\n", os2->sTypoDescender ));
+ FT_TRACE3(( "usWinAscent: %4hu\n", os2->usWinAscent ));
+ FT_TRACE3(( "usWinDescent: %4hu\n", os2->usWinDescent ));
+ FT_TRACE3(( "fsSelection: 0x%2hx\n", os2->fsSelection ));
Exit:
return error;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_postscript */
- /* */
- /* <Description> */
- /* Loads the Postscript table. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* */
- /* stream :: A handle to the input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_postscript
+ *
+ * @Description:
+ * Loads the Postscript table.
+ *
+ * @Input:
+ * face ::
+ * A handle to the target face object.
+ *
+ * stream ::
+ * A handle to the input stream.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_load_post( TT_Face face,
FT_Stream stream )
@@ -1277,10 +1334,16 @@
if ( FT_STREAM_READ_FIELDS( post_fields, post ) )
return error;
+ if ( post->FormatType != 0x00030000L &&
+ post->FormatType != 0x00025000L &&
+ post->FormatType != 0x00020000L &&
+ post->FormatType != 0x00010000L )
+ return FT_THROW( Invalid_Post_Table_Format );
+
/* we don't load the glyph names, we do that in another */
/* module (ttpost). */
- FT_TRACE3(( "FormatType: 0x%x\n", post->FormatType ));
+ FT_TRACE3(( "FormatType: 0x%lx\n", post->FormatType ));
FT_TRACE3(( "isFixedPitch: %s\n", post->isFixedPitch
? " yes" : " no" ));
@@ -1288,22 +1351,24 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_pclt */
- /* */
- /* <Description> */
- /* Loads the PCL 5 Table. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* */
- /* stream :: A handle to the input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_pclt
+ *
+ * @Description:
+ * Loads the PCL 5 Table.
+ *
+ * @Input:
+ * face ::
+ * A handle to the target face object.
+ *
+ * stream ::
+ * A handle to the input stream.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_load_pclt( TT_Face face,
FT_Stream stream )
@@ -1349,22 +1414,24 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_gasp */
- /* */
- /* <Description> */
- /* Loads the `gasp' table into a face object. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* */
- /* stream :: The input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_gasp
+ *
+ * @Description:
+ * Loads the `gasp' table into a face object.
+ *
+ * @Input:
+ * face ::
+ * A handle to the target face object.
+ *
+ * stream ::
+ * The input stream.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_load_gasp( TT_Face face,
FT_Stream stream )
@@ -1372,8 +1439,8 @@
FT_Error error;
FT_Memory memory = stream->memory;
- FT_UInt j,num_ranges;
- TT_GaspRange gaspranges = NULL;
+ FT_UShort j, num_ranges;
+ TT_GaspRange gasp_ranges = NULL;
/* the gasp table is optional */
@@ -1384,8 +1451,8 @@
if ( FT_FRAME_ENTER( 4L ) )
goto Exit;
- face->gasp.version = FT_GET_USHORT();
- face->gasp.numRanges = FT_GET_USHORT();
+ face->gasp.version = FT_GET_USHORT();
+ num_ranges = FT_GET_USHORT();
FT_FRAME_EXIT();
@@ -1397,29 +1464,31 @@
goto Exit;
}
- num_ranges = face->gasp.numRanges;
- FT_TRACE3(( "numRanges: %u\n", num_ranges ));
+ FT_TRACE3(( "numRanges: %hu\n", num_ranges ));
- if ( FT_QNEW_ARRAY( face->gasp.gaspRanges, num_ranges ) ||
- FT_FRAME_ENTER( num_ranges * 4L ) )
+ if ( FT_QNEW_ARRAY( gasp_ranges, num_ranges ) ||
+ FT_FRAME_ENTER( num_ranges * 4L ) )
goto Exit;
- gaspranges = face->gasp.gaspRanges;
-
for ( j = 0; j < num_ranges; j++ )
{
- gaspranges[j].maxPPEM = FT_GET_USHORT();
- gaspranges[j].gaspFlag = FT_GET_USHORT();
+ gasp_ranges[j].maxPPEM = FT_GET_USHORT();
+ gasp_ranges[j].gaspFlag = FT_GET_USHORT();
- FT_TRACE3(( "gaspRange %d: rangeMaxPPEM %5d, rangeGaspBehavior 0x%x\n",
+ FT_TRACE3(( "gaspRange %hu: rangeMaxPPEM %5hu, rangeGaspBehavior 0x%hx\n",
j,
- gaspranges[j].maxPPEM,
- gaspranges[j].gaspFlag ));
+ gasp_ranges[j].maxPPEM,
+ gasp_ranges[j].gaspFlag ));
}
+ face->gasp.gaspRanges = gasp_ranges;
+ gasp_ranges = NULL;
+ face->gasp.numRanges = num_ranges;
+
FT_FRAME_EXIT();
Exit:
+ FT_FREE( gasp_ranges );
return error;
}