ref: b7b163cb077edd6b6355dd465cc9dc1d4d4d7b53
parent: 545a75fdd76cb9f3ae4d4ea3dca4c0b578ea7aee
author: Werner Lemberg <[email protected]>
date: Sun Mar 31 13:48:24 EST 2002
* src/sfnt/ttcmap.c: 16bit fixes (0xFFFF -> 0xFFFFU). * src/sfnt/ttcmap0.c: 16bit fixes. (TT_Build_CMaps): Simplify debug messages. (tt_cmap12_char_next): Fix offset. * src/sfnt/ttload.c (TT_Load_Names, TT_Load_CMap): Fix debug messages. (TT_Load_OS2): 16bit fix.
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
* src/otlayout/otlcommn.c, src/otlayout/otlcommn.h: s/index/idx/.
* src/psaux/t1cmap.c: Ditto.
+ * src/sfnt/ttcmap0.c: Ditto.
* include/freetype/internal/tttypes.h,
include/freetype/internal/sfnt.h (TT_Goto_Table_Func): Renamed to ...
@@ -12,6 +13,16 @@
(TT_Loader_GotoTableFunc): This.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Fix debug
messages.
+ * src/psnames/psmodule.c (psnames_interface)
+ [!FT_CONFIG_OPTION_ADOBE_GLYPH_LIST]: Fix typo.
+ * src/sfnt/sfdriver.c (get_sfnt_table): 16bit fix.
+ * src/sfnt/ttcmap.c: 16bit fixes (0xFFFF -> 0xFFFFU).
+ * src/sfnt/ttcmap0.c: 16bit fixes.
+ (TT_Build_CMaps): Simplify debug messages.
+ (tt_cmap12_char_next): Fix offset.
+ * src/sfnt/ttload.c (TT_Load_Names, TT_Load_CMap): Fix debug
+ messages.
+ (TT_Load_OS2): 16bit fix.
2002-03-30 David Turner <[email protected]>
@@ -439,8 +450,8 @@
* src/type1/t1cmap.h, src/type1/t1cmap.c: Adding (still
experimental) code for Type 1 charmap processing.
- * src/sfnt/ttcmap0.c: Completing the experimental SFNT charmap
- processing.
+ * src/sfnt/ttcmap0.c: New file. It contains a new, still
+ experimental SFNT charmap processing support.
* include/freetype/internal/ftobjs.h: Adding validation support as
well as internal charmap object definitions (FT_CMap != FT_CharMap).
--- a/src/pshinter/descrip.mms
+++ b/src/pshinter/descrip.mms
@@ -3,7 +3,7 @@
#
-# Copyright 2001 by
+# Copyright 2001, 2002 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
--- a/src/pshinter/pshalgo1.c
+++ b/src/pshinter/pshalgo1.c
@@ -4,7 +4,7 @@
/* */
/* PostScript hinting algorithm 1 (body). */
/* */
-/* Copyright 2001 by */
+/* Copyright 2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
--- a/src/pshinter/pshalgo2.c
+++ b/src/pshinter/pshalgo2.c
@@ -4,7 +4,7 @@
/* */
/* PostScript hinting algorithm 2 (body). */
/* */
-/* Copyright 2001 by */
+/* Copyright 2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
--- a/src/pshinter/pshglob.c
+++ b/src/pshinter/pshglob.c
@@ -5,7 +5,7 @@
/* PostScript hinter global hinting management (body). */
/* Inspired by the new auto-hinter module. */
/* */
-/* Copyright 2001 by */
+/* Copyright 2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
--- a/src/pshinter/pshglob.h
+++ b/src/pshinter/pshglob.h
@@ -4,7 +4,7 @@
/* */
/* PostScript hinter global hinting management. */
/* */
-/* Copyright 2001 by */
+/* Copyright 2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
--- a/src/pshinter/pshmod.c
+++ b/src/pshinter/pshmod.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PostScript hinter module implementation (body). */
/* */
-/* Copyright 2001 by */
+/* Copyright 2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
--- a/src/pshinter/pshrec.c
+++ b/src/pshinter/pshrec.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PostScript hints recorder (body). */
/* */
-/* Copyright 2001 by */
+/* Copyright 2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
--- a/src/pshinter/pshrec.h
+++ b/src/pshinter/pshrec.h
@@ -4,7 +4,7 @@
/* */
/* Postscript (Type1/Type2) hints recorder (specification). */
/* */
-/* Copyright 2001 by */
+/* Copyright 2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
--- a/src/psnames/descrip.mms
+++ b/src/psnames/descrip.mms
@@ -3,7 +3,7 @@
#
-# Copyright 2001 by
+# Copyright 2001, 2002 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -4,7 +4,7 @@
/* */
/* PSNames module implementation (body). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -186,8 +186,8 @@
count = (FT_UInt)( map - table->maps );
if ( count > 0 && FT_REALLOC( table->maps,
- num_glyphs * sizeof ( PS_UniMap ),
- count * sizeof ( PS_UniMap ) ) )
+ num_glyphs * sizeof ( PS_UniMap ),
+ count * sizeof ( PS_UniMap ) ) )
count = 0;
if ( count == 0 )
@@ -311,7 +311,6 @@
#else
- 0,
0,
0,
0,
--- a/src/psnames/rules.mk
+++ b/src/psnames/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000 by
+# Copyright 1996-2000, 2001 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType glyph rasterizer (body). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -3211,9 +3211,9 @@
static void
- ft_black_set_mode( TRaster_Instance* raster,
- unsigned long mode,
- const char* palette )
+ ft_black_set_mode( TRaster_Instance* raster,
+ unsigned long mode,
+ const char* palette )
{
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
--- a/src/raster/ftrend1.c
+++ b/src/raster/ftrend1.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType glyph rasterizer interface (body). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
--- a/src/raster/rules.mk
+++ b/src/raster/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000 by
+# Copyright 1996-2000, 2001 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
--- a/src/sfnt/Jamfile
+++ b/src/sfnt/Jamfile
@@ -1,4 +1,4 @@
-# FreeType 2 src/sfnt Jamfile (c) 2001 David Turner
+# FreeType 2 src/sfnt Jamfile (c) 2001, 2002 David Turner
#
SubDir FT2_TOP src sfnt ;
--- a/src/sfnt/descrip.mms
+++ b/src/sfnt/descrip.mms
@@ -3,7 +3,7 @@
#
-# Copyright 2001 by
+# Copyright 2001, 2002 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
--- a/src/sfnt/rules.mk
+++ b/src/sfnt/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000 by
+# Copyright 1996-2000, 2002 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -4,7 +4,7 @@
/* */
/* High-level SFNT driver interface (body). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -58,7 +58,7 @@
break;
case ft_sfnt_os2:
- table = face->os2.version == 0xFFFF ? 0 : &face->os2;
+ table = face->os2.version == 0xFFFFU ? 0 : &face->os2;
break;
case ft_sfnt_post:
@@ -114,7 +114,7 @@
static const char*
get_sfnt_postscript_name( TT_Face face )
{
- FT_Int n, found_win, found_apple;
+ FT_Int n, found_win, found_apple;
const char* result = NULL;
@@ -124,8 +124,8 @@
/* scan the name table to see whether we have a Postscript name here, */
/* either in Macintosh or Windows platform encodings */
- found_win = -1;
- found_apple = -1;
+ found_win = -1;
+ found_apple = -1;
for ( n = 0; n < face->num_names; n++ )
{
@@ -148,16 +148,18 @@
if ( found_win != -1 )
{
- FT_Memory memory = face->root.memory;
+ FT_Memory memory = face->root.memory;
TT_NameEntryRec* name = face->name_table.names + found_win;
- FT_UInt len = name->stringLength/2;
- FT_Error error;
+ FT_UInt len = name->stringLength / 2;
+ FT_Error error;
- if ( !FT_ALLOC( result, len+1 ) )
+
+ if ( !FT_ALLOC( result, len + 1 ) )
{
FT_String* r = (FT_String*)result;
- FT_Byte* p = (FT_Byte*) name->string;
+ FT_Byte* p = (FT_Byte*)name->string;
+
for ( ; len > 0; len--, p += 2 )
{
if ( p[0] == 0 && p[1] >= 32 && p[1] < 128 )
@@ -175,7 +177,8 @@
FT_UInt len = name->stringLength;
FT_Error error;
- if ( !FT_ALLOC( result, len+1 ) )
+
+ if ( !FT_ALLOC( result, len + 1 ) )
{
FT_MEM_COPY( (char*)result, name->string, len );
((char*)result)[len] = '\0';
--- a/src/sfnt/sfnt.c
+++ b/src/sfnt/sfnt.c
@@ -4,7 +4,7 @@
/* */
/* Single object library component. */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -4,7 +4,7 @@
/* */
/* SFNT object management (base). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -39,36 +39,37 @@
- /* convert a UTF-16 name entry to ASCII */
+ /* convert a UTF-16 name entry to ASCII */
static FT_String*
- tt_name_entry_ascii_from_utf16( TT_NameEntry entry,
- FT_Memory memory )
+ tt_name_entry_ascii_from_utf16( TT_NameEntry entry,
+ FT_Memory memory )
{
FT_String* string;
FT_UInt len, code, n;
- FT_Byte* read = (FT_Byte*) entry->string;
-
- len = (FT_UInt) entry->stringLength/2;
-
- if ( FT_MEM_NEW_ARRAY( string, len+1 ) )
+ FT_Byte* read = (FT_Byte*)entry->string;
+
+
+ len = (FT_UInt)entry->stringLength / 2;
+
+ if ( FT_MEM_NEW_ARRAY( string, len + 1 ) )
return NULL;
-
+
for ( n = 0; n < len; n++ )
{
- code = FT_NEXT_USHORT(read);
+ code = FT_NEXT_USHORT( read );
if ( code < 32 || code > 127 )
code = '?';
-
+
string[n] = (char)code;
}
string[len] = 0;
-
+
return string;
- }
+ }
- /* convert a UCS-4 name entry to ASCII */
+ /* convert a UCS-4 name entry to ASCII */
static FT_String*
tt_name_entry_ascii_from_ucs4( TT_NameEntry entry,
FT_Memory memory )
@@ -75,29 +76,30 @@
{
FT_String* string;
FT_UInt len, code, n;
- FT_Byte* read = (FT_Byte*) entry->string;
-
- len = (FT_UInt) entry->stringLength/4;
-
- if ( FT_MEM_NEW_ARRAY( string, len+1 ) )
+ FT_Byte* read = (FT_Byte*)entry->string;
+
+
+ len = (FT_UInt)entry->stringLength / 4;
+
+ if ( FT_MEM_NEW_ARRAY( string, len + 1 ) )
return NULL;
-
+
for ( n = 0; n < len; n++ )
{
- code = FT_NEXT_ULONG(read);
+ code = FT_NEXT_ULONG( read );
if ( code < 32 || code > 127 )
code = '?';
-
+
string[n] = (char)code;
}
string[len] = 0;
-
+
return string;
- }
+ }
- /* convert an Apple Roman or symbol name entry to ASCII */
+ /* convert an Apple Roman or symbol name entry to ASCII */
static FT_String*
tt_name_entry_ascii_from_other( TT_NameEntry entry,
FT_Memory memory )
@@ -104,26 +106,27 @@
{
FT_String* string;
FT_UInt len, code, n;
- FT_Byte* read = (FT_Byte*) entry->string;
-
- len = (FT_UInt) entry->stringLength;
-
- if ( FT_MEM_NEW_ARRAY( string, len+1 ) )
+ FT_Byte* read = (FT_Byte*)entry->string;
+
+
+ len = (FT_UInt)entry->stringLength;
+
+ if ( FT_MEM_NEW_ARRAY( string, len + 1 ) )
return NULL;
-
+
for ( n = 0; n < len; n++ )
{
code = *read++;
if ( code < 32 || code > 127 )
code = '?';
-
+
string[n] = (char)code;
}
string[len] = 0;
-
+
return string;
- }
+ }
/*************************************************************************/
@@ -158,91 +161,79 @@
rec = face->name_table.names;
for ( n = 0; n < face->name_table.numNameRecords; n++, rec++ )
{
- /* according to the OpenType 1.3 specification, only Microsoft of */
- /* Apple platform ids might be used in the 'name' table. The */
- /* 'Unicode' platform is reserved for the 'cmap' table, and */
- /* the 'Iso' one is deprecated */
-
- /* however the Apple TrueType specification doesn't says the same */
- /* thing and goes to suggest that all Unicode 'name' table entries */
- /* should be coded in UTF-16 (in big-endian format I suppose) */
+ /* According to the OpenType 1.3 specification, only Microsoft or */
+ /* Apple platform IDs might be used in the `name' table. The */
+ /* `Unicode' platform is reserved for the `cmap' table, and the */
+ /* `Iso' one is deprecated. */
/* */
+ /* However, the Apple TrueType specification doesn't say the same */
+ /* thing and goes to suggest that all Unicode `name' table entries */
+ /* should be coded in UTF-16 (in big-endian format I suppose). */
+ /* */
if ( rec->nameID == nameid && rec->string )
{
switch ( rec->platformID )
{
+ case TT_PLATFORM_APPLE_UNICODE:
+ case TT_PLATFORM_ISO:
+ /* there is `languageID' to check there. We should use this */
+ /* field only as a last solution when nothing else is */
+ /* available. */
+ /* */
+ found_unicode = n;
+ break;
- case TT_PLATFORM_APPLE_UNICODE:
- case TT_PLATFORM_ISO:
+ case TT_PLATFORM_MACINTOSH:
+ if ( rec->languageID == TT_MAC_LANGID_ENGLISH )
+ found_apple = n;
+
+ break;
+
+ case TT_PLATFORM_MICROSOFT:
+ /* we only take a non-English name when there is nothing */
+ /* else available in the font */
+ /* */
+ if ( found_win == -1 || ( rec->languageID & 0x3FF ) == 0x009 )
+ {
+ switch ( rec->encodingID )
{
- /* there is 'languageID' to check there. We should use this */
- /* field only as a last solution when nothing else is */
- /* available.. */
- /* */
- found_unicode = n;
+ case TT_MS_ID_SYMBOL_CS:
+ case TT_MS_ID_UNICODE_CS:
+ case TT_MS_ID_UCS_4:
+ found_win = n;
break;
+
+ default:
+ ;
}
-
- case TT_PLATFORM_MACINTOSH:
- {
- if ( rec->languageID == TT_MAC_LANGID_ENGLISH )
- found_apple = n;
-
- break;
- }
-
- case TT_PLATFORM_MICROSOFT:
- {
- /* we only take a non-English name when there is nothing */
- /* else available in the font.. */
- /* */
- if ( found_win == -1 || (rec->languageID & 0x3FF) == 0x009 )
- {
- switch ( rec->encodingID )
- {
- case TT_MS_ID_SYMBOL_CS:
- case TT_MS_ID_UNICODE_CS:
- case TT_MS_ID_UCS_4:
- found_win = n;
- break;
-
- default:
- ;
- }
- }
- break;
- }
-
- default:
- ;
+ }
+ break;
+
+ default:
+ ;
}
}
}
- /* some fonts contain invalid Unicode or Macintosh formatted entries */
- /* we will thus favor name encoded in Windows formats when they're */
- /* available.. */
- /* */
+ /* some fonts contain invalid Unicode or Macintosh formatted entries; */
+ /* we will thus favor names encoded in Windows formats if available */
+ /* */
if ( found_win >= 0 )
{
rec = face->name_table.names + found_win;
switch ( rec->encodingID )
{
- case TT_MS_ID_UNICODE_CS:
- case TT_MS_ID_SYMBOL_CS:
- {
- result = tt_name_entry_ascii_from_utf16( rec, memory );
- break;
- }
-
- case TT_MS_ID_UCS_4:
- {
- result = tt_name_entry_ascii_from_ucs4( rec, memory );
- break;
- }
-
- default:
- ;
+ case TT_MS_ID_UNICODE_CS:
+ case TT_MS_ID_SYMBOL_CS:
+ result = tt_name_entry_ascii_from_utf16( rec, memory );
+ break;
+
+ case TT_MS_ID_UCS_4:
+ result = tt_name_entry_ascii_from_ucs4( rec, memory );
+ break;
+
+ default:
+ ;
}
}
else if ( found_apple >= 0 )
@@ -255,7 +246,7 @@
rec = face->name_table.names + found_unicode;
result = tt_name_entry_ascii_from_utf16( rec, memory );
}
-
+
return result;
}
@@ -321,12 +312,13 @@
FT_Error error;
FT_Library library = face->root.driver->root.library;
SFNT_Service sfnt;
- SFNT_HeaderRec sfnt_header;
+ SFNT_HeaderRec sfnt_header;
/* for now, parameters are unused */
FT_UNUSED( num_params );
FT_UNUSED( params );
+
sfnt = (SFNT_Service)face->sfnt;
if ( !sfnt )
{
@@ -344,7 +336,7 @@
if ( !face->psnames )
{
face->psnames = (PSNames_Service)
- FT_Get_Module_Interface( library, "psnames" );
+ FT_Get_Module_Interface( library, "psnames" );
}
/* check that we have a valid TrueType file */
@@ -381,9 +373,9 @@
FT_Int num_params,
FT_Parameter* params )
{
- FT_Error error;
- FT_Bool has_outline;
- FT_Bool is_apple_sbit;
+ FT_Error error;
+ FT_Bool has_outline;
+ FT_Bool is_apple_sbit;
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
@@ -433,7 +425,6 @@
(void)LOAD_( max_profile );
(void)LOAD_( charmaps );
-
/* the following tables are optional in PCL fonts -- */
/* don't check for errors */
(void)LOAD_( names );
@@ -470,6 +461,7 @@
else
goto Exit;
}
+
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
if ( LOAD_( hdmx ) ||
@@ -478,15 +470,17 @@
LOAD_( pclt ) )
goto Exit;
- face->root.family_name = tt_face_get_name( face, TT_NAME_ID_FONT_FAMILY );
- face->root.style_name = tt_face_get_name( face, TT_NAME_ID_FONT_SUBFAMILY );
+ face->root.family_name = tt_face_get_name( face,
+ TT_NAME_ID_FONT_FAMILY );
+ face->root.style_name = tt_face_get_name( face,
+ TT_NAME_ID_FONT_SUBFAMILY );
/* now set up root fields */
{
- FT_Face root = &face->root;
- FT_Int flags = 0;
- FT_Int n;
- FT_Memory memory;
+ FT_Face root = &face->root;
+ FT_Int flags = 0;
+ FT_Int n;
+ FT_Memory memory;
memory = root->memory;
@@ -557,19 +551,21 @@
#ifdef FT_CONFIG_OPTION_USE_CMAPS
TT_Build_CMaps( face ); /* ignore errors */
-
-
+
+
/* set the encoding fields */
{
FT_Int m;
-
+
+
for ( m = 0; m < root->num_charmaps; m++ )
{
FT_CharMap charmap = root->charmaps[m];
-
+
+
charmap->encoding = sfnt_find_encoding( charmap->platform_id,
charmap->encoding_id );
-
+
if ( root->charmap == NULL &&
charmap->encoding == ft_encoding_unicode )
{
@@ -580,34 +576,35 @@
}
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
-
+
{
TT_CharMap charmap = face->charmaps;
-
+
+
charmap = face->charmaps;
root->num_charmaps = face->num_charmaps;
-
+
/* allocate table of pointers */
if ( FT_NEW_ARRAY( root->charmaps, root->num_charmaps ) )
goto Exit;
-
+
for ( n = 0; n < root->num_charmaps; n++, charmap++ )
{
FT_Int platform = charmap->cmap.platformID;
FT_Int encoding = charmap->cmap.platformEncodingID;
-
-
+
+
charmap->root.face = (FT_Face)face;
charmap->root.platform_id = (FT_UShort)platform;
charmap->root.encoding_id = (FT_UShort)encoding;
charmap->root.encoding = sfnt_find_encoding( platform, encoding );
-
+
/* now, set root->charmap with a unicode charmap */
/* wherever available */
if ( !root->charmap &&
charmap->root.encoding == ft_encoding_unicode )
root->charmap = (FT_CharMap)charmap;
-
+
root->charmaps[n] = (FT_CharMap)charmap;
}
}
@@ -622,7 +619,8 @@
root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
#if 0
- /* I don't know criteria whether layout is horizontal or vertical */
+ /* XXX: I don't know criteria whether layout is horizontal */
+ /* or vertical. */
if ( has_outline.... )
{
...
@@ -753,7 +751,7 @@
FT_LOCAL_DEF( void )
SFNT_Done_Face( TT_Face face )
{
- FT_Memory memory = face->root.memory;
+ FT_Memory memory = face->root.memory;
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
@@ -783,8 +781,9 @@
#ifdef FT_CONFIG_OPTION_USE_CMAPS
{
- FT_Stream stream = FT_FACE_STREAM(face);
-
+ FT_Stream stream = FT_FACE_STREAM( face );
+
+
/* simply release the 'cmap' table frame */
FT_FRAME_RELEASE( face->cmap_table );
face->cmap_size = 0;
--- a/src/sfnt/sfobjs.h
+++ b/src/sfnt/sfobjs.h
@@ -4,7 +4,7 @@
/* */
/* SFNT object management (specification). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -4,7 +4,7 @@
/* */
/* TrueType character mapping table (cmap) support (body). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -35,52 +35,52 @@
FT_CALLBACK_DEF( FT_UInt )
- code_to_index0( TT_CMapTable charmap,
- FT_ULong char_code );
+ code_to_index0( TT_CMapTable charmap,
+ FT_ULong char_code );
FT_CALLBACK_DEF( FT_ULong )
- code_to_next0( TT_CMapTable charmap,
- FT_ULong char_code );
+ code_to_next0( TT_CMapTable charmap,
+ FT_ULong char_code );
FT_CALLBACK_DEF( FT_UInt )
- code_to_index2( TT_CMapTable charmap,
- FT_ULong char_code );
+ code_to_index2( TT_CMapTable charmap,
+ FT_ULong char_code );
FT_CALLBACK_DEF( FT_ULong )
- code_to_next2( TT_CMapTable charmap,
- FT_ULong char_code );
+ code_to_next2( TT_CMapTable charmap,
+ FT_ULong char_code );
FT_CALLBACK_DEF( FT_UInt )
- code_to_index4( TT_CMapTable charmap,
- FT_ULong char_code );
+ code_to_index4( TT_CMapTable charmap,
+ FT_ULong char_code );
FT_CALLBACK_DEF( FT_ULong )
- code_to_next4( TT_CMapTable charmap,
- FT_ULong char_code );
+ code_to_next4( TT_CMapTable charmap,
+ FT_ULong char_code );
FT_CALLBACK_DEF( FT_UInt )
- code_to_index6( TT_CMapTable charmap,
- FT_ULong char_code );
+ code_to_index6( TT_CMapTable charmap,
+ FT_ULong char_code );
FT_CALLBACK_DEF( FT_ULong )
- code_to_next6( TT_CMapTable charmap,
- FT_ULong char_code );
+ code_to_next6( TT_CMapTable charmap,
+ FT_ULong char_code );
FT_CALLBACK_DEF( FT_UInt )
- code_to_index8_12( TT_CMapTable charmap,
- FT_ULong char_code );
+ code_to_index8_12( TT_CMapTable charmap,
+ FT_ULong char_code );
FT_CALLBACK_DEF( FT_ULong )
- code_to_next8_12( TT_CMapTable charmap,
- FT_ULong char_code );
+ code_to_next8_12( TT_CMapTable charmap,
+ FT_ULong char_code );
FT_CALLBACK_DEF( FT_UInt )
- code_to_index10( TT_CMapTable charmap,
- FT_ULong char_code );
+ code_to_index10( TT_CMapTable charmap,
+ FT_ULong char_code );
FT_CALLBACK_DEF( FT_ULong )
- code_to_next10( TT_CMapTable charmap,
- FT_ULong char_code );
+ code_to_next10( TT_CMapTable charmap,
+ FT_ULong char_code );
/*************************************************************************/
@@ -93,6 +93,7 @@
/* */
/* <Input> */
/* face :: A handle to the parent face object. */
+ /* */
/* stream :: A handle to the current stream object. */
/* */
/* <InOut> */
@@ -107,27 +108,27 @@
/* released. */
/* */
FT_LOCAL_DEF( FT_Error )
- TT_CharMap_Load( TT_Face face,
- TT_CMapTable cmap,
- FT_Stream stream )
+ TT_CharMap_Load( TT_Face face,
+ TT_CMapTable cmap,
+ FT_Stream stream )
{
- FT_Error error;
- FT_Memory memory;
- FT_UShort num_SH, num_Seg, i;
- FT_ULong j, n;
+ FT_Error error;
+ FT_Memory memory;
+ FT_UShort num_SH, num_Seg, i;
+ FT_ULong j, n;
- FT_UShort u, l;
+ FT_UShort u, l;
- TT_CMap0 cmap0;
- TT_CMap2 cmap2;
- TT_CMap4 cmap4;
- TT_CMap6 cmap6;
+ TT_CMap0 cmap0;
+ TT_CMap2 cmap2;
+ TT_CMap4 cmap4;
+ TT_CMap6 cmap6;
TT_CMap8_12 cmap8_12;
TT_CMap10 cmap10;
- TT_CMap2SubHeader cmap2sub;
- TT_CMap4Segment segments;
- TT_CMapGroup groups;
+ TT_CMap2SubHeader cmap2sub;
+ TT_CMap4Segment segments;
+ TT_CMapGroup groups;
if ( cmap->loaded )
@@ -143,12 +144,12 @@
case 0:
cmap0 = &cmap->c.cmap0;
- if ( FT_READ_USHORT( cmap0->language ) ||
- FT_ALLOC( cmap0->glyphIdArray, 256L ) ||
+ if ( FT_READ_USHORT( cmap0->language ) ||
+ FT_ALLOC( cmap0->glyphIdArray, 256L ) ||
FT_STREAM_READ( cmap0->glyphIdArray, 256L ) )
goto Fail;
- cmap->get_index = code_to_index0;
+ cmap->get_index = code_to_index0;
cmap->get_next_char = code_to_next0;
break;
@@ -159,7 +160,7 @@
/* allocate subheader keys */
if ( FT_NEW_ARRAY( cmap2->subHeaderKeys, 256 ) ||
- FT_FRAME_ENTER( 2L + 512L ) )
+ FT_FRAME_ENTER( 2L + 512L ) )
goto Fail;
cmap2->language = FT_GET_USHORT();
@@ -178,10 +179,10 @@
/* load subheaders */
cmap2->numGlyphId = l = (FT_UShort)(
- ( ( cmap->length - 2L * ( 256 + 3 ) - num_SH * 8L ) & 0xFFFF ) / 2 );
+ ( ( cmap->length - 2L * ( 256 + 3 ) - num_SH * 8L ) & 0xFFFFU ) / 2 );
- if ( FT_NEW_ARRAY( cmap2->subHeaders, num_SH + 1 ) ||
- FT_FRAME_ENTER( ( num_SH + 1 ) * 8L ) )
+ if ( FT_NEW_ARRAY( cmap2->subHeaders, num_SH + 1 ) ||
+ FT_FRAME_ENTER( ( num_SH + 1 ) * 8L ) )
{
FT_FREE( cmap2->subHeaderKeys );
goto Fail;
@@ -249,15 +250,15 @@
segments = cmap4->segments;
for ( i = 0; i < num_Seg; i++ )
- segments[i].endCount = FT_GET_USHORT();
+ segments[i].endCount = FT_GET_USHORT();
(void)FT_GET_USHORT();
for ( i = 0; i < num_Seg; i++ )
- segments[i].startCount = FT_GET_USHORT();
+ segments[i].startCount = FT_GET_USHORT();
for ( i = 0; i < num_Seg; i++ )
- segments[i].idDelta = FT_GET_SHORT();
+ segments[i].idDelta = FT_GET_SHORT();
for ( i = 0; i < num_Seg; i++ )
segments[i].idRangeOffset = FT_GET_USHORT();
@@ -265,7 +266,7 @@
FT_FRAME_EXIT();
cmap4->numGlyphId = l = (FT_UShort)(
- ( ( cmap->length - ( 16L + 8L * num_Seg ) ) & 0xFFFF ) / 2 );
+ ( ( cmap->length - ( 16L + 8L * num_Seg ) ) & 0xFFFFU ) / 2 );
/* load IDs */
@@ -283,7 +284,7 @@
cmap4->last_segment = cmap4->segments;
- cmap->get_index = code_to_index4;
+ cmap->get_index = code_to_index4;
cmap->get_next_char = code_to_next4;
break;
@@ -309,7 +310,7 @@
cmap6->glyphIdArray[i] = FT_GET_USHORT();
FT_FRAME_EXIT();
- cmap->get_index = code_to_index6;
+ cmap->get_index = code_to_index6;
cmap->get_next_char = code_to_next6;
break;
@@ -351,7 +352,7 @@
cmap8_12->last_group = cmap8_12->groups;
- cmap->get_index = code_to_index8_12;
+ cmap->get_index = code_to_index8_12;
cmap->get_next_char = code_to_next8_12;
break;
@@ -378,7 +379,7 @@
cmap10->glyphs[j] = FT_GET_USHORT();
FT_FRAME_EXIT();
- cmap->get_index = code_to_index10;
+ cmap->get_index = code_to_index10;
cmap->get_next_char = code_to_next10;
break;
@@ -405,6 +406,7 @@
/* */
/* <Input> */
/* face :: A handle to the parent face object. */
+ /* */
/* cmap :: A handle to a cmap object. */
/* */
/* <Return> */
@@ -411,8 +413,8 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
- TT_CharMap_Free( TT_Face face,
- TT_CMapTable cmap )
+ TT_CharMap_Free( TT_Face face,
+ TT_CMapTable cmap )
{
FT_Memory memory;
@@ -478,6 +480,7 @@
/* */
/* <Input> */
/* charCode :: The wanted character code. */
+ /* */
/* cmap0 :: A pointer to a cmap table in format 0. */
/* */
/* <Return> */
@@ -484,10 +487,10 @@
/* Glyph index into the glyphs array. 0 if the glyph does not exist. */
/* */
FT_CALLBACK_DEF( FT_UInt )
- code_to_index0( TT_CMapTable cmap,
- FT_ULong charCode )
+ code_to_index0( TT_CMapTable cmap,
+ FT_ULong charCode )
{
- TT_CMap0 cmap0 = &cmap->c.cmap0;
+ TT_CMap0 cmap0 = &cmap->c.cmap0;
return ( charCode <= 0xFF ? cmap0->glyphIdArray[charCode] : 0 );
@@ -506,6 +509,7 @@
/* */
/* <Input> */
/* charCode :: The wanted character code. */
+ /* */
/* cmap0 :: A pointer to a cmap table in format 0. */
/* */
/* <Return> */
@@ -512,10 +516,10 @@
/* Next char code. 0 if no higher one is encoded. */
/* */
FT_CALLBACK_DEF( FT_ULong )
- code_to_next0( TT_CMapTable cmap,
- FT_ULong charCode )
+ code_to_next0( TT_CMapTable cmap,
+ FT_ULong charCode )
{
- TT_CMap0 cmap0 = &cmap->c.cmap0;
+ TT_CMap0 cmap0 = &cmap->c.cmap0;
while ( ++charCode <= 0xFF )
@@ -535,6 +539,7 @@
/* */
/* <Input> */
/* charCode :: The wanted character code. */
+ /* */
/* cmap2 :: A pointer to a cmap table in format 2. */
/* */
/* <Return> */
@@ -541,14 +546,14 @@
/* Glyph index into the glyphs array. 0 if the glyph does not exist. */
/* */
FT_CALLBACK_DEF( FT_UInt )
- code_to_index2( TT_CMapTable cmap,
- FT_ULong charCode )
+ code_to_index2( TT_CMapTable cmap,
+ FT_ULong charCode )
{
- FT_UInt result, index1, offset;
- FT_UInt char_lo;
- FT_ULong char_hi;
- TT_CMap2SubHeader sh2;
- TT_CMap2 cmap2;
+ FT_UInt result, index1, offset;
+ FT_UInt char_lo;
+ FT_ULong char_hi;
+ TT_CMap2SubHeader sh2;
+ TT_CMap2 cmap2;
cmap2 = &cmap->c.cmap2;
@@ -582,7 +587,7 @@
{
result = cmap2->glyphIdArray[offset];
if ( result )
- result = ( result + sh2->idDelta ) & 0xFFFF;
+ result = ( result + sh2->idDelta ) & 0xFFFFU;
}
}
@@ -600,6 +605,7 @@
/* */
/* <Input> */
/* charCode :: The wanted character code. */
+ /* */
/* cmap2 :: A pointer to a cmap table in format 2. */
/* */
/* <Return> */
@@ -606,14 +612,14 @@
/* Next encoded character. 0 if none exists. */
/* */
FT_CALLBACK_DEF( FT_ULong )
- code_to_next2( TT_CMapTable cmap,
- FT_ULong charCode )
+ code_to_next2( TT_CMapTable cmap,
+ FT_ULong charCode )
{
- FT_UInt index1, offset;
- FT_UInt char_lo;
- FT_ULong char_hi;
- TT_CMap2SubHeader sh2;
- TT_CMap2 cmap2;
+ FT_UInt index1, offset;
+ FT_UInt char_lo;
+ FT_ULong char_hi;
+ TT_CMap2SubHeader sh2;
+ TT_CMap2 cmap2;
cmap2 = &cmap->c.cmap2;
@@ -683,6 +689,7 @@
/* */
/* <Input> */
/* charCode :: The wanted character code. */
+ /* */
/* cmap4 :: A pointer to a cmap table in format 4. */
/* */
/* <Return> */
@@ -689,11 +696,11 @@
/* Glyph index into the glyphs array. 0 if the glyph does not exist. */
/* */
FT_CALLBACK_DEF( FT_UInt )
- code_to_index4( TT_CMapTable cmap,
- FT_ULong charCode )
+ code_to_index4( TT_CMapTable cmap,
+ FT_ULong charCode )
{
- FT_UInt result, index1, segCount;
- TT_CMap4 cmap4;
+ FT_UInt result, index1, segCount;
+ TT_CMap4 cmap4;
TT_CMap4SegmentRec *seg4, *limit;
@@ -739,7 +746,7 @@
/* directly */
if ( seg4->idRangeOffset == 0 )
- result = ( charCode + seg4->idDelta ) & 0xFFFF;
+ result = ( charCode + seg4->idDelta ) & 0xFFFFU;
else
{
/* otherwise, we must use the glyphIdArray to do it */
@@ -750,7 +757,7 @@
if ( index1 < (FT_UInt)cmap4->numGlyphId &&
cmap4->glyphIdArray[index1] != 0 )
- result = ( cmap4->glyphIdArray[index1] + seg4->idDelta ) & 0xFFFF;
+ result = ( cmap4->glyphIdArray[index1] + seg4->idDelta ) & 0xFFFFU;
}
return result;
@@ -767,6 +774,7 @@
/* */
/* <Input> */
/* charCode :: The wanted character code. */
+ /* */
/* cmap :: A pointer to a cmap table in format 4. */
/* */
/* <Return> */
@@ -773,11 +781,11 @@
/* Next encoded character. 0 if none exists. */
/* */
FT_CALLBACK_DEF( FT_ULong )
- code_to_next4( TT_CMapTable cmap,
- FT_ULong charCode )
+ code_to_next4( TT_CMapTable cmap,
+ FT_ULong charCode )
{
- FT_UInt index1, segCount;
- TT_CMap4 cmap4;
+ FT_UInt index1, segCount;
+ TT_CMap4 cmap4;
TT_CMap4SegmentRec *seg4, *limit;
@@ -834,6 +842,7 @@
/* */
/* <Input> */
/* charCode :: The wanted character code. */
+ /* */
/* cmap6 :: A pointer to a cmap table in format 6. */
/* */
/* <Return> */
@@ -840,11 +849,11 @@
/* Glyph index into the glyphs array. 0 if the glyph does not exist. */
/* */
FT_CALLBACK_DEF( FT_UInt )
- code_to_index6( TT_CMapTable cmap,
- FT_ULong charCode )
+ code_to_index6( TT_CMapTable cmap,
+ FT_ULong charCode )
{
- TT_CMap6 cmap6;
- FT_UInt result = 0;
+ TT_CMap6 cmap6;
+ FT_UInt result = 0;
cmap6 = &cmap->c.cmap6;
@@ -867,6 +876,7 @@
/* */
/* <Input> */
/* charCode :: The wanted character code. */
+ /* */
/* cmap :: A pointer to a cmap table in format 6. */
/* */
/* <Return> */
@@ -873,10 +883,10 @@
/* Next encoded character. 0 if none exists. */
/* */
FT_CALLBACK_DEF( FT_ULong )
- code_to_next6( TT_CMapTable cmap,
- FT_ULong charCode )
+ code_to_next6( TT_CMapTable cmap,
+ FT_ULong charCode )
{
- TT_CMap6 cmap6;
+ TT_CMap6 cmap6;
charCode++;
@@ -910,6 +920,7 @@
/* */
/* <Input> */
/* charCode :: The wanted character code. */
+ /* */
/* cmap8_12 :: A pointer to a cmap table in format 8 or 12. */
/* */
/* <Return> */
@@ -916,10 +927,10 @@
/* Glyph index into the glyphs array. 0 if the glyph does not exist. */
/* */
FT_CALLBACK_DEF( FT_UInt )
- code_to_index8_12( TT_CMapTable cmap,
- FT_ULong charCode )
+ code_to_index8_12( TT_CMapTable cmap,
+ FT_ULong charCode )
{
- TT_CMap8_12 cmap8_12;
+ TT_CMap8_12 cmap8_12;
TT_CMapGroupRec *group, *limit;
@@ -974,6 +985,7 @@
/* */
/* <Input> */
/* charCode :: The wanted character code. */
+ /* */
/* cmap :: A pointer to a cmap table in format 8 or 12. */
/* */
/* <Return> */
@@ -980,10 +992,10 @@
/* Next encoded character. 0 if none exists. */
/* */
FT_CALLBACK_DEF( FT_ULong )
- code_to_next8_12( TT_CMapTable cmap,
- FT_ULong charCode )
+ code_to_next8_12( TT_CMapTable cmap,
+ FT_ULong charCode )
{
- TT_CMap8_12 cmap8_12;
+ TT_CMap8_12 cmap8_12;
TT_CMapGroupRec *group, *limit;
@@ -1020,6 +1032,7 @@
/* */
/* <Input> */
/* charCode :: The wanted character code. */
+ /* */
/* cmap10 :: A pointer to a cmap table in format 10. */
/* */
/* <Return> */
@@ -1026,11 +1039,11 @@
/* Glyph index into the glyphs array. 0 if the glyph does not exist. */
/* */
FT_CALLBACK_DEF( FT_UInt )
- code_to_index10( TT_CMapTable cmap,
- FT_ULong charCode )
+ code_to_index10( TT_CMapTable cmap,
+ FT_ULong charCode )
{
TT_CMap10 cmap10;
- FT_UInt result = 0;
+ FT_UInt result = 0;
cmap10 = &cmap->c.cmap10;
@@ -1057,6 +1070,7 @@
/* */
/* <Input> */
/* charCode :: The wanted character code. */
+ /* */
/* cmap :: A pointer to a cmap table in format 10. */
/* */
/* <Return> */
@@ -1063,8 +1077,8 @@
/* Next encoded character. 0 if none exists. */
/* */
FT_CALLBACK_DEF( FT_ULong )
- code_to_next10( TT_CMapTable cmap,
- FT_ULong charCode )
+ code_to_next10( TT_CMapTable cmap,
+ FT_ULong charCode )
{
TT_CMap10 cmap10;
--- a/src/sfnt/ttcmap.h
+++ b/src/sfnt/ttcmap.h
@@ -4,7 +4,7 @@
/* */
/* TrueType character mapping table (cmap) support (specification). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -28,13 +28,13 @@
FT_LOCAL( FT_Error )
- TT_CharMap_Load( TT_Face face,
- TT_CMapTable cmap,
- FT_Stream input );
+ TT_CharMap_Load( TT_Face face,
+ TT_CMapTable cmap,
+ FT_Stream input );
FT_LOCAL( FT_Error )
- TT_CharMap_Free( TT_Face face,
- TT_CMapTable cmap );
+ TT_CharMap_Free( TT_Face face,
+ TT_CMapTable cmap );
FT_END_HEADER
--- a/src/sfnt/ttcmap0.c
+++ b/src/sfnt/ttcmap0.c
@@ -1,10 +1,10 @@
/***************************************************************************/
/* */
-/* ttcmap.c */
+/* ttcmap0.c */
/* */
-/* TrueType character mapping table (cmap) support (body). */
+/* TrueType new character mapping table (cmap) support (body). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -35,21 +35,20 @@
#define FT_COMPONENT trace_ttcmap
+#define TT_PEEK_SHORT FT_PEEK_SHORT
+#define TT_PEEK_USHORT FT_PEEK_USHORT
+#define TT_PEEK_LONG FT_PEEK_LONG
+#define TT_PEEK_ULONG FT_PEEK_ULONG
-#define TT_PEEK_SHORT FT_PEEK_SHORT
-#define TT_PEEK_USHORT FT_PEEK_USHORT
-#define TT_PEEK_LONG FT_PEEK_LONG
-#define TT_PEEK_ULONG FT_PEEK_ULONG
+#define TT_NEXT_SHORT FT_NEXT_SHORT
+#define TT_NEXT_USHORT FT_NEXT_USHORT
+#define TT_NEXT_LONG FT_NEXT_LONG
+#define TT_NEXT_ULONG FT_NEXT_ULONG
-#define TT_NEXT_SHORT FT_NEXT_SHORT
-#define TT_NEXT_USHORT FT_NEXT_USHORT
-#define TT_NEXT_LONG FT_NEXT_LONG
-#define TT_NEXT_ULONG FT_NEXT_ULONG
-
FT_CALLBACK_DEF( FT_Error )
- tt_cmap_init( TT_CMap cmap,
- FT_Byte* table )
+ tt_cmap_init( TT_CMap cmap,
+ FT_Byte* table )
{
cmap->data = table;
return 0;
@@ -56,27 +55,27 @@
}
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** FORMAT 0 *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** FORMAT 0 *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
- /*************************************************************************
- *
- * TABLE OVERVIEW:
- * ---------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 0
- * length 2 USHORT table length in bytes
- * language 4 USHORT Mac language code
- * glyph_ids 6 BYTE[256] array of glyph indices
- * 262
- */
+ /*************************************************************************/
+ /* */
+ /* TABLE OVERVIEW */
+ /* -------------- */
+ /* */
+ /* NAME OFFSET TYPE DESCRIPTION */
+ /* */
+ /* format 0 USHORT must be 0 */
+ /* length 2 USHORT table length in bytes */
+ /* language 4 USHORT Mac language code */
+ /* glyph_ids 6 BYTE[256] array of glyph indices */
+ /* 262 */
+ /* */
#ifdef TT_CONFIG_CMAP_FORMAT_0
@@ -85,8 +84,9 @@
FT_Validator valid )
{
FT_Byte* p = table + 2;
- FT_UInt length = TT_NEXT_USHORT(p);
+ FT_UInt length = TT_NEXT_USHORT( p );
+
if ( table + length > valid->limit || length < 262 )
FT_INVALID_TOO_SHORT;
@@ -93,13 +93,14 @@
/* check glyph indices whenever necessary */
if ( valid->level >= FT_VALIDATE_TIGHT )
{
- FT_UInt n, index;
+ FT_UInt n, idx;
+
p = table + 6;
for ( n = 0; n < 256; n++ )
{
- index = *p++;
- if ( index >= TT_VALID_GLYPH_COUNT(valid) )
+ idx = *p++;
+ if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
@@ -112,13 +113,14 @@
{
FT_Byte* table = cmap->data;
- return ( char_code < 256 ? table[6+char_code] : 0 );
+
+ return char_code < 256 ? table[6 + char_code] : 0;
}
FT_CALLBACK_DEF( FT_UInt )
- tt_cmap0_char_next( TT_CMap cmap,
- FT_UInt32 *pchar_code )
+ tt_cmap0_char_next( TT_CMap cmap,
+ FT_UInt32 *pchar_code )
{
FT_Byte* table = cmap->data;
FT_UInt32 charcode = *pchar_code;
@@ -125,6 +127,7 @@
FT_UInt32 result = 0;
FT_UInt gindex = 0;
+
table += 6; /* go to glyph ids */
while ( ++charcode < 256 )
{
@@ -141,107 +144,109 @@
}
- FT_CALLBACK_TABLE_DEF const TT_CMap_ClassRec tt_cmap0_class_rec =
+ FT_CALLBACK_TABLE_DEF
+ const TT_CMap_ClassRec tt_cmap0_class_rec =
{
{
sizeof( TT_CMapRec ),
- (FT_CMap_InitFunc) tt_cmap_init,
- (FT_CMap_DoneFunc) NULL,
- (FT_CMap_CharIndexFunc) tt_cmap0_char_index,
- (FT_CMap_CharNextFunc) tt_cmap0_char_next
+ (FT_CMap_InitFunc) tt_cmap_init,
+ (FT_CMap_DoneFunc) NULL,
+ (FT_CMap_CharIndexFunc)tt_cmap0_char_index,
+ (FT_CMap_CharNextFunc) tt_cmap0_char_next
},
0,
- (TT_CMap_ValidateFunc) tt_cmap0_validate
+ (TT_CMap_ValidateFunc) tt_cmap0_validate
};
#endif /* TT_CONFIG_CMAP_FORMAT_0 */
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** FORMAT 2 *****/
- /***** *****/
- /***** This is used for certain CJK encodings that encode text *****/
- /***** in a mixed 8/16 bits along the following lines: *****/
- /***** *****/
- /***** * certain byte values correspond to an 8-bit character code *****/
- /***** (typicall in the range 0..127 for ASCII compatibility) *****/
- /***** *****/
- /***** * certain byte values signal the first byte of a 2-byte *****/
- /***** character code (but these values are also valid as the *****/
- /***** second byte of a 2-byte character) *****/
- /***** *****/
- /***** the following charmap lookup and iteration function all *****/
- /***** assume that the value "charcode" correspond to following: *****/
- /***** *****/
- /***** - for one byte characters, "charcode" is simply the *****/
- /***** character code *****/
- /***** *****/
- /***** - for two byte characters, "charcode" is the 2-byte *****/
- /***** character code in big endian format. More exactly: *****/
- /***** *****/
- /***** (charcode >> 8) is the first byte value *****/
- /***** (charcode & 0xFF) is the second byte value *****/
- /***** *****/
- /***** note that not all values of "charcode" are valid *****/
- /***** according to these rules, and the function moderately *****/
- /***** check the arguments.. *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** FORMAT 2 *****/
+ /***** *****/
+ /***** This is used for certain CJK encodings that encode text in a *****/
+ /***** mixed 8/16 bits encoding along the following lines: *****/
+ /***** *****/
+ /***** * Certain byte values correspond to an 8-bit character code *****/
+ /***** (typically in the range 0..127 for ASCII compatibility). *****/
+ /***** *****/
+ /***** * Certain byte values signal the first byte of a 2-byte *****/
+ /***** character code (but these values are also valid as the *****/
+ /***** second byte of a 2-byte character). *****/
+ /***** *****/
+ /***** The following charmap lookup and iteration functions all *****/
+ /***** assume that the value "charcode" correspond to following: *****/
+ /***** *****/
+ /***** - For one byte characters, "charcode" is simply the *****/
+ /***** character code. *****/
+ /***** *****/
+ /***** - For two byte characters, "charcode" is the 2-byte *****/
+ /***** character code in big endian format. More exactly: *****/
+ /***** *****/
+ /***** (charcode >> 8) is the first byte value *****/
+ /***** (charcode & 0xFF) is the second byte value *****/
+ /***** *****/
+ /***** Note that not all values of "charcode" are valid according *****/
+ /***** to these rules, and the function moderately check the *****/
+ /***** arguments. *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
- /*************************************************************************
- *
- * TABLE OVERVIEW:
- * ---------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 2
- * length 2 USHORT table length in bytes
- * language 4 USHORT Mac language code
- * keys 6 USHORT[256] sub-header keys
- * subs 518 SUBHEAD[NSUBS] sub-headers array
- * glyph_ids 518+NSUB*8 USHORT[] glyph id array
- *
- * the 'keys' table is used to map charcode high-bytes to sub-headers.
- * the value of 'NSUBS' is the number of sub-headers defined in the
- * table and is computed by finding the maximum of the 'keys' table.
- *
- * note that for any N, keys[n] is a byte offset within the subs table,
- * i.e. it is the corresponding sub-header index multiplied by 8.
- *
- * each sub-header has the following format:
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * first 0 USHORT first valid low-byte
- * count 2 USHORT number of valid low-bytes
- * delta 4 SHORT see below
- * offset 6 USHORT see below
- *
- * a sub-header defines, for each high-byte, the range of valid low-bytes
- * within the charmap. note that the range defined by 'first' and 'count'
- * must be completely included in the interval [0..255] according to the
- * specification
- *
- * if a character code is contained within a given sub-header, then mapping
- * it to a glyph index is done as follows:
- *
- * * the value of 'offset' is read. this is a _byte_ distance from the
- * location of the 'offset' field itself into a slice of the 'glyph_ids'
- * table. Let's call it 'slice' (it's a USHORT[] too)
- *
- * * the value 'slice[ char.lo - first ]' is read. If it is 0, there is
- * no glyph for the charcode. Otherwise, the value of 'delta' is added
- * to it (modulo 65536) to form a new glyph index
- *
- * it is up to the validation routine to check that all offsets fall within
- * the glyph ids table (and not within the 'subs' table itself or outside
- * of the CMap).
- */
+ /*************************************************************************/
+ /* */
+ /* TABLE OVERVIEW */
+ /* -------------- */
+ /* */
+ /* NAME OFFSET TYPE DESCRIPTION */
+ /* */
+ /* format 0 USHORT must be 2 */
+ /* length 2 USHORT table length in bytes */
+ /* language 4 USHORT Mac language code */
+ /* keys 6 USHORT[256] sub-header keys */
+ /* subs 518 SUBHEAD[NSUBS] sub-headers array */
+ /* glyph_ids 518+NSUB*8 USHORT[] glyph id array */
+ /* */
+ /* The `keys' table is used to map charcode high-bytes to sub-headers. */
+ /* The value of `NSUBS' is the number of sub-headers defined in the */
+ /* table and is computed by finding the maximum of the `keys' table. */
+ /* */
+ /* Note that for any n, `keys[n]' is a byte offset within the `subs' */
+ /* table, i.e., it is the corresponding sub-header index multiplied */
+ /* by 8. */
+ /* */
+ /* Each sub-header has the following format: */
+ /* */
+ /* NAME OFFSET TYPE DESCRIPTION */
+ /* */
+ /* first 0 USHORT first valid low-byte */
+ /* count 2 USHORT number of valid low-bytes */
+ /* delta 4 SHORT see below */
+ /* offset 6 USHORT see below */
+ /* */
+ /* A sub-header defines, for each high-byte, the range of valid */
+ /* low-bytes within the charmap. Note that the range defined by `first' */
+ /* and `count' must be completely included in the interval [0..255] */
+ /* according to the specification. */
+ /* */
+ /* If a character code is contained within a given sub-header, then */
+ /* mapping it to a glyph index is done as follows: */
+ /* */
+ /* * The value of `offset' is read. This is a _byte_ distance from the */
+ /* location of the `offset' field itself into a slice of the */
+ /* `glyph_ids' table. Let's call it `slice' (it's a USHORT[] too). */
+ /* */
+ /* * The value `slice[char.lo - first]' is read. If it is 0, there is */
+ /* no glyph for the charcode. Otherwise, the value of `delta' is */
+ /* added to it (modulo 65536) to form a new glyph index. */
+ /* */
+ /* It is up to the validation routine to check that all offsets fall */
+ /* within the glyph ids table (and not within the `subs' table itself or */
+ /* outside of the CMap). */
+ /* */
#ifdef TT_CONFIG_CMAP_FORMAT_2
@@ -249,15 +254,15 @@
tt_cmap2_validate( FT_Byte* table,
FT_Validator valid )
{
- FT_Byte* p = table + 2; /* skip format */
- FT_UInt length = TT_PEEK_USHORT(p);
+ FT_Byte* p = table + 2; /* skip format */
+ FT_UInt length = TT_PEEK_USHORT( p );
FT_UInt n, max_subs;
- FT_Byte* keys; /* keys table */
- FT_Byte* subs; /* sub-headers */
- FT_Byte* glyph_ids; /* glyph id array */
+ FT_Byte* keys; /* keys table */
+ FT_Byte* subs; /* sub-headers */
+ FT_Byte* glyph_ids; /* glyph id array */
- if ( table + length > valid->limit || length < 6+512 )
+ if ( table + length > valid->limit || length < 6 + 512 )
FT_INVALID_TOO_SHORT;
keys = table + 6;
@@ -267,22 +272,23 @@
max_subs = 0;
for ( n = 0; n < 256; n++ )
{
- FT_UInt index = TT_NEXT_USHORT(p);
+ FT_UInt idx = TT_NEXT_USHORT( p );
+
/* value must be multiple of 8 */
- if ( valid->level >= FT_VALIDATE_PARANOID && ( index & 7 ) != 0 )
+ if ( valid->level >= FT_VALIDATE_PARANOID && ( idx & 7 ) != 0 )
FT_INVALID_DATA;
- index >>= 3;
+ idx >>= 3;
- if ( index > max_subs )
- max_subs = index;
+ if ( idx > max_subs )
+ max_subs = idx;
}
FT_ASSERT( p == table + 518 );
subs = p;
- glyph_ids = subs + (max_subs + 1)*8;
+ glyph_ids = subs + (max_subs + 1) * 8;
if ( glyph_ids > valid->limit )
FT_INVALID_TOO_SHORT;
@@ -294,10 +300,10 @@
FT_Byte* ids;
- first_code = TT_NEXT_USHORT(p);
- code_count = TT_NEXT_USHORT(p);
- delta = TT_NEXT_SHORT(p);
- offset = TT_NEXT_USHORT(p);
+ first_code = TT_NEXT_USHORT( p );
+ code_count = TT_NEXT_USHORT( p );
+ delta = TT_NEXT_SHORT( p );
+ offset = TT_NEXT_USHORT( p );
/* check range within 0..255 */
if ( valid->level >= FT_VALIDATE_PARANOID )
@@ -316,16 +322,17 @@
/* check glyph ids */
if ( valid->level >= FT_VALIDATE_TIGHT )
{
- FT_Byte* limit = p + code_count*2;
- FT_UInt index;
+ FT_Byte* limit = p + code_count * 2;
+ FT_UInt idx;
+
for ( ; p < limit; )
{
- index = TT_NEXT_USHORT(p);
- if ( index != 0 )
+ idx = TT_NEXT_USHORT( p );
+ if ( idx != 0 )
{
- index = (index + delta) & 0xFFFFU;
- if ( index >= TT_VALID_GLYPH_COUNT(valid) )
+ idx = ( idx + delta ) & 0xFFFFU;
+ if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
@@ -336,7 +343,7 @@
/* return sub header corresponding to a given character code */
- /* NULL on invalid charcode.. */
+ /* NULL on invalid charcode */
static FT_Byte*
tt_cmap2_get_subheader( FT_Byte* table,
FT_UInt32 char_code )
@@ -343,19 +350,20 @@
{
FT_Byte* result = NULL;
- if ( char_code < 0x10000 )
+
+ if ( char_code < 0x10000UL )
{
- FT_UInt char_lo = (FT_UInt)( char_code & 0xFF );
- FT_UInt char_hi = (FT_UInt)( char_code >> 8 );
- FT_Byte* p = table + 6; /* keys table */
- FT_Byte* subs = table + 518; /* subheaders table */
- FT_Byte* sub;
+ FT_UInt char_lo = (FT_UInt)( char_code & 0xFF );
+ FT_UInt char_hi = (FT_UInt)( char_code >> 8 );
+ FT_Byte* p = table + 6; /* keys table */
+ FT_Byte* subs = table + 518; /* subheaders table */
+ FT_Byte* sub;
if ( char_hi == 0 )
{
/* an 8-bit character code -- we use subHeader 0 in this case */
- /* to test wheteher the character code is in the charmap */
+ /* to test whether the character code is in the charmap */
/* */
sub = subs; /* jump to first sub-header */
@@ -363,15 +371,15 @@
/* indicates that it's really a valid one-byte value */
/* Otherwise, return 0 */
/* */
- p += char_lo*2;
- if ( TT_PEEK_USHORT(p) != 0 )
+ p += char_lo * 2;
+ if ( TT_PEEK_USHORT( p ) != 0 )
goto Exit;
}
else
{
/* a 16-bit character code */
- p += char_hi*2; /* jump to key entry */
- sub = subs + ( TT_PEEK_USHORT(p) & -8 ); /* jump to sub-header */
+ p += char_hi * 2; /* jump to key entry */
+ sub = subs + ( TT_PEEK_USHORT( p ) & -8 ); /* jump to sub-header */
/* check that the hi byte isn't a valid one-byte value */
if ( sub == subs )
@@ -392,28 +400,30 @@
FT_UInt result = 0;
FT_Byte* subheader;
+
subheader = tt_cmap2_get_subheader( table, char_code );
if ( subheader )
{
- FT_Byte* p = subheader;
- FT_UInt index = (FT_UInt)(char_code & 0xFF);
+ FT_Byte* p = subheader;
+ FT_UInt idx = (FT_UInt)(char_code & 0xFF);
FT_UInt start, count;
FT_Int delta;
FT_UInt offset;
- start = TT_NEXT_USHORT(p);
- count = TT_NEXT_USHORT(p);
- delta = TT_NEXT_SHORT(p);
- offset = TT_PEEK_USHORT(p);
- index -= start;
- if ( index < count && offset != 0 )
+ start = TT_NEXT_USHORT( p );
+ count = TT_NEXT_USHORT( p );
+ delta = TT_NEXT_SHORT ( p );
+ offset = TT_PEEK_USHORT( p );
+
+ idx -= start;
+ if ( idx < count && offset != 0 )
{
- p += offset + 2*index;
- index = TT_PEEK_USHORT(p);
+ p += offset + 2 * idx;
+ idx = TT_PEEK_USHORT( p );
- if ( index != 0 )
- result = (FT_UInt)( index + delta ) & 0xFFFFU;
+ if ( idx != 0 )
+ result = (FT_UInt)( idx + delta ) & 0xFFFFU;
}
}
return result;
@@ -420,30 +430,31 @@
}
-
FT_CALLBACK_DEF( FT_UInt )
tt_cmap2_char_next( TT_CMap cmap,
FT_UInt32 *pcharcode )
{
- FT_Byte* table = cmap->data;
- FT_UInt gindex = 0;
- FT_UInt32 result = 0;
- FT_UInt32 charcode = *pcharcode + 1;
- FT_Byte* subheader;
+ FT_Byte* table = cmap->data;
+ FT_UInt gindex = 0;
+ FT_UInt32 result = 0;
+ FT_UInt32 charcode = *pcharcode + 1;
+ FT_Byte* subheader;
- while ( charcode < 0x10000U )
+
+ while ( charcode < 0x10000UL )
{
subheader = tt_cmap2_get_subheader( table, charcode );
if ( subheader )
{
FT_Byte* p = subheader;
- FT_UInt start = TT_NEXT_USHORT(p);
- FT_UInt count = TT_NEXT_USHORT(p);
- FT_Int delta = TT_NEXT_SHORT(p);
- FT_UInt offset = TT_PEEK_USHORT(p);
+ FT_UInt start = TT_NEXT_USHORT( p );
+ FT_UInt count = TT_NEXT_USHORT( p );
+ FT_Int delta = TT_NEXT_SHORT ( p );
+ FT_UInt offset = TT_PEEK_USHORT( p );
FT_UInt char_lo = (FT_UInt)( charcode & 0xFF );
- FT_UInt pos, index;
+ FT_UInt pos, idx;
+
if ( offset == 0 )
goto Next_SubHeader;
@@ -455,16 +466,16 @@
else
pos = (FT_UInt)( char_lo - start );
- p += offset + pos*2;
- charcode = (charcode & -256) + char_lo;
+ p += offset + pos * 2;
+ charcode = ( charcode & -256 ) + char_lo;
for ( ; pos < count; pos++, charcode++ )
{
- index = TT_NEXT_USHORT(p);
+ idx = TT_NEXT_USHORT( p );
- if ( index != 0 )
+ if ( idx != 0 )
{
- gindex = ( index + delta ) & 0xFFFFU;
+ gindex = ( idx + delta ) & 0xFFFFU;
if ( gindex != 0 )
{
result = charcode;
@@ -476,7 +487,7 @@
/* jump to next sub-header, i.e. higher byte value */
Next_SubHeader:
- charcode = (charcode & -256) + 256;
+ charcode = ( charcode & -256 ) + 256;
}
Exit:
@@ -485,83 +496,90 @@
return gindex;
}
- FT_CALLBACK_TABLE_DEF const TT_CMap_ClassRec tt_cmap2_class_rec =
+
+ FT_CALLBACK_TABLE_DEF
+ const TT_CMap_ClassRec tt_cmap2_class_rec =
{
{
sizeof( TT_CMapRec ),
- (FT_CMap_InitFunc) tt_cmap_init,
- (FT_CMap_DoneFunc) NULL,
- (FT_CMap_CharIndexFunc) tt_cmap2_char_index,
- (FT_CMap_CharNextFunc) tt_cmap2_char_next
+ (FT_CMap_InitFunc) tt_cmap_init,
+ (FT_CMap_DoneFunc) NULL,
+ (FT_CMap_CharIndexFunc)tt_cmap2_char_index,
+ (FT_CMap_CharNextFunc) tt_cmap2_char_next
},
2,
- (TT_CMap_ValidateFunc) tt_cmap2_validate
+ (TT_CMap_ValidateFunc) tt_cmap2_validate
};
#endif /* TT_CONFIG_CMAP_FORMAT_2 */
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** FORMAT 4 *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** FORMAT 4 *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
- /*************************************************************************
- *
- * TABLE OVERVIEW:
- * ---------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 4
- * length 2 USHORT table length in bytes
- * language 4 USHORT Mac language code
- *
- * segCountX2 6 USHORT 2*NUM_SEGS
- * searchRange 8 USHORT 2*(1 << LOG_SEGS)
- * entrySelector 10 USHORT LOG_SEGS
- * rangeShift 12 USHORT segCountX2 - searchRange
- *
- * endCount 14 USHORT[NUM_SEGS] end charcode for each
- * segment. last is 0xFFFF
- *
- * pad 14+NUM_SEGS*2 USHORT padding
- *
- * startCount 16+NUM_SEGS*2 USHORT[NUM_SEGS] first charcode for each
- * segment
- *
- * idDelta 16+NUM_SEGS*4 SHORT[NUM_SEGS] delta for each segment
- *
- * idOffset 16+NUM_SEGS*6 SHORT[NUM_SEGS] range offset for each
- * segment. can be 0
- *
- * glyphIds 16+NUM_SEGS*8 USHORT[] array og glyph id ranges
- *
- *
- * Charcodes are modelled by a series of ordered (increasing) intervals
- * called segments. Each segment has start and end codes, provided by
- * the 'startCount' and 'endCount' arrays. Segments must not be over-lapping
- * and the last segment should always contain the '0xFFFF' endCount.
- *
- * The fields 'searchRange', 'entrySelector' and 'rangeShift' are better
- * ignored (they're traces of over-engineering in the TT specification)
- *
- * Each segment also has a signed 'delta', as well as an optional offset
- * within the 'glyphIds' table.
- *
- * if a segment's idOffset is 0, then the glyph index corresponding to
- * any charcode within the segment is obtained by adding the value of
- * 'idDelta' directly to the charcode, modulo 65536
- *
- * otherwise, a glyph index is taken from the glyph ids sub-array for the
- * segment, and the value of 'idDelta' is added to it..
- */
+ /*************************************************************************/
+ /* */
+ /* TABLE OVERVIEW */
+ /* -------------- */
+ /* */
+ /* NAME OFFSET TYPE DESCRIPTION */
+ /* */
+ /* format 0 USHORT must be 4 */
+ /* length 2 USHORT table length */
+ /* in bytes */
+ /* language 4 USHORT Mac language code */
+ /* */
+ /* segCountX2 6 USHORT 2*NUM_SEGS */
+ /* searchRange 8 USHORT 2*(1 << LOG_SEGS) */
+ /* entrySelector 10 USHORT LOG_SEGS */
+ /* rangeShift 12 USHORT segCountX2 - */
+ /* searchRange */
+ /* */
+ /* endCount 14 USHORT[NUM_SEGS] end charcode for */
+ /* each segment; last */
+ /* is 0xFFFF */
+ /* */
+ /* pad 14+NUM_SEGS*2 USHORT padding */
+ /* */
+ /* startCount 16+NUM_SEGS*2 USHORT[NUM_SEGS] first charcode for */
+ /* each segment */
+ /* */
+ /* idDelta 16+NUM_SEGS*4 SHORT[NUM_SEGS] delta for each */
+ /* segment */
+ /* idOffset 16+NUM_SEGS*6 SHORT[NUM_SEGS] range offset for */
+ /* each segment; can be */
+ /* zero */
+ /* */
+ /* glyphIds 16+NUM_SEGS*8 USHORT[] array of glyph id */
+ /* ranges */
+ /* */
+ /* Character codes are modelled by a series of ordered (increasing) */
+ /* intervals called segments. Each segment has start and end codes, */
+ /* provided by the `startCount' and `endCount' arrays. Segments must */
+ /* not be overlapping and the last segment should always contain the */
+ /* `0xFFFF' endCount. */
+ /* */
+ /* The fields `searchRange', `entrySelector' and `rangeShift' are better */
+ /* ignored (they are traces of over-engineering in the TrueType */
+ /* specification). */
+ /* */
+ /* Each segment also has a signed `delta', as well as an optional offset */
+ /* within the `glyphIds' table. */
+ /* */
+ /* If a segment's idOffset is 0, the glyph index corresponding to any */
+ /* charcode within the segment is obtained by adding the value of */
+ /* `idDelta' directly to the charcode, modulo 65536. */
+ /* */
+ /* Otherwise, a glyph index is taken from the glyph ids sub-array for */
+ /* the segment, and the value of `idDelta' is added to it. */
+ /* */
-
#ifdef TT_CONFIG_CMAP_FORMAT_4
FT_CALLBACK_DEF( void )
@@ -568,16 +586,17 @@
tt_cmap4_validate( FT_Byte* table,
FT_Validator valid )
{
- FT_Byte* p = table + 2; /* skip format */
- FT_UInt length = TT_NEXT_USHORT(p);
+ FT_Byte* p = table + 2; /* skip format */
+ FT_UInt length = TT_NEXT_USHORT( p );
FT_Byte *ends, *starts, *offsets, *deltas, *glyph_ids;
FT_UInt num_segs;
+
if ( table + length > valid->limit || length < 16 )
FT_INVALID_TOO_SHORT;
p = table + 6;
- num_segs = TT_NEXT_USHORT(p); /* read segCountX2 */
+ num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
if ( valid->level >= FT_VALIDATE_PARANOID )
{
@@ -593,30 +612,31 @@
if ( valid->level >= FT_VALIDATE_PARANOID )
{
/* check the values of 'searchRange', 'entrySelector', 'rangeShift' */
- FT_UInt search_range = TT_NEXT_USHORT(p);
- FT_UInt entry_selector = TT_NEXT_USHORT(p);
- FT_UInt range_shift = TT_NEXT_USHORT(p);
+ FT_UInt search_range = TT_NEXT_USHORT( p );
+ FT_UInt entry_selector = TT_NEXT_USHORT( p );
+ FT_UInt range_shift = TT_NEXT_USHORT( p );
- if ( (search_range | range_shift) & 1 ) /* must be even values */
+
+ if ( ( search_range | range_shift ) & 1 ) /* must be even values */
FT_INVALID_DATA;
search_range /= 2;
range_shift /= 2;
- /* 'search range' is the greatest power of 2 that is <= num_segs */
+ /* `search range' is the greatest power of 2 that is <= num_segs */
- if ( search_range > num_segs ||
- search_range*2 < num_segs ||
- search_range + range_shift != num_segs ||
- search_range != (1U << entry_selector) )
+ if ( search_range > num_segs ||
+ search_range * 2 < num_segs ||
+ search_range + range_shift != num_segs ||
+ search_range != ( 1U << entry_selector ) )
FT_INVALID_DATA;
}
ends = table + 14;
- starts = table + 16 + num_segs*2;
- deltas = starts + num_segs*2;
- offsets = deltas + num_segs*2;
- glyph_ids = offsets + num_segs*2;
+ starts = table + 16 + num_segs * 2;
+ deltas = starts + num_segs * 2;
+ offsets = deltas + num_segs * 2;
+ glyph_ids = offsets + num_segs * 2;
if ( glyph_ids >= table + length )
FT_INVALID_TOO_SHORT;
@@ -624,23 +644,28 @@
/* check last segment, its end count must be FFFF */
if ( valid->level >= FT_VALIDATE_PARANOID )
{
- p = ends + (num_segs-1)*2;
- if ( TT_PEEK_USHORT(p) != 0xFFFFU )
+ p = ends + ( num_segs - 1 ) * 2;
+ if ( TT_PEEK_USHORT( p ) != 0xFFFFU )
FT_INVALID_DATA;
}
- /* check that segments are sorted in increasing order and do not overlap */
- /* check also the offsets.. */
+ /* check that segments are sorted in increasing order and do not */
+ /* overlap; check also the offsets */
{
FT_UInt start, end, last = 0,offset, n;
FT_Int delta;
+
for ( n = 0; n < num_segs; n++ )
{
- p = starts + n*2; start = TT_PEEK_USHORT(p);
- p = ends + n*2; end = TT_PEEK_USHORT(p);
- p = deltas + n*2; delta = TT_PEEK_SHORT(p);
- p = offsets + n*2; offset = TT_PEEK_USHORT(p);
+ p = starts + n * 2;
+ start = TT_PEEK_USHORT( p );
+ p = ends + n * 2;
+ end = TT_PEEK_USHORT( p );
+ p = deltas + n * 2;
+ delta = TT_PEEK_SHORT( p );
+ p = offsets + n * 2;
+ offset = TT_PEEK_USHORT( p );
if ( start > end )
FT_INVALID_DATA;
@@ -653,27 +678,30 @@
p += offset; /* start of glyph id array */
/* check that we point within the glyph ids table only */
- if ( p < glyph_ids || p + (end - start + 1)*2 > table + length )
+ if ( p < glyph_ids ||
+ p + ( end - start + 1 ) * 2 > table + length )
FT_INVALID_DATA;
/* check glyph indices within the segment range */
if ( valid->level >= FT_VALIDATE_TIGHT )
{
- FT_UInt index;
+ FT_UInt idx;
+
for ( ; start < end; )
{
- index = FT_NEXT_USHORT(p);
- if ( index != 0 )
+ idx = FT_NEXT_USHORT( p );
+ if ( idx != 0 )
{
- index = (FT_UInt)(index + delta) & 0xFFFFU;
+ idx = (FT_UInt)( idx + delta ) & 0xFFFFU;
- if ( index >= TT_VALID_GLYPH_COUNT(valid) )
+ if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
}
}
+
last = end;
}
}
@@ -680,7 +708,6 @@
}
-
FT_CALLBACK_DEF( FT_UInt )
tt_cmap4_char_index( TT_CMap cmap,
FT_UInt32 char_code )
@@ -688,16 +715,18 @@
FT_Byte* table = cmap->data;
FT_UInt result = 0;
- if ( char_code < 0x10000U )
+
+ if ( char_code < 0x10000UL )
{
FT_Byte* p;
FT_Byte* q;
- FT_UInt index, num_segs2;
+ FT_UInt idx, num_segs2;
FT_Int delta;
FT_UInt n, code = (FT_UInt)char_code;
+
p = table + 6;
- num_segs2 = TT_PEEK_USHORT(p) & -2; /* be paranoid !! */
+ num_segs2 = TT_PEEK_USHORT( p ) & -2; /* be paranoid! */
p = table + 14; /* ends table */
q = table + 16 + num_segs2; /* starts table */
@@ -704,28 +733,31 @@
for ( n = 0; n < num_segs2; n += 2 )
{
- FT_UInt end = TT_NEXT_USHORT(p);
- FT_UInt start = TT_NEXT_USHORT(q);
+ FT_UInt end = TT_NEXT_USHORT( p );
+ FT_UInt start = TT_NEXT_USHORT( q );
FT_UInt offset;
+
if ( code < start )
break;
if ( code <= end )
{
- index = code;
+ idx = code;
- p = q + num_segs2 - 2; delta = TT_PEEK_SHORT(p);
- p += num_segs2; offset = TT_PEEK_USHORT(p);
+ p = q + num_segs2 - 2;
+ delta = TT_PEEK_SHORT( p );
+ p += num_segs2;
+ offset = TT_PEEK_USHORT( p );
if ( offset != 0 )
{
- p += offset + 2*(index - start);
- index = TT_PEEK_USHORT(p);
+ p += offset + 2 * ( idx - start );
+ idx = TT_PEEK_USHORT( p );
}
- if ( index != 0 )
- result = (FT_UInt)( index + delta ) & 0xFFFFU;
+ if ( idx != 0 )
+ result = (FT_UInt)( idx + delta ) & 0xFFFFU;
}
}
}
@@ -733,20 +765,20 @@
}
-
FT_CALLBACK_DEF( FT_UInt )
tt_cmap4_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
- FT_Byte* table = cmap->data;
- FT_UInt32 result = 0;
- FT_UInt32 char_code = *pchar_code + 1;
- FT_UInt gindex = 0;
- FT_Byte* p;
- FT_Byte* q;
- FT_UInt code, num_segs2;
+ FT_Byte* table = cmap->data;
+ FT_UInt32 result = 0;
+ FT_UInt32 char_code = *pchar_code + 1;
+ FT_UInt gindex = 0;
+ FT_Byte* p;
+ FT_Byte* q;
+ FT_UInt code, num_segs2;
- if ( char_code >= 0x10000U )
+
+ if ( char_code >= 0x10000UL )
goto Exit;
code = (FT_UInt)char_code;
@@ -755,32 +787,36 @@
for (;;)
{
- FT_UInt offset, n;
- FT_Int delta;
+ FT_UInt offset, n;
+ FT_Int delta;
+
p = table + 14; /* ends table */
q = table + 16 + num_segs2; /* starts table */
for ( n = 0; n < num_segs2; n += 2 )
{
- FT_UInt end = TT_NEXT_USHORT(p);
- FT_UInt start = TT_NEXT_USHORT(q);
+ FT_UInt end = TT_NEXT_USHORT( p );
+ FT_UInt start = TT_NEXT_USHORT( q );
+
if ( code < start )
code = start;
if ( code <= end )
{
- p = q + num_segs2 - 2; delta = TT_PEEK_SHORT(p);
- p += num_segs2; offset = TT_PEEK_USHORT(p);
+ p = q + num_segs2 - 2;
+ delta = TT_PEEK_SHORT( p );
+ p += num_segs2;
+ offset = TT_PEEK_USHORT( p );
if ( offset != 0 )
{
/* parse the glyph ids array for non-0 index */
- p += offset + (code - start)*2;
+ p += offset + ( code - start ) * 2;
while ( code <= end )
{
- gindex = TT_NEXT_USHORT(p);
+ gindex = TT_NEXT_USHORT( p );
if ( gindex != 0 )
{
gindex = (FT_UInt)( gindex + delta ) & 0xFFFFU;
@@ -814,49 +850,51 @@
return gindex;
}
- FT_CALLBACK_TABLE_DEF const TT_CMap_ClassRec tt_cmap4_class_rec =
+
+ FT_CALLBACK_TABLE_DEF
+ const TT_CMap_ClassRec tt_cmap4_class_rec =
{
{
- sizeof( TT_CMapRec ),
+ sizeof ( TT_CMapRec ),
- (FT_CMap_InitFunc) tt_cmap_init,
- (FT_CMap_DoneFunc) NULL,
- (FT_CMap_CharIndexFunc) tt_cmap4_char_index,
- (FT_CMap_CharNextFunc) tt_cmap4_char_next
+ (FT_CMap_InitFunc) tt_cmap_init,
+ (FT_CMap_DoneFunc) NULL,
+ (FT_CMap_CharIndexFunc)tt_cmap4_char_index,
+ (FT_CMap_CharNextFunc) tt_cmap4_char_next
},
4,
- (TT_CMap_ValidateFunc) tt_cmap4_validate
+ (TT_CMap_ValidateFunc) tt_cmap4_validate
};
#endif /* TT_CONFIG_CMAP_FORMAT_4 */
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** FORMAT 6 *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
- /*************************************************************************
- *
- * TABLE OVERVIEW:
- * ---------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 4
- * length 2 USHORT table length in bytes
- * language 4 USHORT Mac language code
- *
- * first 6 USHORT first segment code
- * count 8 USHORT segment size in chars
- * glyphIds 10 USHORT[count] glyph ids
- *
- *
- * A very simplified segment mapping
- */
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** FORMAT 6 *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* TABLE OVERVIEW */
+ /* -------------- */
+ /* */
+ /* NAME OFFSET TYPE DESCRIPTION */
+ /* */
+ /* format 0 USHORT must be 4 */
+ /* length 2 USHORT table length in bytes */
+ /* language 4 USHORT Mac language code */
+ /* */
+ /* first 6 USHORT first segment code */
+ /* count 8 USHORT segment size in chars */
+ /* glyphIds 10 USHORT[count] glyph ids */
+ /* */
+ /* A very simplified segment mapping. */
+ /* */
+
#ifdef TT_CONFIG_CMAP_FORMAT_6
FT_CALLBACK_DEF( void )
@@ -866,17 +904,18 @@
FT_Byte* p;
FT_UInt length, start, count;
+
if ( table + 10 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 2;
- length = TT_NEXT_USHORT(p);
+ length = TT_NEXT_USHORT( p );
- p = table + 6; /* skip language */
- start = TT_NEXT_USHORT(p);
- count = TT_NEXT_USHORT(p);
+ p = table + 6; /* skip language */
+ start = TT_NEXT_USHORT( p );
+ count = TT_NEXT_USHORT( p );
- if ( table + length > valid->limit || length < 10 + count*2 )
+ if ( table + length > valid->limit || length < 10 + count * 2 )
FT_INVALID_TOO_SHORT;
/* check glyph indices */
@@ -884,10 +923,11 @@
{
FT_UInt gindex;
+
for ( ; count > 0; count-- )
{
- gindex = TT_NEXT_USHORT(p);
- if ( gindex >= TT_VALID_GLYPH_COUNT(valid) )
+ gindex = TT_NEXT_USHORT( p );
+ if ( gindex >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
@@ -901,14 +941,15 @@
FT_Byte* table = cmap->data;
FT_UInt result = 0;
FT_Byte* p = table + 6;
- FT_UInt start = TT_NEXT_USHORT(p);
- FT_UInt count = TT_NEXT_USHORT(p);
- FT_UInt index = (FT_UInt)( char_code - start );
+ FT_UInt start = TT_NEXT_USHORT( p );
+ FT_UInt count = TT_NEXT_USHORT( p );
+ FT_UInt idx = (FT_UInt)( char_code - start );
- if ( index < count )
+
+ if ( idx < count )
{
- p += 2*index;
- result = TT_PEEK_USHORT(p);
+ p += 2 * idx;
+ result = TT_PEEK_USHORT( p );
}
return result;
}
@@ -915,31 +956,32 @@
FT_CALLBACK_DEF( FT_UInt )
- tt_cmap6_char_next( TT_CMap cmap,
- FT_UInt32 *pchar_code )
+ tt_cmap6_char_next( TT_CMap cmap,
+ FT_UInt32 *pchar_code )
{
- FT_Byte* table = cmap->data;
- FT_UInt32 result = 0;
- FT_UInt32 char_code = *pchar_code + 1;
- FT_UInt gindex = 0;
+ FT_Byte* table = cmap->data;
+ FT_UInt32 result = 0;
+ FT_UInt32 char_code = *pchar_code + 1;
+ FT_UInt gindex = 0;
- FT_Byte* p = table + 6;
- FT_UInt start = TT_NEXT_USHORT(p);
- FT_UInt count = TT_NEXT_USHORT(p);
- FT_UInt index;
+ FT_Byte* p = table + 6;
+ FT_UInt start = TT_NEXT_USHORT( p );
+ FT_UInt count = TT_NEXT_USHORT( p );
+ FT_UInt idx;
- if ( char_code >= 0x10000U )
+
+ if ( char_code >= 0x10000UL )
goto Exit;
if ( char_code < start )
char_code = start;
- index = (FT_UInt)( char_code - start );
- p += 2*index;
+ idx = (FT_UInt)( char_code - start );
+ p += 2 * idx;
- for ( ; index < count; index++ )
+ for ( ; idx < count; idx++ )
{
- gindex = TT_NEXT_USHORT(p);
+ gindex = TT_NEXT_USHORT( p );
if ( gindex != 0 )
{
result = char_code;
@@ -954,80 +996,78 @@
}
- FT_CALLBACK_TABLE_DEF const TT_CMap_ClassRec tt_cmap6_class_rec =
+ FT_CALLBACK_TABLE_DEF
+ const TT_CMap_ClassRec tt_cmap6_class_rec =
{
{
- sizeof( TT_CMapRec ),
+ sizeof ( TT_CMapRec ),
- (FT_CMap_InitFunc) tt_cmap_init,
- (FT_CMap_DoneFunc) NULL,
- (FT_CMap_CharIndexFunc) tt_cmap6_char_index,
- (FT_CMap_CharNextFunc) tt_cmap6_char_next
+ (FT_CMap_InitFunc) tt_cmap_init,
+ (FT_CMap_DoneFunc) NULL,
+ (FT_CMap_CharIndexFunc)tt_cmap6_char_index,
+ (FT_CMap_CharNextFunc) tt_cmap6_char_next
},
6,
- (TT_CMap_ValidateFunc) tt_cmap6_validate
+ (TT_CMap_ValidateFunc) tt_cmap6_validate
};
#endif /* TT_CONFIG_CMAP_FORMAT_6 */
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** FORMAT 8 *****/
- /***** *****/
- /***** It's hard to completely understand what the OpenType *****/
- /***** spec says about this format, but here are my conclusion *****/
- /***** *****/
- /***** the purpose of this format is to easily map UTF-16 text *****/
- /***** to glyph indices. Basically, the 'char_code' must be in *****/
- /***** one of the following formats: *****/
- /***** *****/
- /***** - a 16-bit value that isn't part of the Unicode *****/
- /***** Surrogates Area (i.e. U+D800-U+DFFF) *****/
- /***** *****/
- /***** - a 32-bit value, made of two surrogate values, i.e. *****/
- /***** if "char_code = (char_hi << 16) | char_lo", then *****/
- /***** both 'char_hi' and 'char_lo' must be in the Surrogates *****/
- /***** Area. *****/
- /***** *****/
- /***** The 'is32' table embedded in the charmap indicates *****/
- /***** wether a given 16-bit value is in the surrogates area *****/
- /***** or not.. *****/
- /***** *****/
- /***** so, for any given "char_code", we can assert the following *****/
- /***** *****/
- /***** if 'char_hi == 0' then we must have 'is32[char_lo] == 0' *****/
- /***** *****/
- /***** if 'char_hi != 0' then we must have both *****/
- /***** 'is32[char_hi] != 0' and 'is32[char_lo] != 0' *****/
- /***** *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** FORMAT 8 *****/
+ /***** *****/
+ /***** It's hard to completely understand what the OpenType spec *****/
+ /***** says about this format, but here is my conclusion. *****/
+ /***** *****/
+ /***** The purpose of this format is to easily map UTF-16 text to *****/
+ /***** glyph indices. Basically, the `char_code' must be in one of *****/
+ /***** the following formats: *****/
+ /***** *****/
+ /***** - A 16-bit value that isn't part of the Unicode Surrogates *****/
+ /***** Area (i.e. U+D800-U+DFFF). *****/
+ /***** *****/
+ /***** - A 32-bit value, made of two surrogate values, i.e.. if *****/
+ /***** `char_code = (char_hi << 16) | char_lo', then both *****/
+ /***** `char_hi' and `char_lo' must be in the Surrogates Area. *****/
+ /***** Area. *****/
+ /***** *****/
+ /***** The 'is32' table embedded in the charmap indicates whether a *****/
+ /***** given 16-bit value is in the surrogates area or not. *****/
+ /***** *****/
+ /***** So, for any given `char_code', we can assert the following: *****/
+ /***** *****/
+ /***** If `char_hi == 0' then we must have `is32[char_lo] == 0'. *****/
+ /***** *****/
+ /***** If `char_hi != 0' then we must have both *****/
+ /***** `is32[char_hi] != 0' and `is32[char_lo] != 0'. *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* TABLE OVERVIEW */
+ /* -------------- */
+ /* */
+ /* NAME OFFSET TYPE DESCRIPTION */
+ /* */
+ /* format 0 USHORT must be 8 */
+ /* reseved 2 USHORT reserved */
+ /* length 4 ULONG length in bytes */
+ /* language 8 ULONG Mac language code */
+ /* is32 12 BYTE[8192] 32-bitness bitmap */
+ /* count 8204 ULONG number of groups */
+ /* */
+ /* This header is followed by 'count' groups of the following format: */
+ /* */
+ /* start 0 ULONG first charcode */
+ /* end 4 ULONG last charcode */
+ /* startId 8 ULONG start glyph id for the group */
+ /* */
- /*************************************************************************
- *
- * TABLE OVERVIEW:
- * ---------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 8
- * reseved 2 USHORT reserved
- * length 4 ULONG length in bytes
- * language 8 ULONG Mac language code
- * is32 12 BYTE[8192] 32-bitness bitmap
- * count 8204 ULONG number of groups
- *
- * this header is followed by 'count' groups of the following format:
- *
- * start 0 ULONG first charcode
- * end 4 ULONG last charcode
- * startId 8 ULONG start glyph id for
- * the group
- */
-
#ifdef TT_CONFIG_CMAP_FORMAT_8
FT_CALLBACK_DEF( void )
@@ -1039,18 +1079,19 @@
FT_UInt32 length;
FT_UInt32 num_groups;
+
if ( table + 16 + 8192 > valid->limit )
FT_INVALID_TOO_SHORT;
- length = TT_NEXT_ULONG(p);
+ length = TT_NEXT_ULONG( p );
if ( table + length > valid->limit || length < 8208 )
FT_INVALID_TOO_SHORT;
is32 = table + 12;
- p = is32 + 8192; /* skip 'is32' array */
- num_groups = TT_NEXT_ULONG(p);
+ p = is32 + 8192; /* skip `is32' array */
+ num_groups = TT_NEXT_ULONG( p );
- if ( p + num_groups*12 > valid->limit )
+ if ( p + num_groups * 12 > valid->limit )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
@@ -1057,14 +1098,16 @@
{
FT_UInt32 n, start, end, start_id, count, last = 0;
+
for ( n = 0; n < num_groups; n++ )
{
FT_UInt hi, lo;
- start = TT_NEXT_ULONG(p);
- end = TT_NEXT_ULONG(p);
- start_id = TT_NEXT_ULONG(p);
+ start = TT_NEXT_ULONG( p );
+ end = TT_NEXT_ULONG( p );
+ start_id = TT_NEXT_ULONG( p );
+
if ( start > end )
FT_INVALID_DATA;
@@ -1073,41 +1116,41 @@
if ( valid->level >= FT_VALIDATE_TIGHT )
{
- if ( start_id + end - start >= TT_VALID_GLYPH_COUNT(valid) )
+ if ( start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
- count = (FT_UInt32)(end - start + 1);
+ count = (FT_UInt32)( end - start + 1 );
if ( start & ~0xFFFFU )
{
- /* start_hi != 0, check that is32[i] is 1 for each i in */
- /* the 'hi' and 'lo' of the range [start..end] */
+ /* start_hi != 0; check that is32[i] is 1 for each i in */
+ /* the `hi' and `lo' of the range [start..end] */
for ( ; count > 0; count--, start++ )
{
- hi = (FT_UInt)(start >> 16);
- lo = (FT_UInt)(start & 0xFFFFU);
+ hi = (FT_UInt)( start >> 16 );
+ lo = (FT_UInt)( start & 0xFFFFU );
- if ( (is32[ hi >> 3 ] & (0x80 >> (hi & 7))) == 0 )
+ if ( (is32[hi >> 3] & ( 0x80 >> ( hi & 7 ) ) ) == 0 )
FT_INVALID_DATA;
- if ( (is32[ lo >> 3 ] & (0x80 >> (lo & 7))) == 0 )
+ if ( (is32[lo >> 3] & ( 0x80 >> ( lo & 7 ) ) ) == 0 )
FT_INVALID_DATA;
}
}
else
{
- /* start_hi == 0, check that is32[i] is 0 for each i in */
+ /* start_hi == 0; check that is32[i] is 0 for each i in */
/* the range [start..end] */
- /* end_hi cannot be != 0 !! */
+ /* end_hi cannot be != 0! */
if ( end & ~0xFFFFU )
FT_INVALID_DATA;
for ( ; count > 0; count--, start++ )
{
- lo = (FT_UInt)(start & 0xFFFFU);
+ lo = (FT_UInt)( start & 0xFFFFU );
- if ( (is32[ lo >> 3 ] & (0x80 >> (lo & 7))) != 0 )
+ if ( (is32[lo >> 3] & ( 0x80 >> ( lo & 7 ) ) ) != 0 )
FT_INVALID_DATA;
}
}
@@ -1120,20 +1163,21 @@
FT_CALLBACK_DEF( FT_UInt )
- tt_cmap8_char_index( TT_CMap cmap,
- FT_UInt32 char_code )
+ tt_cmap8_char_index( TT_CMap cmap,
+ FT_UInt32 char_code )
{
FT_Byte* table = cmap->data;
FT_UInt result = 0;
FT_Byte* p = table + 8204;
- FT_UInt32 num_groups = TT_NEXT_ULONG(p);
+ FT_UInt32 num_groups = TT_NEXT_ULONG( p );
FT_UInt32 start, end, start_id;
+
for ( ; num_groups > 0; num_groups-- )
{
- start = TT_NEXT_ULONG(p);
- end = TT_NEXT_ULONG(p);
- start_id = TT_NEXT_ULONG(p);
+ start = TT_NEXT_ULONG( p );
+ end = TT_NEXT_ULONG( p );
+ start_id = TT_NEXT_ULONG( p );
if ( char_code < start )
break;
@@ -1149,8 +1193,8 @@
FT_CALLBACK_DEF( FT_UInt )
- tt_cmap8_char_next( TT_CMap cmap,
- FT_UInt32 *pchar_code )
+ tt_cmap8_char_next( TT_CMap cmap,
+ FT_UInt32 *pchar_code )
{
FT_UInt32 result = 0;
FT_UInt32 char_code = *pchar_code + 1;
@@ -1157,16 +1201,17 @@
FT_UInt gindex = 0;
FT_Byte* table = cmap->data;
FT_Byte* p = table + 8204;
- FT_UInt32 num_groups = TT_NEXT_ULONG(p);
+ FT_UInt32 num_groups = TT_NEXT_ULONG( p );
FT_UInt32 n, start, end, start_id;
+
p = table + 8208;
for ( n = 0; n < num_groups++; n++ )
{
- start = TT_NEXT_ULONG(p);
- end = TT_NEXT_ULONG(p);
- start_id = TT_NEXT_ULONG(p);
+ start = TT_NEXT_ULONG( p );
+ end = TT_NEXT_ULONG( p );
+ start_id = TT_NEXT_ULONG( p );
if ( char_code < start )
char_code = start;
@@ -1173,7 +1218,7 @@
if ( char_code <= end )
{
- gindex = (FT_UInt)(char_code - start + start_id);
+ gindex = (FT_UInt)( char_code - start + start_id );
if ( gindex != 0 )
{
result = char_code;
@@ -1188,47 +1233,49 @@
}
- FT_CALLBACK_TABLE_DEF const TT_CMap_ClassRec tt_cmap8_class_rec =
+ FT_CALLBACK_TABLE_DEF
+ const TT_CMap_ClassRec tt_cmap8_class_rec =
{
{
- sizeof( TT_CMapRec ),
+ sizeof ( TT_CMapRec ),
- (FT_CMap_InitFunc) tt_cmap_init,
- (FT_CMap_DoneFunc) NULL,
- (FT_CMap_CharIndexFunc) tt_cmap8_char_index,
- (FT_CMap_CharNextFunc) tt_cmap8_char_next
+ (FT_CMap_InitFunc) tt_cmap_init,
+ (FT_CMap_DoneFunc) NULL,
+ (FT_CMap_CharIndexFunc)tt_cmap8_char_index,
+ (FT_CMap_CharNextFunc) tt_cmap8_char_next
},
8,
- (TT_CMap_ValidateFunc) tt_cmap8_validate
+ (TT_CMap_ValidateFunc) tt_cmap8_validate
};
#endif /* TT_CONFIG_CMAP_FORMAT_8 */
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** FORMAT 10 *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
- /*************************************************************************
- *
- * TABLE OVERVIEW:
- * ---------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 10
- * reseved 2 USHORT reserved
- * length 4 ULONG length in bytes
- * language 8 ULONG Mac language code
- *
- * start 12 ULONG first char in range
- * count 16 ULONG number of chars in range
- * glyphIds 20 USHORT[count] glyph indices covered
- */
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** FORMAT 10 *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* TABLE OVERVIEW */
+ /* -------------- */
+ /* */
+ /* NAME OFFSET TYPE DESCRIPTION */
+ /* */
+ /* format 0 USHORT must be 10 */
+ /* reserved 2 USHORT reserved */
+ /* length 4 ULONG length in bytes */
+ /* language 8 ULONG Mac language code */
+ /* */
+ /* start 12 ULONG first char in range */
+ /* count 16 ULONG number of chars in range */
+ /* glyphIds 20 USHORT[count] glyph indices covered */
+ /* */
+
#ifdef TT_CONFIG_CMAP_FORMAT_10
FT_CALLBACK_DEF( void )
@@ -1238,15 +1285,16 @@
FT_Byte* p = table + 4;
FT_ULong length, start, count;
+
if ( table + 20 > valid->limit )
FT_INVALID_TOO_SHORT;
- length = TT_NEXT_ULONG(p);
+ length = TT_NEXT_ULONG( p );
p = table + 12;
- start = TT_NEXT_ULONG(p);
- count = TT_NEXT_ULONG(p);
+ start = TT_NEXT_ULONG( p );
+ count = TT_NEXT_ULONG( p );
- if ( table + length > valid->limit || length < 20 + count*2 )
+ if ( table + length > valid->limit || length < 20 + count * 2 )
FT_INVALID_TOO_SHORT;
/* check glyph indices */
@@ -1254,10 +1302,11 @@
{
FT_UInt gindex;
+
for ( ; count > 0; count-- )
{
- gindex = TT_NEXT_USHORT(p);
- if ( gindex >= TT_VALID_GLYPH_COUNT(valid) )
+ gindex = TT_NEXT_USHORT( p );
+ if ( gindex >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
@@ -1271,14 +1320,15 @@
FT_Byte* table = cmap->data;
FT_UInt result = 0;
FT_Byte* p = table + 12;
- FT_UInt32 start = TT_NEXT_ULONG(p);
- FT_UInt32 count = TT_NEXT_ULONG(p);
- FT_UInt32 index = (FT_ULong)( char_code - start );
+ FT_UInt32 start = TT_NEXT_ULONG( p );
+ FT_UInt32 count = TT_NEXT_ULONG( p );
+ FT_UInt32 idx = (FT_ULong)( char_code - start );
- if ( index < count )
+
+ if ( idx < count )
{
- p += 2*index;
- result = TT_PEEK_USHORT(p);
+ p += 2 * idx;
+ result = TT_PEEK_USHORT( p );
}
return result;
}
@@ -1293,19 +1343,20 @@
FT_UInt32 char_code = *pchar_code + 1;
FT_UInt gindex = 0;
FT_Byte* p = table + 12;
- FT_UInt32 start = TT_NEXT_ULONG(p);
- FT_UInt32 count = TT_NEXT_ULONG(p);
- FT_UInt32 index;
+ FT_UInt32 start = TT_NEXT_ULONG( p );
+ FT_UInt32 count = TT_NEXT_ULONG( p );
+ FT_UInt32 idx;
+
if ( char_code < start )
char_code = start;
- index = (FT_UInt32)( char_code - start );
- p += 2*index;
+ idx = (FT_UInt32)( char_code - start );
+ p += 2 * idx;
- for ( ; index < count; index++ )
+ for ( ; idx < count; idx++ )
{
- gindex = TT_NEXT_USHORT(p);
+ gindex = TT_NEXT_USHORT( p );
if ( gindex != 0 )
{
result = char_code;
@@ -1319,52 +1370,52 @@
}
- FT_CALLBACK_TABLE_DEF const TT_CMap_ClassRec tt_cmap10_class_rec =
+ FT_CALLBACK_TABLE_DEF
+ const TT_CMap_ClassRec tt_cmap10_class_rec =
{
{
- sizeof( TT_CMapRec ),
+ sizeof ( TT_CMapRec ),
- (FT_CMap_InitFunc) tt_cmap_init,
- (FT_CMap_DoneFunc) NULL,
- (FT_CMap_CharIndexFunc) tt_cmap10_char_index,
- (FT_CMap_CharNextFunc) tt_cmap10_char_next
+ (FT_CMap_InitFunc) tt_cmap_init,
+ (FT_CMap_DoneFunc) NULL,
+ (FT_CMap_CharIndexFunc)tt_cmap10_char_index,
+ (FT_CMap_CharNextFunc) tt_cmap10_char_next
},
10,
- (TT_CMap_ValidateFunc) tt_cmap10_validate
+ (TT_CMap_ValidateFunc) tt_cmap10_validate
};
#endif /* TT_CONFIG_CMAP_FORMAT_10 */
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** FORMAT 12 *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** FORMAT 12 *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
- /*************************************************************************
- *
- * TABLE OVERVIEW:
- * ---------------
- *
- * NAME OFFSET TYPE DESCRIPTION
- *
- * format 0 USHORT must be 12
- * reseved 2 USHORT reserved
- * length 4 ULONG length in bytes
- * language 8 ULONG Mac language code
- * count 12 ULONG number of groups
- * 16
- *
- * this header is followed by 'count' groups of the following format:
- *
- * start 0 ULONG first charcode
- * end 4 ULONG last charcode
- * startId 8 ULONG start glyph id for
- * the group
- */
+ /*************************************************************************/
+ /* */
+ /* TABLE OVERVIEW */
+ /* -------------- */
+ /* */
+ /* NAME OFFSET TYPE DESCRIPTION */
+ /* */
+ /* format 0 USHORT must be 12 */
+ /* reserved 2 USHORT reserved */
+ /* length 4 ULONG length in bytes */
+ /* language 8 ULONG Mac language code */
+ /* count 12 ULONG number of groups */
+ /* 16 */
+ /* */
+ /* This header is followed by `count' groups of the following format: */
+ /* */
+ /* start 0 ULONG first charcode */
+ /* end 4 ULONG last charcode */
+ /* startId 8 ULONG start glyph id for the group */
+ /* */
#ifdef TT_CONFIG_CMAP_FORMAT_12
@@ -1376,16 +1427,17 @@
FT_ULong length;
FT_ULong num_groups;
+
if ( table + 16 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 4;
- length = TT_NEXT_ULONG(p);
+ length = TT_NEXT_ULONG( p );
p = table + 12;
- num_groups = TT_NEXT_ULONG(p);
+ num_groups = TT_NEXT_ULONG( p );
- if ( table + length > valid->limit || length < 16 + 12*num_groups )
+ if ( table + length > valid->limit || length < 16 + 12 * num_groups )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
@@ -1392,11 +1444,12 @@
{
FT_ULong n, start, end, start_id, last = 0;
+
for ( n = 0; n < num_groups; n++ )
{
- start = TT_NEXT_ULONG(p);
- end = TT_NEXT_ULONG(p);
- start_id = TT_NEXT_ULONG(p);
+ start = TT_NEXT_ULONG( p );
+ end = TT_NEXT_ULONG( p );
+ start_id = TT_NEXT_ULONG( p );
if ( start > end )
FT_INVALID_DATA;
@@ -1406,7 +1459,7 @@
if ( valid->level >= FT_VALIDATE_TIGHT )
{
- if ( start_id + end - start >= TT_VALID_GLYPH_COUNT(valid) )
+ if ( start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
@@ -1416,7 +1469,6 @@
}
-
FT_CALLBACK_DEF( FT_UInt )
tt_cmap12_char_index( TT_CMap cmap,
FT_UInt32 char_code )
@@ -1424,14 +1476,15 @@
FT_UInt result = 0;
FT_Byte* table = cmap->data;
FT_Byte* p = table + 12;
- FT_UInt32 num_groups = TT_NEXT_ULONG(p);
+ FT_UInt32 num_groups = TT_NEXT_ULONG( p );
FT_UInt32 start, end, start_id;
+
for ( ; num_groups > 0; num_groups-- )
{
- start = TT_NEXT_ULONG(p);
- end = TT_NEXT_ULONG(p);
- start_id = TT_NEXT_ULONG(p);
+ start = TT_NEXT_ULONG( p );
+ end = TT_NEXT_ULONG( p );
+ start_id = TT_NEXT_ULONG( p );
if ( char_code < start )
break;
@@ -1447,8 +1500,8 @@
FT_CALLBACK_DEF( FT_UInt )
- tt_cmap12_char_next( TT_CMap cmap,
- FT_UInt32 *pchar_code )
+ tt_cmap12_char_next( TT_CMap cmap,
+ FT_UInt32 *pchar_code )
{
FT_Byte* table = cmap->data;
FT_UInt32 result = 0;
@@ -1455,16 +1508,17 @@
FT_UInt32 char_code = *pchar_code + 1;
FT_UInt gindex = 0;
FT_Byte* p = table + 12;
- FT_UInt32 num_groups = TT_NEXT_ULONG(p);
+ FT_UInt32 num_groups = TT_NEXT_ULONG( p );
FT_UInt32 n, start, end, start_id;
- p = table + 8208;
+ p = table + 16;
+
for ( n = 0; n < num_groups++; n++ )
{
- start = TT_NEXT_ULONG(p);
- end = TT_NEXT_ULONG(p);
- start_id = TT_NEXT_ULONG(p);
+ start = TT_NEXT_ULONG( p );
+ end = TT_NEXT_ULONG( p );
+ start_id = TT_NEXT_ULONG( p );
if ( char_code < start )
char_code = start;
@@ -1486,18 +1540,19 @@
}
- FT_CALLBACK_TABLE_DEF const TT_CMap_ClassRec tt_cmap12_class_rec =
+ FT_CALLBACK_TABLE_DEF
+ const TT_CMap_ClassRec tt_cmap12_class_rec =
{
{
- sizeof( TT_CMapRec ),
+ sizeof ( TT_CMapRec ),
- (FT_CMap_InitFunc) tt_cmap_init,
- (FT_CMap_DoneFunc) NULL,
- (FT_CMap_CharIndexFunc) tt_cmap12_char_index,
- (FT_CMap_CharNextFunc) tt_cmap12_char_next
+ (FT_CMap_InitFunc) tt_cmap_init,
+ (FT_CMap_DoneFunc) NULL,
+ (FT_CMap_CharIndexFunc)tt_cmap12_char_index,
+ (FT_CMap_CharNextFunc) tt_cmap12_char_next
},
12,
- (TT_CMap_ValidateFunc) tt_cmap12_validate
+ (TT_CMap_ValidateFunc) tt_cmap12_validate
};
@@ -1504,8 +1559,6 @@
#endif /* TT_CONFIG_CMAP_FORMAT_12 */
-
-
#ifdef FT_CONFIG_OPTION_USE_CMAPS
static const TT_CMap_Class tt_cmap_classes[] =
@@ -1542,9 +1595,9 @@
};
- /* parse the 'cmap' table and build the corresponding TT_CMap objects */
- /* in the current face.. */
- /* */
+ /* parse the `cmap' table and build the corresponding TT_CMap objects */
+ /* in the current face */
+ /* */
FT_LOCAL_DEF( FT_Error )
TT_Build_CMaps( TT_Face face )
{
@@ -1553,19 +1606,20 @@
volatile FT_UInt num_cmaps;
volatile FT_Byte* p = table;
+
if ( p + 4 > limit )
return FT_Err_Invalid_Table;
/* only recognize format 0 */
- if ( TT_NEXT_USHORT(p) != 0 )
+ if ( TT_NEXT_USHORT( p ) != 0 )
{
p -= 2;
- FT_ERROR(( "%s: unsupported 'cmap' table format = %d\n",
- "TT_Build_CMaps", TT_PEEK_USHORT(p) ));
+ FT_ERROR(( "TT_Build_CMaps: unsupported `cmap' table format = %d\n",
+ TT_PEEK_USHORT( p ) ));
return FT_Err_Invalid_Table;
}
- num_cmaps = TT_NEXT_USHORT(p);
+ num_cmaps = TT_NEXT_USHORT( p );
for ( ; num_cmaps > 0 && p + 8 <= limit; num_cmaps-- )
{
@@ -1572,19 +1626,21 @@
FT_CharMapRec charmap;
FT_UInt32 offset;
- charmap.platform_id = TT_NEXT_USHORT(p);
- charmap.encoding_id = TT_NEXT_USHORT(p);
- charmap.face = FT_FACE(face);
+
+ charmap.platform_id = TT_NEXT_USHORT( p );
+ charmap.encoding_id = TT_NEXT_USHORT( p );
+ charmap.face = FT_FACE( face );
charmap.encoding = ft_encoding_none; /* will be filled later */
- offset = TT_NEXT_ULONG(p);
+ offset = TT_NEXT_ULONG( p );
if ( offset && table + offset + 2 < limit )
{
FT_Byte* cmap = table + offset;
- FT_UInt format = TT_PEEK_USHORT(cmap);
+ FT_UInt format = TT_PEEK_USHORT( cmap );
volatile const TT_CMap_Class* pclazz = tt_cmap_classes;
TT_CMap_Class clazz;
+
for ( ; *pclazz; pclazz++ )
{
clazz = *pclazz;
@@ -1592,22 +1648,25 @@
{
volatile TT_ValidatorRec valid;
- ft_validator_init( FT_VALIDATOR(&valid), cmap, limit,
+
+ ft_validator_init( FT_VALIDATOR( &valid ), cmap, limit,
FT_VALIDATE_DEFAULT );
valid.num_glyphs = face->root.num_glyphs;
- if ( setjmp( FT_VALIDATOR(&valid)->jump_buffer ) == 0 )
+ if ( setjmp( FT_VALIDATOR( &valid )->jump_buffer ) == 0 )
{
/* validate this cmap sub-table */
- clazz->validate( cmap, FT_VALIDATOR(&valid) );
+ clazz->validate( cmap, FT_VALIDATOR( &valid ) );
}
if ( valid.validator.error == 0 )
(void)FT_CMap_New( (FT_CMap_Class)clazz, cmap, &charmap, NULL );
else
- FT_ERROR(( "%s: broken cmap sub-table ignored !!\n",
- "TT_Build_CMaps" ));
+ {
+ FT_ERROR(( "TT_Build_CMaps:" ));
+ FT_ERROR(( " broken cmap sub-table ignored!\n" ));
+ }
}
}
}
@@ -1621,7 +1680,7 @@
FT_LOCAL_DEF( FT_Error )
TT_Build_CMaps( TT_Face face )
{
- FT_ERROR(( "TT_Build_CMaps should _not_ be called !!\n" ));
+ FT_ERROR(( "No support for TT_Build_CMaps compiled\n" ));
return 0;
}
--- a/src/sfnt/ttcmap0.h
+++ b/src/sfnt/ttcmap0.h
@@ -1,10 +1,10 @@
/***************************************************************************/
/* */
-/* ttcmap.h */
+/* ttcmap0.h */
/* */
-/* TrueType character mapping table (cmap) support (specification). */
+/* TrueType new character mapping table (cmap) support (specification). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -27,19 +27,21 @@
FT_BEGIN_HEADER
- typedef struct TT_CMapRec_
+ typedef struct TT_CMapRec_
{
FT_CMapRec cmap;
- FT_Byte* data; /* pointer to in-memory cmap table */
+ FT_Byte* data; /* pointer to in-memory cmap table */
} TT_CMapRec, *TT_CMap;
- typedef const struct TT_CMap_ClassRec_* TT_CMap_Class;
+ typedef const struct TT_CMap_ClassRec_* TT_CMap_Class;
- typedef FT_Error (*TT_CMap_ValidateFunc)( FT_Byte* data,
- FT_Validator valid );
- typedef struct TT_CMap_ClassRec_
+ typedef FT_Error
+ (*TT_CMap_ValidateFunc)( FT_Byte* data,
+ FT_Validator valid );
+
+ typedef struct TT_CMap_ClassRec_
{
FT_CMap_ClassRec clazz;
FT_UInt format;
@@ -47,7 +49,8 @@
} TT_CMap_ClassRec;
- typedef struct TT_ValidatorRec_
+
+ typedef struct TT_ValidatorRec_
{
FT_ValidatorRec validator;
FT_UInt num_glyphs;
@@ -54,12 +57,13 @@
} TT_ValidatorRec, *TT_Validator;
-#define TT_VALIDATOR(x) ((TT_Validator)(x))
-#define TT_VALID_GLYPH_COUNT(v) TT_VALIDATOR(v)->num_glyphs
+#define TT_VALIDATOR( x ) ((TT_Validator)( x ))
+#define TT_VALID_GLYPH_COUNT( x ) TT_VALIDATOR( x )->num_glyphs
+
FT_LOCAL( FT_Error )
- TT_Build_CMaps( TT_Face face );
+ TT_Build_CMaps( TT_Face face );
FT_END_HEADER
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -5,7 +5,7 @@
/* Load the basic TrueType tables, i.e., tables that can be either in */
/* TTF or OTF fonts (body). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -28,6 +28,7 @@
#include <stdlib.h> /* for qsort */
+
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -48,6 +49,7 @@
/* */
/* <Input> */
/* face :: A face object handle. */
+ /* */
/* tag :: The searched tag. */
/* */
/* <Return> */
@@ -57,8 +59,8 @@
TT_LookUp_Table( TT_Face face,
FT_ULong tag )
{
- TT_Table entry;
- TT_Table limit;
+ TT_Table entry;
+ TT_Table limit;
FT_TRACE3(( "TT_LookUp_Table: %08p, `%c%c%c%c' -- ",
@@ -95,7 +97,9 @@
/* */
/* <Input> */
/* face :: A face object handle. */
+ /* */
/* tag :: The searched tag. */
+ /* */
/* stream :: The stream to seek when the table is found. */
/* */
/* <Output> */
@@ -110,8 +114,8 @@
FT_Stream stream,
FT_ULong* length )
{
- TT_Table table;
- FT_Error error;
+ TT_Table table;
+ FT_Error error;
table = TT_LookUp_Table( face, tag );
@@ -134,7 +138,7 @@
/*************************************************************************/
/* */
/* <Function> */
- /* TT_Load_SFNT_HeaderRec */
+ /* TT_Load_SFNT_HeaderRec */
/* */
/* <Description> */
/* Loads the header of a SFNT font file. Supports collections. */
@@ -141,7 +145,9 @@
/* */
/* <Input> */
/* face :: A handle to the target face object. */
+ /* */
/* stream :: The input stream. */
+ /* */
/* face_index :: If the font is a collection, the number of the font */
/* in the collection, ignored otherwise. */
/* */
@@ -161,9 +167,9 @@
/* */
FT_LOCAL_DEF( FT_Error )
TT_Load_SFNT_HeaderRec( TT_Face face,
- FT_Stream stream,
- FT_Long face_index,
- SFNT_Header sfnt )
+ FT_Stream stream,
+ FT_Long face_index,
+ SFNT_Header sfnt )
{
FT_Error error;
FT_ULong format_tag;
@@ -190,15 +196,16 @@
FT_FRAME_START( 8 ),
FT_FRAME_LONG( version ),
FT_FRAME_LONG( count ),
- FT_FRAME_END };
+ FT_FRAME_END
+ };
FT_TRACE2(( "TT_Load_SFNT_HeaderRec: %08p, %ld\n",
face, face_index ));
- face->ttc_header.tag = 0;
- face->ttc_header.version = 0;
- face->ttc_header.count = 0;
+ face->ttc_header.tag = 0;
+ face->ttc_header.version = 0;
+ face->ttc_header.count = 0;
face->num_tables = 0;
@@ -205,6 +212,7 @@
/* first of all, read the first 4 bytes. If it is `ttcf', then the */
/* file is a TrueType collection, otherwise it can be any other */
/* kind of font. */
+ /* */
if ( FT_READ_ULONG( format_tag ) )
goto Exit;
@@ -215,8 +223,8 @@
FT_TRACE3(( "TT_Load_SFNT_HeaderRec: file is a collection\n" ));
- /* it's a TrueType collection, i.e. a file containing several */
- /* font files. Read the font directory now */
+ /* It is a TrueType collection, i.e. a file containing several */
+ /* font files. Read the font directory now */
if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) )
goto Exit;
@@ -239,7 +247,7 @@
/* seek to the appropriate TrueType file, then read tag */
if ( FT_STREAM_SEEK( face->ttc_header.offsets[face_index] ) ||
- FT_READ_LONG( format_tag ) )
+ FT_READ_LONG( format_tag ) )
goto Exit;
}
@@ -284,6 +292,7 @@
/* */
/* <Input> */
/* stream :: The input stream. */
+ /* */
/* sfnt :: The SFNT directory header. */
/* */
/* <Return> */
@@ -293,14 +302,14 @@
/* The stream cursor must be at the font file's origin. */
/* */
FT_LOCAL_DEF( FT_Error )
- TT_Load_Directory( TT_Face face,
- FT_Stream stream,
- SFNT_Header sfnt )
+ TT_Load_Directory( TT_Face face,
+ FT_Stream stream,
+ SFNT_Header sfnt )
{
- FT_Error error;
- FT_Memory memory = stream->memory;
+ FT_Error error;
+ FT_Memory memory = stream->memory;
- TT_TableRec *entry, *limit;
+ TT_TableRec *entry, *limit;
FT_TRACE2(( "TT_Load_Directory: %08p\n", face ));
@@ -444,6 +453,7 @@
/* */
/* <Input> */
/* face :: A handle to the target face object. */
+ /* */
/* stream :: The input stream. */
/* */
/* <Return> */
@@ -545,6 +555,7 @@
/* */
/* <Input> */
/* face :: A handle to the target face object. */
+ /* */
/* stream :: The input stream. */
/* */
/* <Return> */
@@ -666,7 +677,9 @@
/* */
/* <Input> */
/* face :: A handle to the target face object. */
+ /* */
/* stream :: The input stream. */
+ /* */
/* vertical :: A boolean flag. If set, load vertical metrics. */
/* */
/* <Return> */
@@ -694,6 +707,7 @@
if ( vertical )
{
/* The table is optional, quit silently if it wasn't found */
+ /* */
/* XXX: Some fonts have a valid vertical header with a non-null */
/* `number_of_VMetrics' fields, but no corresponding `vmtx' */
/* table to get the metrics from (e.g. mingliu). */
@@ -753,8 +767,8 @@
goto Exit;
{
- TT_LongMetrics cur = *longs;
- TT_LongMetrics limit = cur + num_longs;
+ TT_LongMetrics cur = *longs;
+ TT_LongMetrics limit = cur + num_longs;
for ( ; cur < limit; cur++ )
@@ -806,7 +820,9 @@
/* */
/* <Input> */
/* face :: A handle to the target face object. */
+ /* */
/* stream :: The input stream. */
+ /* */
/* vertical :: A boolean flag. If set, load vertical metrics. */
/* */
/* <Return> */
@@ -906,6 +922,7 @@
/* */
/* <Input> */
/* face :: A handle to the target face object. */
+ /* */
/* stream :: The input stream. */
/* */
/* <Return> */
@@ -915,14 +932,14 @@
TT_Load_Names( TT_Face face,
FT_Stream stream )
{
- FT_Error error;
- FT_Memory memory = stream->memory;
+ FT_Error error;
+ FT_Memory memory = stream->memory;
- FT_ULong table_pos, table_len;
- FT_ULong storageOffset, storageSize;
- FT_Byte* storage;
+ FT_ULong table_pos, table_len;
+ FT_ULong storageOffset, storageSize;
+ FT_Byte* storage;
- TT_NameTable names;
+ TT_NameTable names;
const FT_Frame_Field name_table_fields[] =
{
@@ -972,10 +989,10 @@
/* check the 'storageOffset' field */
storageOffset = names->storageOffset;
- if ( storageOffset < (FT_ULong)(6 + 12*names->numNameRecords) ||
- table_len <= storageOffset )
+ if ( storageOffset < (FT_ULong)( 6 + 12 * names->numNameRecords ) ||
+ table_len <= storageOffset )
{
- FT_ERROR(( "TT.load_names: invalid 'name' table\n" ));
+ FT_ERROR(( "TT_Load_Names: invalid `name' table\n" ));
error = SFNT_Err_Name_Table_Missing;
goto Exit;
}
@@ -984,11 +1001,12 @@
/* Allocate the array of name records. */
if ( FT_ALLOC( names->names,
- names->numNameRecords*sizeof(TT_NameEntryRec) + storageSize ) ||
- FT_FRAME_ENTER( names->numNameRecords * 12L ) )
+ names->numNameRecords * sizeof ( TT_NameEntryRec ) +
+ storageSize ) ||
+ FT_FRAME_ENTER( names->numNameRecords * 12L ) )
goto Exit;
- storage = (FT_Byte*)(names->names + names->numNameRecords);
+ storage = (FT_Byte*)( names->names + names->numNameRecords );
/* Load the name records and determine how much storage is needed */
/* to hold the strings themselves. */
@@ -1002,8 +1020,8 @@
if ( FT_STREAM_READ_FIELDS( name_record_fields, cur ) )
break;
- /* invalid name entries will have "cur->string" set to NULL !! */
- if ( (FT_ULong)(cur->stringOffset + cur->stringLength) < storageSize )
+ /* invalid name entries will have "cur->string" set to NULL! */
+ if ( (FT_ULong)( cur->stringOffset + cur->stringLength ) < storageSize )
cur->string = storage + cur->stringOffset;
else
{
@@ -1016,18 +1034,17 @@
FT_FRAME_EXIT();
- if (error)
+ if ( error )
goto Exit;
- storageOffset -= 6 + 12*names->numNameRecords;
+ storageOffset -= 6 + 12 * names->numNameRecords;
if ( FT_STREAM_SKIP( storageOffset ) ||
FT_STREAM_READ( storage, storageSize ) )
goto Exit;
-
#ifdef FT_DEBUG_LEVEL_TRACE
- /* Print Name Record Table in case of debugging */
+ /* print Name Record Table in case of debugging */
{
TT_NameEntryRec* cur = names->names;
TT_NameEntryRec* limit = cur + names->numNameRecords;
@@ -1039,10 +1056,10 @@
FT_TRACE3(( "(%2d %2d %4x %2d) ",
- cur->platformID,
- cur->encodingID,
- cur->languageID,
- cur->nameID ));
+ cur->platformID,
+ cur->encodingID,
+ cur->languageID,
+ cur->nameID ));
/* I know that M$ encoded strings are Unicode, */
/* but this works reasonable well for debugging purposes. */
@@ -1049,7 +1066,7 @@
if ( cur->string )
for ( j = 0; j < (FT_UInt)cur->stringLength; j++ )
{
- FT_Byte c = *(FT_Byte*)(cur->string + j);
+ FT_Byte c = *(FT_Byte*)( cur->string + j );
if ( c >= 32 && c < 128 )
@@ -1056,7 +1073,7 @@
FT_TRACE3(( "%c", c ));
}
else
- FT_TRACE3(( "INVALID ENTRY !!\n" ));
+ FT_TRACE3(( "Invalid entry!\n" ));
FT_TRACE3(( "\n" ));
}
@@ -1088,8 +1105,8 @@
FT_LOCAL_DEF( void )
TT_Free_Names( TT_Face face )
{
- FT_Memory memory = face->root.driver->root.memory;
- TT_NameTable names = &face->name_table;
+ FT_Memory memory = face->root.driver->root.memory;
+ TT_NameTable names = &face->name_table;
/* free strings table */
@@ -1115,6 +1132,7 @@
/* */
/* <Input> */
/* face :: A handle to the target face object. */
+ /* */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
@@ -1127,21 +1145,22 @@
TT_Load_CMap( TT_Face face,
FT_Stream stream )
{
- FT_Error error;
+ FT_Error error;
+
error = face->goto_table( face, TTAG_cmap, stream, &face->cmap_size );
if ( error )
{
- FT_TRACE2(( "No 'cmap' table in font !\n" ));
+ FT_TRACE2(( "No `cmap' table in font !\n" ));
error = SFNT_Err_CMap_Table_Missing;
goto Exit;
}
if ( !FT_FRAME_EXTRACT( face->cmap_size, face->cmap_table ) )
- FT_TRACE2(( "'cmap' table loaded\n" ));
+ FT_TRACE2(( "`cmap' table loaded\n" ));
else
{
- FT_ERROR(( "'cmap' table is too short !!\n" ));
+ FT_ERROR(( "`cmap' table is too short!\n" ));
face->cmap_size = 0;
}
@@ -1213,7 +1232,7 @@
for ( ; charmap < limit; charmap++ )
{
- TT_CMapTable cmap;
+ TT_CMapTable cmap;
charmap->root.face = (FT_Face)face;
@@ -1234,7 +1253,7 @@
if ( FT_STREAM_SEEK( table_start + (FT_Long)cmap->offset ) ||
- FT_STREAM_READ_FIELDS( cmap_rec_fields, cmap ) )
+ FT_STREAM_READ_FIELDS( cmap_rec_fields, cmap ) )
goto Exit;
cmap->offset = FT_STREAM_POS();
@@ -1249,6 +1268,7 @@
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
+
/*************************************************************************/
/* */
/* <Function> */
@@ -1259,6 +1279,7 @@
/* */
/* <Input> */
/* face :: A handle to the target face object. */
+ /* */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
@@ -1352,7 +1373,7 @@
if ( error )
{
FT_TRACE2(( "is missing!\n" ));
- face->os2.version = 0xFFFF;
+ face->os2.version = 0xFFFFU;
error = SFNT_Err_Ok;
goto Exit;
}
@@ -1401,6 +1422,7 @@
/* */
/* <Input> */
/* face :: A handle to the target face object. */
+ /* */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
@@ -1459,6 +1481,7 @@
/* */
/* <Input> */
/* face :: A handle to the target face object. */
+ /* */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
@@ -1526,6 +1549,7 @@
/* */
/* <Input> */
/* face :: A handle to the target face object. */
+ /* */
/* stream :: The input stream. */
/* */
/* <Return> */
@@ -1603,6 +1627,7 @@
/* */
/* <Input> */
/* face :: A handle to the target face object. */
+ /* */
/* stream :: The input stream. */
/* */
/* <Return> */
@@ -1648,7 +1673,7 @@
if ( coverage == 0x0001 )
{
- FT_UInt num_pairs;
+ FT_UInt num_pairs;
TT_Kern0_Pair pair;
TT_Kern0_Pair limit;
@@ -1685,7 +1710,7 @@
/* ensure that the kerning pair table is sorted (yes, some */
/* fonts have unsorted tables!) */
{
- FT_UInt i;
+ FT_UInt i;
TT_Kern0_Pair pair0;
@@ -1722,6 +1747,7 @@
#undef TT_KERN_INDEX
#define TT_KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 )
+
FT_CALLBACK_DEF( int )
tt_kern_pair_compare( const void* a,
const void* b )
@@ -1737,6 +1763,7 @@
( index1 > index2 ? 1 : 0 ));
}
+
#undef TT_KERN_INDEX
@@ -1750,6 +1777,7 @@
/* */
/* <Input> */
/* face :: A handle to the target face object. */
+ /* */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
@@ -1759,12 +1787,12 @@
TT_Load_Hdmx( TT_Face face,
FT_Stream stream )
{
- FT_Error error;
- FT_Memory memory = stream->memory;
+ FT_Error error;
+ FT_Memory memory = stream->memory;
- TT_Hdmx hdmx = &face->hdmx;
- FT_Long num_glyphs;
- FT_Long record_size;
+ TT_Hdmx hdmx = &face->hdmx;
+ FT_Long num_glyphs;
+ FT_Long record_size;
hdmx->version = 0;
@@ -1807,7 +1835,7 @@
FT_READ_BYTE( cur->max_width ) )
goto Exit;
- if ( FT_ALLOC( cur->widths, num_glyphs ) ||
+ if ( FT_ALLOC( cur->widths, num_glyphs ) ||
FT_STREAM_READ( cur->widths, num_glyphs ) )
goto Exit;
--- a/src/sfnt/ttload.h
+++ b/src/sfnt/ttload.h
@@ -5,7 +5,7 @@
/* Load the basic TrueType tables, i.e., tables that can be either in */
/* TTF or OTF fonts (specification). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -42,9 +42,9 @@
FT_LOCAL( FT_Error )
TT_Load_SFNT_HeaderRec( TT_Face face,
- FT_Stream stream,
- FT_Long face_index,
- SFNT_Header sfnt );
+ FT_Stream stream,
+ FT_Long face_index,
+ SFNT_Header sfnt );
FT_LOCAL( FT_Error )
TT_Load_Directory( TT_Face face,
--- a/src/sfnt/ttpost.c
+++ b/src/sfnt/ttpost.c
@@ -5,7 +5,7 @@
/* Postcript name table processing for TrueType and OpenType fonts */
/* (body). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -33,6 +33,7 @@
#include "sferrors.h"
+
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -155,14 +156,14 @@
Load_Format_20( TT_Face face,
FT_Stream stream )
{
- FT_Memory memory = stream->memory;
- FT_Error error;
+ FT_Memory memory = stream->memory;
+ FT_Error error;
- FT_Int num_glyphs;
- FT_UShort num_names;
+ FT_Int num_glyphs;
+ FT_UShort num_names;
- FT_UShort* glyph_indices = 0;
- FT_Char** name_strings = 0;
+ FT_UShort* glyph_indices = 0;
+ FT_Char** name_strings = 0;
if ( FT_READ_USHORT( num_glyphs ) )
@@ -241,7 +242,7 @@
/* all right, set table fields and exit successfuly */
{
- TT_Post_20 table = &face->postscript_names.names.format_20;
+ TT_Post_20 table = &face->postscript_names.names.format_20;
table->num_glyphs = (FT_UShort)num_glyphs;
@@ -251,7 +252,6 @@
}
return SFNT_Err_Ok;
-
Fail1:
{
FT_UShort n;
@@ -292,7 +292,7 @@
goto Exit;
}
- if ( FT_ALLOC ( offset_table, num_glyphs ) ||
+ if ( FT_ALLOC( offset_table, num_glyphs ) ||
FT_STREAM_READ( offset_table, num_glyphs ) )
goto Fail;
@@ -316,7 +316,7 @@
/* OK, set table fields and exit successfuly */
{
- TT_Post_25 table = &face->postscript_names.names.format_25;
+ TT_Post_25 table = &face->postscript_names.names.format_25;
table->num_glyphs = (FT_UShort)num_glyphs;
@@ -380,8 +380,8 @@
FT_LOCAL_DEF( void )
TT_Free_Post_Names( TT_Face face )
{
- FT_Memory memory = face->root.memory;
- TT_Post_Names names = &face->postscript_names;
+ FT_Memory memory = face->root.memory;
+ TT_Post_Names names = &face->postscript_names;
if ( names->loaded )
@@ -390,8 +390,8 @@
{
case 0x00020000L:
{
- TT_Post_20 table = &names->names.format_20;
- FT_UShort n;
+ TT_Post_20 table = &names->names.format_20;
+ FT_UShort n;
FT_FREE( table->glyph_indices );
@@ -407,7 +407,7 @@
case 0x00028000L:
{
- TT_Post_25 table = &names->names.format_25;
+ TT_Post_25 table = &names->names.format_25;
FT_FREE( table->offsets );
@@ -446,8 +446,8 @@
FT_UInt idx,
FT_String** PSname )
{
- FT_Error error;
- TT_Post_Names names;
+ FT_Error error;
+ TT_Post_Names names;
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
PSNames_Service psnames;
@@ -480,7 +480,7 @@
case 0x00020000L:
{
- TT_Post_20 table = &names->names.format_20;
+ TT_Post_20 table = &names->names.format_20;
if ( !names->loaded )
@@ -505,7 +505,7 @@
case 0x00028000L:
{
- TT_Post_25 table = &names->names.format_25;
+ TT_Post_25 table = &names->names.format_25;
if ( !names->loaded )
--- a/src/sfnt/ttpost.h
+++ b/src/sfnt/ttpost.h
@@ -5,7 +5,7 @@
/* Postcript name table processing for TrueType and OpenType fonts */
/* (specification). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded bitmap support (body). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -222,8 +222,8 @@
/* FreeType error code. 0 means success. */
/* */
static FT_Error
- Load_SBit_Const_Metrics( TT_SBit_Range range,
- FT_Stream stream )
+ Load_SBit_Const_Metrics( TT_SBit_Range range,
+ FT_Stream stream )
{
FT_Error error;
@@ -254,9 +254,9 @@
/* FreeType error code. 0 means success. */
/* */
static FT_Error
- Load_SBit_Range_Codes( TT_SBit_Range range,
- FT_Stream stream,
- FT_Bool load_offsets )
+ Load_SBit_Range_Codes( TT_SBit_Range range,
+ FT_Stream stream,
+ FT_Bool load_offsets )
{
FT_Error error;
FT_ULong count, n, size;
@@ -317,8 +317,8 @@
/* FreeType error code. 0 means success. */
/* */
static FT_Error
- Load_SBit_Range( TT_SBit_Range range,
- FT_Stream stream )
+ Load_SBit_Range( TT_SBit_Range range,
+ FT_Stream stream )
{
FT_Error error;
FT_Memory memory = stream->memory;
@@ -346,8 +346,8 @@
for ( n = 0; n < num_glyphs; n++ )
range->glyph_offsets[n] = (FT_ULong)( range->image_offset +
- ( large ? FT_GET_ULONG()
- : FT_GET_USHORT() ) );
+ ( large ? FT_GET_ULONG()
+ : FT_GET_USHORT() ) );
FT_FRAME_EXIT();
}
break;
@@ -361,8 +361,8 @@
break;
case 5:
- error = Load_SBit_Const_Metrics( range, stream ) ||
- Load_SBit_Range_Codes( range, stream, 0 );
+ error = Load_SBit_Const_Metrics( range, stream ) ||
+ Load_SBit_Range_Codes( range, stream, 0 );
break;
default:
@@ -485,8 +485,8 @@
/* now read each strike table separately */
{
- TT_SBit_Strike strike = face->sbit_strikes;
- FT_ULong count = num_strikes;
+ TT_SBit_Strike strike = face->sbit_strikes;
+ FT_ULong count = num_strikes;
if ( FT_FRAME_ENTER( 48L * num_strikes ) )
@@ -509,14 +509,14 @@
/* allocate the index ranges for each strike table */
{
- TT_SBit_Strike strike = face->sbit_strikes;
- FT_ULong count = num_strikes;
+ TT_SBit_Strike strike = face->sbit_strikes;
+ FT_ULong count = num_strikes;
while ( count > 0 )
{
- TT_SBit_Range range;
- FT_ULong count2 = strike->num_ranges;
+ TT_SBit_Range range;
+ FT_ULong count2 = strike->num_ranges;
if ( FT_NEW_ARRAY( strike->sbit_ranges, strike->num_ranges ) )
@@ -524,7 +524,7 @@
/* read each range */
if ( FT_STREAM_SEEK( table_base + strike->ranges_offset ) ||
- FT_FRAME_ENTER( strike->num_ranges * 8L ) )
+ FT_FRAME_ENTER( strike->num_ranges * 8L ) )
goto Exit;
range = strike->sbit_ranges;
@@ -532,8 +532,8 @@
{
range->first_glyph = FT_GET_USHORT();
range->last_glyph = FT_GET_USHORT();
- range->table_offset = table_base + strike->ranges_offset
- + FT_GET_ULONG();
+ range->table_offset = table_base + strike->ranges_offset +
+ FT_GET_ULONG();
count2--;
range++;
}
@@ -547,7 +547,7 @@
{
/* Read the header */
if ( FT_STREAM_SEEK( range->table_offset ) ||
- FT_FRAME_ENTER( 8L ) )
+ FT_FRAME_ENTER( 8L ) )
goto Exit;
range->index_format = FT_GET_USHORT();
@@ -588,9 +588,9 @@
FT_LOCAL_DEF( void )
TT_Free_SBit_Strikes( TT_Face face )
{
- FT_Memory memory = face->root.memory;
- TT_SBit_Strike strike = face->sbit_strikes;
- TT_SBit_Strike strike_limit = strike + face->num_sbit_strikes;
+ FT_Memory memory = face->root.memory;
+ TT_SBit_Strike strike = face->sbit_strikes;
+ TT_SBit_Strike strike_limit = strike + face->num_sbit_strikes;
if ( strike )
@@ -597,8 +597,8 @@
{
for ( ; strike < strike_limit; strike++ )
{
- TT_SBit_Range range = strike->sbit_ranges;
- TT_SBit_Range range_limit = range + strike->num_ranges;
+ TT_SBit_Range range = strike->sbit_ranges;
+ TT_SBit_Range range_limit = range + strike->num_ranges;
if ( range )
@@ -635,8 +635,8 @@
for ( i = 0; i < face->num_sbit_strikes; i++ )
{
- if ( ( face->sbit_strikes[i].y_ppem == y_ppem ) &&
- ( ( x_ppem == 0 ) ||
+ if ( ( face->sbit_strikes[i].y_ppem == y_ppem ) &&
+ ( ( x_ppem == 0 ) ||
( face->sbit_strikes[i].x_ppem == x_ppem ) ) )
{
*astrike_index = i;
@@ -673,8 +673,8 @@
static FT_Error
Find_SBit_Range( FT_UInt glyph_index,
TT_SBit_Strike strike,
- TT_SBit_Range * arange,
- FT_ULong* aglyph_offset )
+ TT_SBit_Range *arange,
+ FT_ULong *aglyph_offset )
{
TT_SBit_RangeRec *range, *range_limit;
@@ -731,12 +731,12 @@
}
}
- /* fall-through */
- default:
- goto Fail;
+ /* fall-through */
+ default:
+ goto Fail;
}
- Found:
+ Found:
/* return successfully! */
*arange = range;
return 0;
@@ -780,18 +780,18 @@
/* glyph. */
/* */
static FT_Error
- Find_SBit_Image( TT_Face face,
- FT_UInt glyph_index,
- FT_ULong strike_index,
- TT_SBit_Range *arange,
- TT_SBit_Strike *astrike,
- FT_ULong *aglyph_offset )
+ Find_SBit_Image( TT_Face face,
+ FT_UInt glyph_index,
+ FT_ULong strike_index,
+ TT_SBit_Range *arange,
+ TT_SBit_Strike *astrike,
+ FT_ULong *aglyph_offset )
{
- FT_Error error;
- TT_SBit_Strike strike;
+ FT_Error error;
+ TT_SBit_Strike strike;
- if ( !face->sbit_strikes ||
+ if ( !face->sbit_strikes ||
( face->num_sbit_strikes <= (FT_Int)strike_index ) )
goto Fail;
@@ -844,9 +844,9 @@
/* function exit. */
/* */
static FT_Error
- Load_SBit_Metrics( FT_Stream stream,
- TT_SBit_Range range,
- TT_SBit_Metrics metrics )
+ Load_SBit_Metrics( FT_Stream stream,
+ TT_SBit_Range range,
+ TT_SBit_Metrics metrics )
{
FT_Error error = SFNT_Err_Ok;
@@ -930,8 +930,8 @@
/* metrics :: The corresponding metrics structure. */
/* */
static void
- Crop_Bitmap( FT_Bitmap* map,
- TT_SBit_Metrics metrics )
+ Crop_Bitmap( FT_Bitmap* map,
+ TT_SBit_Metrics metrics )
{
/***********************************************************************/
/* */
@@ -991,7 +991,7 @@
line = (FT_Byte*)map->buffer;
FT_MEM_MOVE( line, line + count * line_len,
- ( rows - count ) * line_len );
+ ( rows - count ) * line_len );
metrics->height = (FT_Byte)( metrics->height - count );
metrics->horiBearingY = (FT_Char)( metrics->horiBearingY - count );
@@ -1121,13 +1121,13 @@
static FT_Error
- Load_SBit_Single( FT_Bitmap* map,
- FT_Int x_offset,
- FT_Int y_offset,
- FT_Int pix_bits,
- FT_UShort image_format,
- TT_SBit_Metrics metrics,
- FT_Stream stream )
+ Load_SBit_Single( FT_Bitmap* map,
+ FT_Int x_offset,
+ FT_Int y_offset,
+ FT_Int pix_bits,
+ FT_UShort image_format,
+ TT_SBit_Metrics metrics,
+ FT_Stream stream )
{
FT_Error error;
@@ -1142,11 +1142,11 @@
}
{
- FT_Int glyph_width = metrics->width;
- FT_Int glyph_height = metrics->height;
- FT_Int glyph_size;
- FT_Int line_bits = pix_bits * glyph_width;
- FT_Bool pad_bytes = 0;
+ FT_Int glyph_width = metrics->width;
+ FT_Int glyph_height = metrics->height;
+ FT_Int glyph_size;
+ FT_Int line_bits = pix_bits * glyph_width;
+ FT_Bool pad_bytes = 0;
/* compute size of glyph image */
@@ -1160,10 +1160,17 @@
switch ( pix_bits )
{
- case 1: line_length = ( glyph_width + 7 ) >> 3; break;
- case 2: line_length = ( glyph_width + 3 ) >> 2; break;
- case 4: line_length = ( glyph_width + 1 ) >> 1; break;
- default: line_length = glyph_width;
+ case 1:
+ line_length = ( glyph_width + 7 ) >> 3;
+ break;
+ case 2:
+ line_length = ( glyph_width + 3 ) >> 2;
+ break;
+ case 4:
+ line_length = ( glyph_width + 1 ) >> 1;
+ break;
+ default:
+ line_length = glyph_width;
}
glyph_size = glyph_height * line_length;
@@ -1201,15 +1208,15 @@
static FT_Error
- Load_SBit_Image( TT_SBit_Strike strike,
- TT_SBit_Range range,
- FT_ULong ebdt_pos,
- FT_ULong glyph_offset,
- FT_Bitmap* map,
- FT_Int x_offset,
- FT_Int y_offset,
- FT_Stream stream,
- TT_SBit_Metrics metrics )
+ Load_SBit_Image( TT_SBit_Strike strike,
+ TT_SBit_Range range,
+ FT_ULong ebdt_pos,
+ FT_ULong glyph_offset,
+ FT_Bitmap* map,
+ FT_Int x_offset,
+ FT_Int y_offset,
+ FT_Stream stream,
+ TT_SBit_Metrics metrics )
{
FT_Memory memory = stream->memory;
FT_Error error;
@@ -1295,9 +1302,9 @@
/* All right, we have a compound format. First of all, read */
/* the array of elements. */
{
- TT_SBit_Component components;
- TT_SBit_Component comp;
- FT_UShort num_components, count;
+ TT_SBit_Component components;
+ TT_SBit_Component comp;
+ FT_UShort num_components, count;
if ( FT_READ_USHORT( num_components ) ||
@@ -1323,9 +1330,9 @@
comp = components;
for ( ; count > 0; count--, comp++ )
{
- TT_SBit_Range elem_range;
+ TT_SBit_Range elem_range;
TT_SBit_MetricsRec elem_metrics;
- FT_ULong elem_offset;
+ FT_ULong elem_offset;
/* find the range for this element */
@@ -1393,20 +1400,20 @@
/* The `map.buffer' field is always freed before the glyph is loaded. */
/* */
FT_LOCAL_DEF( FT_Error )
- TT_Load_SBit_Image( TT_Face face,
- FT_ULong strike_index,
- FT_UInt glyph_index,
- FT_UInt load_flags,
- FT_Stream stream,
- FT_Bitmap *map,
+ TT_Load_SBit_Image( TT_Face face,
+ FT_ULong strike_index,
+ FT_UInt glyph_index,
+ FT_UInt load_flags,
+ FT_Stream stream,
+ FT_Bitmap *map,
TT_SBit_MetricsRec *metrics )
{
- FT_Error error;
- FT_Memory memory = stream->memory;
- FT_ULong ebdt_pos, glyph_offset;
+ FT_Error error;
+ FT_Memory memory = stream->memory;
+ FT_ULong ebdt_pos, glyph_offset;
- TT_SBit_Strike strike;
- TT_SBit_Range range;
+ TT_SBit_Strike strike;
+ TT_SBit_Range range;
/* Check whether there is a glyph sbit for the current index */
--- a/src/sfnt/ttsbit.h
+++ b/src/sfnt/ttsbit.h
@@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded bitmap support (specification). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -42,12 +42,12 @@
FT_ULong *astrike_index );
FT_LOCAL( FT_Error )
- TT_Load_SBit_Image( TT_Face face,
- FT_ULong strike_index,
- FT_UInt glyph_index,
- FT_UInt load_flags,
- FT_Stream stream,
- FT_Bitmap *map,
+ TT_Load_SBit_Image( TT_Face face,
+ FT_ULong strike_index,
+ FT_UInt glyph_index,
+ FT_UInt load_flags,
+ FT_Stream stream,
+ FT_Bitmap *map,
TT_SBit_MetricsRec *metrics );