Handle unsorted SFNT type 4 cmaps correctly (reported by Dirck
Blaskey). * src/sfnt/ttcmap.h (TT_CMap): Add member `unsorted'. * src/sfnt/ttcmac.c: Use SFNT_Err_Ok where appropriate. (tt_cmap0_validate, tt_cmap2_validate, tt_cmap6_validate, tt_cmap8_validate, tt_cmap10_validate, tt_cmap12_validate): Use `FT_Error' as return type. (tt_cmap4_validate): Use `FT_Error' as return type. Return error code for unsorted cmap. (tt_cmap4_char_index, tt_cmap4_char_next): Use old code for unsorted cmaps. (tt_face_build_cmaps): Set `unsorted' variable in cmap. Minor formatting.
This commit is contained in:
parent
43ebad4207
commit
22ad9ef024
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
|||
2005-05-07 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
Handle unsorted SFNT type 4 cmaps correctly (reported by Dirck
|
||||
Blaskey).
|
||||
|
||||
* src/sfnt/ttcmap.h (TT_CMap): Add member `unsorted'.
|
||||
* src/sfnt/ttcmac.c: Use SFNT_Err_Ok where appropriate.
|
||||
|
||||
(tt_cmap0_validate, tt_cmap2_validate, tt_cmap6_validate,
|
||||
tt_cmap8_validate, tt_cmap10_validate, tt_cmap12_validate): Use
|
||||
`FT_Error' as return type.
|
||||
(tt_cmap4_validate): Use `FT_Error' as return type.
|
||||
Return error code for unsorted cmap.
|
||||
(tt_cmap4_char_index, tt_cmap4_char_next): Use old code for unsorted
|
||||
cmaps.
|
||||
(tt_face_build_cmaps): Set `unsorted' variable in cmap.
|
||||
|
||||
2005-05-07 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
* src/truetype/ttpload.c (tt_face_get_location): Fix typo.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* FreeType path stroker (body). */
|
||||
/* */
|
||||
/* Copyright 2002, 2003, 2004 by */
|
||||
/* Copyright 2002, 2003, 2004, 2005 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
FreeType font driver for bdf files
|
||||
|
||||
Copyright (C) 2001, 2002, 2003, 2004 by
|
||||
Copyright (C) 2001, 2002, 2003, 2004, 2005 by
|
||||
Francesco Zappa Nardelli
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* The FreeType basic cache interface (body). */
|
||||
/* */
|
||||
/* Copyright 2003, 2004 by */
|
||||
/* Copyright 2003, 2004, 2005 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* FreeType CharMap cache (body) */
|
||||
/* */
|
||||
/* Copyright 2000-2001, 2002, 2003, 2004 by */
|
||||
/* Copyright 2000-2001, 2002, 2003, 2004, 2005 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* FreeType Cache Manager (body). */
|
||||
/* */
|
||||
/* Copyright 2000-2001, 2002, 2003, 2004 by */
|
||||
/* Copyright 2000-2001, 2002, 2003, 2004, 2005 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* OpenType and CFF data/program tables loader (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2001, 2002, 2003, 2004 by */
|
||||
/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* CID-keyed Type1 font loader (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2001, 2002, 2003, 2004 by */
|
||||
/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
/*-
|
||||
*
|
||||
* Copyright (c) 2004
|
||||
* Copyright (c) 2004, 2005
|
||||
* Albert Chin-A-Young.
|
||||
*
|
||||
* Modified to work with FreeType's PCF driver.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* OpenType GDEF table validation (body). */
|
||||
/* */
|
||||
/* Copyright 2004 by */
|
||||
/* Copyright 2004, 2005 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
FT_Byte* table )
|
||||
{
|
||||
cmap->data = table;
|
||||
return 0;
|
||||
return SFNT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
|||
|
||||
#ifdef TT_CONFIG_CMAP_FORMAT_0
|
||||
|
||||
FT_CALLBACK_DEF( void )
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
tt_cmap0_validate( FT_Byte* table,
|
||||
FT_Validator valid )
|
||||
{
|
||||
|
@ -106,6 +106,8 @@
|
|||
FT_INVALID_GLYPH_ID;
|
||||
}
|
||||
}
|
||||
|
||||
return SFNT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -266,7 +268,7 @@
|
|||
|
||||
#ifdef TT_CONFIG_CMAP_FORMAT_2
|
||||
|
||||
FT_CALLBACK_DEF( void )
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
tt_cmap2_validate( FT_Byte* table,
|
||||
FT_Validator valid )
|
||||
{
|
||||
|
@ -355,6 +357,8 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SFNT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -662,7 +666,7 @@
|
|||
cmap->cur_charcode = 0;
|
||||
cmap->cur_gindex = 0;
|
||||
|
||||
return 0;
|
||||
return SFNT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -792,7 +796,7 @@
|
|||
|
||||
|
||||
|
||||
FT_CALLBACK_DEF( void )
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
tt_cmap4_validate( FT_Byte* table,
|
||||
FT_Validator valid )
|
||||
{
|
||||
|
@ -800,6 +804,7 @@
|
|||
FT_UInt length = TT_NEXT_USHORT( p );
|
||||
FT_Byte *ends, *starts, *offsets, *deltas, *glyph_ids;
|
||||
FT_UInt num_segs;
|
||||
FT_Error error = SFNT_Err_Ok;
|
||||
|
||||
|
||||
/* in certain fonts, the `length' field is invalid and goes */
|
||||
|
@ -894,10 +899,12 @@
|
|||
/* unfortunately, some popular Asian fonts present overlapping */
|
||||
/* ranges in their charmaps */
|
||||
/* */
|
||||
if ( valid->level >= FT_VALIDATE_TIGHT )
|
||||
{
|
||||
if ( n > 0 && start <= last )
|
||||
{
|
||||
if ( valid->level >= FT_VALIDATE_TIGHT )
|
||||
FT_INVALID_DATA;
|
||||
else
|
||||
error = SFNT_Err_Invalid_CharMap_Format;
|
||||
}
|
||||
|
||||
if ( offset && offset != 0xFFFFU )
|
||||
|
@ -951,6 +958,8 @@
|
|||
last = end;
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
|
@ -972,11 +981,11 @@
|
|||
p = table + 6;
|
||||
num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 ); /* be paranoid! */
|
||||
|
||||
#if 1
|
||||
if ( !cmap->unsorted )
|
||||
{
|
||||
/* Some fonts have more than 170 segments in their charmaps! */
|
||||
/* We changed this function to use a more efficient binary */
|
||||
/* search for improving performance */
|
||||
{
|
||||
FT_UInt min = 0;
|
||||
FT_UInt max = num_segs2 >> 1;
|
||||
FT_UInt mid, start, end, offset;
|
||||
|
@ -1021,9 +1030,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else /* 0 - old code */
|
||||
|
||||
else
|
||||
{
|
||||
FT_UInt n;
|
||||
FT_Byte* q;
|
||||
|
@ -1066,9 +1073,6 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
}
|
||||
|
||||
Exit:
|
||||
|
@ -1113,8 +1117,8 @@
|
|||
p = table + 6;
|
||||
num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 ); /* ensure even-ness */
|
||||
|
||||
#if 1
|
||||
|
||||
if ( !cmap->unsorted )
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
/* Some fonts have more than 170 segments in their charmaps! */
|
||||
|
@ -1209,9 +1213,9 @@
|
|||
code++;
|
||||
}
|
||||
}
|
||||
|
||||
#else /* old code -- kept for reference */
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( ;; )
|
||||
{
|
||||
FT_UInt offset, n;
|
||||
|
@ -1276,8 +1280,7 @@
|
|||
|
||||
code++;
|
||||
}
|
||||
|
||||
#endif /* !1 */
|
||||
}
|
||||
|
||||
Exit:
|
||||
*pchar_code = result;
|
||||
|
@ -1349,7 +1352,7 @@
|
|||
|
||||
#ifdef TT_CONFIG_CMAP_FORMAT_6
|
||||
|
||||
FT_CALLBACK_DEF( void )
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
tt_cmap6_validate( FT_Byte* table,
|
||||
FT_Validator valid )
|
||||
{
|
||||
|
@ -1382,6 +1385,8 @@
|
|||
FT_INVALID_GLYPH_ID;
|
||||
}
|
||||
}
|
||||
|
||||
return SFNT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1535,7 +1540,7 @@
|
|||
|
||||
#ifdef TT_CONFIG_CMAP_FORMAT_8
|
||||
|
||||
FT_CALLBACK_DEF( void )
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
tt_cmap8_validate( FT_Byte* table,
|
||||
FT_Validator valid )
|
||||
{
|
||||
|
@ -1624,6 +1629,8 @@
|
|||
last = end;
|
||||
}
|
||||
}
|
||||
|
||||
return SFNT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1757,7 +1764,7 @@
|
|||
|
||||
#ifdef TT_CONFIG_CMAP_FORMAT_10
|
||||
|
||||
FT_CALLBACK_DEF( void )
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
tt_cmap10_validate( FT_Byte* table,
|
||||
FT_Validator valid )
|
||||
{
|
||||
|
@ -1788,6 +1795,8 @@
|
|||
FT_INVALID_GLYPH_ID;
|
||||
}
|
||||
}
|
||||
|
||||
return SFNT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1907,7 +1916,7 @@
|
|||
|
||||
#ifdef TT_CONFIG_CMAP_FORMAT_12
|
||||
|
||||
FT_CALLBACK_DEF( void )
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
tt_cmap12_validate( FT_Byte* table,
|
||||
FT_Validator valid )
|
||||
{
|
||||
|
@ -1954,6 +1963,8 @@
|
|||
last = end;
|
||||
}
|
||||
}
|
||||
|
||||
return SFNT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2149,6 +2160,7 @@
|
|||
if ( clazz->format == format )
|
||||
{
|
||||
volatile TT_ValidatorRec valid;
|
||||
FT_Error error = SFNT_Err_Ok;
|
||||
|
||||
|
||||
ft_validator_init( FT_VALIDATOR( &valid ), cmap, limit,
|
||||
|
@ -2159,11 +2171,19 @@
|
|||
if ( ft_setjmp( FT_VALIDATOR( &valid )->jump_buffer ) == 0 )
|
||||
{
|
||||
/* validate this cmap sub-table */
|
||||
clazz->validate( cmap, FT_VALIDATOR( &valid ) );
|
||||
error = clazz->validate( cmap, FT_VALIDATOR( &valid ) );
|
||||
}
|
||||
|
||||
if ( valid.validator.error == 0 )
|
||||
{
|
||||
(void)FT_CMap_New( (FT_CMap_Class)clazz, cmap, &charmap, NULL );
|
||||
|
||||
/* it is simpler to directly set the `unsorted' flag instead */
|
||||
/* of adding a parameter to FT_CMap_New */
|
||||
((TT_CMap)(face->root.charmaps
|
||||
[face->root.num_charmaps - 1]))->unsorted =
|
||||
FT_BOOL( error );
|
||||
}
|
||||
else
|
||||
{
|
||||
FT_ERROR(( "tt_face_build_cmaps:" ));
|
||||
|
@ -2175,7 +2195,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return SFNT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* TrueType character mapping table (cmap) support (specification). */
|
||||
/* */
|
||||
/* Copyright 2002, 2003, 2004 by */
|
||||
/* Copyright 2002, 2003, 2004, 2005 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
@ -31,6 +31,7 @@ FT_BEGIN_HEADER
|
|||
{
|
||||
FT_CMapRec cmap;
|
||||
FT_Byte* data; /* pointer to in-memory cmap table */
|
||||
FT_Bool unsorted; /* for format 4 only */
|
||||
|
||||
} TT_CMapRec, *TT_CMap;
|
||||
|
||||
|
|
|
@ -139,8 +139,8 @@
|
|||
/* whose header might also start with 0x100000L (yes, these exist). */
|
||||
/* */
|
||||
/* Very unfortunately, many TrueType fonts don't have these fields */
|
||||
/* set correctly and we must ignore them to support them. An alternative */
|
||||
/* way to check the font file is thus to: */
|
||||
/* set correctly and we must ignore them to support them. An */
|
||||
/* alternative way to check the font file is thus to: */
|
||||
/* */
|
||||
/* - check that `num_tables' is valid */
|
||||
/* - look for a "head" table, check its size, and parse it to */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* TrueType GX Font Variation loader */
|
||||
/* */
|
||||
/* Copyright 2004 by */
|
||||
/* Copyright 2004, 2005 by */
|
||||
/* David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
@ -1238,8 +1238,8 @@
|
|||
{
|
||||
/* this means that there are deltas for every entry in cvt */
|
||||
for ( j = 0; j < face->cvt_size; ++j )
|
||||
face->cvt[j] = (FT_Short)( face->cvt[j] + FT_MulFix( deltas[j],
|
||||
apply ) );
|
||||
face->cvt[j] = (FT_Short)( face->cvt[j] +
|
||||
FT_MulFix( deltas[j], apply ) );
|
||||
}
|
||||
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue