@ -21,10 +21,10 @@
/* LangSys */
static FT _Error Load_LangSys ( HB_LangSys * ls ,
static HB _Error Load_LangSys ( HB_LangSys * ls ,
FT_Stream stream )
{
FT _Error error ;
HB _Error error ;
FT_Memory memory = stream - > memory ;
FT_UShort n , count ;
FT_UShort * fi ;
@ -57,7 +57,7 @@ static FT_Error Load_LangSys( HB_LangSys* ls,
FORGET_Frame ( ) ;
return FT _Err_Ok;
return HB _Err_Ok;
}
@ -70,10 +70,10 @@ static void Free_LangSys( HB_LangSys* ls,
/* Script */
static FT _Error Load_Script ( HB_Script * s ,
static HB _Error Load_Script ( HB_Script * s ,
FT_Stream stream )
{
FT _Error error ;
HB _Error error ;
FT_Memory memory = stream - > memory ;
FT_UShort n , m , count ;
FT_ULong cur_offset , new_offset , base_offset ;
@ -95,7 +95,7 @@ static FT_Error Load_Script( HB_Script* s,
cur_offset = FILE_Pos ( ) ;
if ( FILE_Seek ( new_offset ) | |
( error = Load_LangSys ( & s - > DefaultLangSys ,
stream ) ) ! = FT _Err_Ok )
stream ) ) ! = HB _Err_Ok )
return error ;
( void ) FILE_Seek ( cur_offset ) ;
}
@ -144,12 +144,12 @@ static FT_Error Load_Script( HB_Script* s,
cur_offset = FILE_Pos ( ) ;
if ( FILE_Seek ( new_offset ) | |
( error = Load_LangSys ( & lsr [ n ] . LangSys , stream ) ) ! = FT _Err_Ok )
( error = Load_LangSys ( & lsr [ n ] . LangSys , stream ) ) ! = HB _Err_Ok )
goto Fail1 ;
( void ) FILE_Seek ( cur_offset ) ;
}
return FT _Err_Ok;
return HB _Err_Ok;
Fail1 :
for ( m = 0 ; m < n ; m + + )
@ -188,10 +188,10 @@ static void Free_Script( HB_Script* s,
/* ScriptList */
FT _Error _HB_OPEN_Load_ScriptList ( HB_ScriptList * sl ,
HB _Error _HB_OPEN_Load_ScriptList ( HB_ScriptList * sl ,
FT_Stream stream )
{
FT _Error error ;
HB _Error error ;
FT_Memory memory = stream - > memory ;
FT_UShort n , script_count ;
@ -233,7 +233,7 @@ FT_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
goto Fail ;
error = Load_Script ( & sr [ sl - > ScriptCount ] . Script , stream ) ;
if ( error = = FT _Err_Ok )
if ( error = = HB _Err_Ok )
sl - > ScriptCount + = 1 ;
else if ( error ! = HB_Err_Empty_Script )
goto Fail ;
@ -247,12 +247,12 @@ FT_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
#if 0
if ( sl - > ScriptCount = = 0 )
{
error = HB_Err_Invalid_SubTable ;
error = _hb_err ( HB_Err_Invalid_SubTable ) ;
goto Fail ;
}
# endif
return FT _Err_Ok;
return HB _Err_Ok;
Fail :
for ( n = 0 ; n < sl - > ScriptCount ; n + + )
@ -292,10 +292,10 @@ void _HB_OPEN_Free_ScriptList( HB_ScriptList* sl,
/* Feature */
static FT _Error Load_Feature ( HB_Feature * f ,
static HB _Error Load_Feature ( HB_Feature * f ,
FT_Stream stream )
{
FT _Error error ;
HB _Error error ;
FT_Memory memory = stream - > memory ;
FT_UShort n , count ;
@ -329,7 +329,7 @@ static FT_Error Load_Feature( HB_Feature* f,
FORGET_Frame ( ) ;
return FT _Err_Ok;
return HB _Err_Ok;
}
@ -342,10 +342,10 @@ static void Free_Feature( HB_Feature* f,
/* FeatureList */
FT _Error _HB_OPEN_Load_FeatureList ( HB_FeatureList * fl ,
HB _Error _HB_OPEN_Load_FeatureList ( HB_FeatureList * fl ,
FT_Stream stream )
{
FT _Error error ;
HB _Error error ;
FT_Memory memory = stream - > memory ;
FT_UShort n , m , count ;
@ -386,12 +386,12 @@ FT_Error _HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
cur_offset = FILE_Pos ( ) ;
if ( FILE_Seek ( new_offset ) | |
( error = Load_Feature ( & fr [ n ] . Feature , stream ) ) ! = FT _Err_Ok )
( error = Load_Feature ( & fr [ n ] . Feature , stream ) ) ! = HB _Err_Ok )
goto Fail1 ;
( void ) FILE_Seek ( cur_offset ) ;
}
return FT _Err_Ok;
return HB _Err_Ok;
Fail1 :
for ( m = 0 ; m < n ; m + + )
@ -440,7 +440,7 @@ void _HB_OPEN_Free_FeatureList( HB_FeatureList* fl,
/* SubTable */
static FT _Error Load_SubTable ( HB_SubTable * st ,
static HB _Error Load_SubTable ( HB_SubTable * st ,
FT_Stream stream ,
HB_Type table_type ,
FT_UShort lookup_type )
@ -466,11 +466,11 @@ static void Free_SubTable( HB_SubTable* st,
/* Lookup */
static FT _Error Load_Lookup ( HB_Lookup * l ,
static HB _Error Load_Lookup ( HB_Lookup * l ,
FT_Stream stream ,
HB_Type type )
{
FT _Error error ;
HB _Error error ;
FT_Memory memory = stream - > memory ;
FT_UShort n , m , count ;
@ -530,12 +530,12 @@ static FT_Error Load_Lookup( HB_Lookup* l,
if ( FILE_Seek ( new_offset ) | |
( error = Load_SubTable ( & st [ n ] , stream ,
type , l - > LookupType ) ) ! = FT _Err_Ok )
type , l - > LookupType ) ) ! = HB _Err_Ok )
goto Fail ;
( void ) FILE_Seek ( cur_offset ) ;
}
return FT _Err_Ok;
return HB _Err_Ok;
Fail :
for ( m = 0 ; m < n ; m + + )
@ -570,11 +570,11 @@ static void Free_Lookup( HB_Lookup* l,
/* LookupList */
FT _Error _HB_OPEN_Load_LookupList ( HB_LookupList * ll ,
HB _Error _HB_OPEN_Load_LookupList ( HB_LookupList * ll ,
FT_Stream stream ,
HB_Type type )
{
FT _Error error ;
HB _Error error ;
FT_Memory memory = stream - > memory ;
FT_UShort n , m , count ;
@ -612,12 +612,12 @@ FT_Error _HB_OPEN_Load_LookupList( HB_LookupList* ll,
cur_offset = FILE_Pos ( ) ;
if ( FILE_Seek ( new_offset ) | |
( error = Load_Lookup ( & l [ n ] , stream , type ) ) ! = FT _Err_Ok )
( error = Load_Lookup ( & l [ n ] , stream , type ) ) ! = HB _Err_Ok )
goto Fail1 ;
( void ) FILE_Seek ( cur_offset ) ;
}
return FT _Err_Ok;
return HB _Err_Ok;
Fail1 :
FREE ( ll - > Properties ) ;
@ -663,10 +663,10 @@ void _HB_OPEN_Free_LookupList( HB_LookupList* ll,
/* CoverageFormat1 */
static FT _Error Load_Coverage1 ( HB_CoverageFormat1 * cf1 ,
static HB _Error Load_Coverage1 ( HB_CoverageFormat1 * cf1 ,
FT_Stream stream )
{
FT _Error error ;
HB _Error error ;
FT_Memory memory = stream - > memory ;
FT_UShort n , count ;
@ -699,7 +699,7 @@ static FT_Error Load_Coverage1( HB_CoverageFormat1* cf1,
FORGET_Frame ( ) ;
return FT _Err_Ok;
return HB _Err_Ok;
}
@ -712,10 +712,10 @@ static void Free_Coverage1( HB_CoverageFormat1* cf1,
/* CoverageFormat2 */
static FT _Error Load_Coverage2 ( HB_CoverageFormat2 * cf2 ,
static HB _Error Load_Coverage2 ( HB_CoverageFormat2 * cf2 ,
FT_Stream stream )
{
FT _Error error ;
HB _Error error ;
FT_Memory memory = stream - > memory ;
FT_UShort n , count ;
@ -751,14 +751,14 @@ static FT_Error Load_Coverage2( HB_CoverageFormat2* cf2,
( rr [ n ] . End - rr [ n ] . Start + ( long ) rr [ n ] . StartCoverageIndex ) > =
0x10000L )
{
error = HB_Err_Invalid_SubTable ;
error = _hb_err ( HB_Err_Invalid_SubTable ) ;
goto Fail ;
}
}
FORGET_Frame ( ) ;
return FT _Err_Ok;
return HB _Err_Ok;
Fail :
FREE ( cf2 - > RangeRecord ) ;
@ -773,10 +773,10 @@ static void Free_Coverage2( HB_CoverageFormat2* cf2,
}
FT _Error _HB_OPEN_Load_Coverage ( HB_Coverage * c ,
HB _Error _HB_OPEN_Load_Coverage ( HB_Coverage * c ,
FT_Stream stream )
{
FT _Error error ;
HB _Error error ;
if ( ACCESS_Frame ( 2L ) )
return error ;
@ -787,17 +787,12 @@ FT_Error _HB_OPEN_Load_Coverage( HB_Coverage* c,
switch ( c - > CoverageFormat )
{
case 1 :
return Load_Coverage1 ( & c - > cf . cf1 , stream ) ;
case 2 :
return Load_Coverage2 ( & c - > cf . cf2 , stream ) ;
default :
return HB_Err_Invalid_SubTable_Format ;
case 1 : return Load_Coverage1 ( & c - > cf . cf1 , stream ) ;
case 2 : return Load_Coverage2 ( & c - > cf . cf2 , stream ) ;
default : return _hb_err ( HB_Err_Invalid_SubTable_Format ) ;
}
return FT _Err_Ok; /* never reached */
return HB_Err_Ok ; /* never reached */
}
@ -806,18 +801,14 @@ void _HB_OPEN_Free_Coverage( HB_Coverage* c,
{
switch ( c - > CoverageFormat )
{
case 1 :
Free_Coverage1 ( & c - > cf . cf1 , memory ) ;
break ;
case 2 :
Free_Coverage2 ( & c - > cf . cf2 , memory ) ;
break ;
case 1 : Free_Coverage1 ( & c - > cf . cf1 , memory ) ; break ;
case 2 : Free_Coverage2 ( & c - > cf . cf2 , memory ) ; break ;
default : break ;
}
}
static FT _Error Coverage_Index1 ( HB_CoverageFormat1 * cf1 ,
static HB _Error Coverage_Index1 ( HB_CoverageFormat1 * cf1 ,
FT_UShort glyphID ,
FT_UShort * index )
{
@ -847,7 +838,7 @@ static FT_Error Coverage_Index1( HB_CoverageFormat1* cf1,
if ( glyphID = = array [ middle ] )
{
* index = middle ;
return FT _Err_Ok;
return HB _Err_Ok;
}
else if ( glyphID < array [ middle ] )
{
@ -867,7 +858,7 @@ static FT_Error Coverage_Index1( HB_CoverageFormat1* cf1,
}
static FT _Error Coverage_Index2 ( HB_CoverageFormat2 * cf2 ,
static HB _Error Coverage_Index2 ( HB_CoverageFormat2 * cf2 ,
FT_UShort glyphID ,
FT_UShort * index )
{
@ -897,7 +888,7 @@ static FT_Error Coverage_Index2( HB_CoverageFormat2* cf2,
if ( glyphID > = rr [ middle ] . Start & & glyphID < = rr [ middle ] . End )
{
* index = rr [ middle ] . StartCoverageIndex + glyphID - rr [ middle ] . Start ;
return FT _Err_Ok;
return HB _Err_Ok;
}
else if ( glyphID < rr [ middle ] . Start )
{
@ -917,23 +908,18 @@ static FT_Error Coverage_Index2( HB_CoverageFormat2* cf2,
}
FT _Error _HB_OPEN_Coverage_Index ( HB_Coverage * c ,
HB _Error _HB_OPEN_Coverage_Index ( HB_Coverage * c ,
FT_UShort glyphID ,
FT_UShort * index )
{
switch ( c - > CoverageFormat )
{
case 1 :
return Coverage_Index1 ( & c - > cf . cf1 , glyphID , index ) ;
case 2 :
return Coverage_Index2 ( & c - > cf . cf2 , glyphID , index ) ;
default :
return HB_Err_Invalid_SubTable_Format ;
case 1 : return Coverage_Index1 ( & c - > cf . cf1 , glyphID , index ) ;
case 2 : return Coverage_Index2 ( & c - > cf . cf2 , glyphID , index ) ;
default : return _hb_err ( HB_Err_Invalid_SubTable_Format ) ;
}
return FT _Err_Ok; /* never reached */
return HB_Err_Ok ; /* never reached */
}
@ -945,11 +931,11 @@ FT_Error _HB_OPEN_Coverage_Index( HB_Coverage* c,
/* ClassDefFormat1 */
static FT _Error Load_ClassDef1 ( HB_ClassDefinition * cd ,
static HB _Error Load_ClassDef1 ( HB_ClassDefinition * cd ,
FT_UShort limit ,
FT_Stream stream )
{
FT _Error error ;
HB _Error error ;
FT_Memory memory = stream - > memory ;
FT_UShort n , count ;
@ -973,7 +959,7 @@ static FT_Error Load_ClassDef1( HB_ClassDefinition* cd,
/* sanity check; we are limited to 16bit integers */
if ( cdf1 - > StartGlyph + ( long ) count > = 0x10000L )
return HB_Err_Invalid_SubTable ;
return _hb_err ( HB_Err_Invalid_SubTable ) ;
cdf1 - > ClassValueArray = NULL ;
@ -991,7 +977,7 @@ static FT_Error Load_ClassDef1( HB_ClassDefinition* cd,
cva [ n ] = GET_UShort ( ) ;
if ( cva [ n ] > = limit )
{
error = HB_Err_Invalid_SubTable ;
error = _hb_err ( HB_Err_Invalid_SubTable ) ;
goto Fail ;
}
d [ cva [ n ] ] = TRUE ;
@ -999,7 +985,7 @@ static FT_Error Load_ClassDef1( HB_ClassDefinition* cd,
FORGET_Frame ( ) ;
return FT _Err_Ok;
return HB _Err_Ok;
Fail :
FREE ( cva ) ;
@ -1017,11 +1003,11 @@ static void Free_ClassDef1( HB_ClassDefFormat1* cdf1,
/* ClassDefFormat2 */
static FT _Error Load_ClassDef2 ( HB_ClassDefinition * cd ,
static HB _Error Load_ClassDef2 ( HB_ClassDefinition * cd ,
FT_UShort limit ,
FT_Stream stream )
{
FT _Error error ;
HB _Error error ;
FT_Memory memory = stream - > memory ;
FT_UShort n , count ;
@ -1037,7 +1023,8 @@ static FT_Error Load_ClassDef2( HB_ClassDefinition* cd,
if ( ACCESS_Frame ( 2L ) )
return error ;
count = cdf2 - > ClassRangeCount = GET_UShort ( ) ;
count = GET_UShort ( ) ;
cdf2 - > ClassRangeCount = 0 ; /* zero for now. we fill with the number of good entries later */
FORGET_Frame ( ) ;
@ -1063,15 +1050,22 @@ static FT_Error Load_ClassDef2( HB_ClassDefinition* cd,
if ( crr [ n ] . Start > crr [ n ] . End | |
crr [ n ] . Class > = limit )
{
error = HB_Err_Invalid_SubTable ;
goto Fail ;
/* XXX
* Corrupt entry . Skip it .
* This is hit by Nafees Nastaliq font for example
*/
n - - ;
count - - ;
}
d [ crr [ n ] . Class ] = TRUE ;
else
d [ crr [ n ] . Class ] = TRUE ;
}
FORGET_Frame ( ) ;
return FT_Err_Ok ;
cdf2 - > ClassRangeCount = count ;
return HB_Err_Ok ;
Fail :
FREE ( crr ) ;
@ -1089,11 +1083,11 @@ static void Free_ClassDef2( HB_ClassDefFormat2* cdf2,
/* ClassDefinition */
FT _Error _HB_OPEN_Load_ClassDefinition ( HB_ClassDefinition * cd ,
HB _Error _HB_OPEN_Load_ClassDefinition ( HB_ClassDefinition * cd ,
FT_UShort limit ,
FT_Stream stream )
{
FT _Error error ;
HB _Error error ;
FT_Memory memory = stream - > memory ;
@ -1109,17 +1103,9 @@ FT_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
switch ( cd - > ClassFormat )
{
case 1 :
error = Load_ClassDef1 ( cd , limit , stream ) ;
break ;
case 2 :
error = Load_ClassDef2 ( cd , limit , stream ) ;
break ;
default :
error = HB_Err_Invalid_SubTable_Format ;
break ;
case 1 : error = Load_ClassDef1 ( cd , limit , stream ) ; break ;
case 2 : error = Load_ClassDef2 ( cd , limit , stream ) ; break ;
default : error = _hb_err ( HB_Err_Invalid_SubTable_Format ) ; break ;
}
if ( error )
@ -1127,7 +1113,7 @@ FT_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
cd - > loaded = TRUE ;
return FT _Err_Ok;
return HB _Err_Ok;
Fail :
FREE ( cd - > Defined ) ;
@ -1135,10 +1121,10 @@ Fail:
}
FT _Error _HB_OPEN_Load_EmptyClassDefinition ( HB_ClassDefinition * cd ,
HB _Error _HB_OPEN_Load_EmptyClassDefinition ( HB_ClassDefinition * cd ,
FT_Stream stream )
{
FT _Error error ;
HB _Error error ;
FT_Memory memory = stream - > memory ;
@ -1151,7 +1137,7 @@ FT_Error _HB_OPEN_Load_EmptyClassDefinition( HB_ClassDefinition* cd,
if ( ALLOC_ARRAY ( cd - > cd . cd1 . ClassValueArray , 1 , FT_UShort ) )
goto Fail ;
return FT _Err_Ok;
return HB _Err_Ok;
Fail :
FREE ( cd - > Defined ) ;
@ -1168,18 +1154,14 @@ void _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition* cd,
switch ( cd - > ClassFormat )
{
case 1 :
Free_ClassDef1 ( & cd - > cd . cd1 , memory ) ;
break ;
case 2 :
Free_ClassDef2 ( & cd - > cd . cd2 , memory ) ;
break ;
case 1 : Free_ClassDef1 ( & cd - > cd . cd1 , memory ) ; break ;
case 2 : Free_ClassDef2 ( & cd - > cd . cd2 , memory ) ; break ;
default : break ;
}
}
static FT _Error Get_Class1 ( HB_ClassDefFormat1 * cdf1 ,
static HB _Error Get_Class1 ( HB_ClassDefFormat1 * cdf1 ,
FT_UShort glyphID ,
FT_UShort * class ,
FT_UShort * index )
@ -1194,7 +1176,7 @@ static FT_Error Get_Class1( HB_ClassDefFormat1* cdf1,
glyphID < cdf1 - > StartGlyph + cdf1 - > GlyphCount )
{
* class = cva [ glyphID - cdf1 - > StartGlyph ] ;
return FT _Err_Ok;
return HB _Err_Ok;
}
else
{
@ -1207,12 +1189,12 @@ static FT_Error Get_Class1( HB_ClassDefFormat1* cdf1,
/* we need the index value of the last searched class range record
in case of failure for constructed GDEF tables */
static FT _Error Get_Class2 ( HB_ClassDefFormat2 * cdf2 ,
static HB _Error Get_Class2 ( HB_ClassDefFormat2 * cdf2 ,
FT_UShort glyphID ,
FT_UShort * class ,
FT_UShort * index )
{
FT_Error error = FT _Err_Ok;
HB_Error error = HB _Err_Ok;
FT_UShort min , max , new_min , new_max , middle ;
HB_ClassRangeRecord * crr = cdf2 - > ClassRangeRecord ;
@ -1245,7 +1227,7 @@ static FT_Error Get_Class2( HB_ClassDefFormat2* cdf2,
if ( glyphID > = crr [ middle ] . Start & & glyphID < = crr [ middle ] . End )
{
* class = crr [ middle ] . Class ;
error = FT _Err_Ok;
error = HB _Err_Ok;
break ;
}
else if ( glyphID < crr [ middle ] . Start )
@ -1277,24 +1259,19 @@ static FT_Error Get_Class2( HB_ClassDefFormat2* cdf2,
}
FT _Error _HB_OPEN_Get_Class ( HB_ClassDefinition * cd ,
HB _Error _HB_OPEN_Get_Class ( HB_ClassDefinition * cd ,
FT_UShort glyphID ,
FT_UShort * class ,
FT_UShort * index )
{
switch ( cd - > ClassFormat )
{
case 1 :
return Get_Class1 ( & cd - > cd . cd1 , glyphID , class , index ) ;
case 2 :
return Get_Class2 ( & cd - > cd . cd2 , glyphID , class , index ) ;
default :
return HB_Err_Invalid_SubTable_Format ;
case 1 : return Get_Class1 ( & cd - > cd . cd1 , glyphID , class , index ) ;
case 2 : return Get_Class2 ( & cd - > cd . cd2 , glyphID , class , index ) ;
default : return _hb_err ( HB_Err_Invalid_SubTable_Format ) ;
}
return FT _Err_Ok; /* never reached */
return HB_Err_Ok ; /* never reached */
}
@ -1304,10 +1281,10 @@ FT_Error _HB_OPEN_Get_Class( HB_ClassDefinition* cd,
* * * * * * * * * * * * * * * * * * * * * * * * * * */
FT _Error _HB_OPEN_Load_Device ( HB_Device * d ,
HB _Error _HB_OPEN_Load_Device ( HB_Device * d ,
FT_Stream stream )
{
FT _Error error ;
HB _Error error ;
FT_Memory memory = stream - > memory ;
FT_UShort n , count ;
@ -1324,11 +1301,18 @@ FT_Error _HB_OPEN_Load_Device( HB_Device* d,
FORGET_Frame ( ) ;
d - > DeltaValue = NULL ;
if ( d - > StartSize > d - > EndSize | |
d - > DeltaFormat = = 0 | | d - > DeltaFormat > 3 )
return HB_Err_Invalid_SubTable ;
d - > DeltaValue = NULL ;
{
/* XXX
* I ' ve seen fontforge generate DeltaFormat = = 0.
* Just return Ok and let the NULL DeltaValue disable
* this table .
*/
return HB_Err_Ok ;
}
count = ( ( d - > EndSize - d - > StartSize + 1 ) > >
( 4 - d - > DeltaFormat ) ) + 1 ;
@ -1349,7 +1333,7 @@ FT_Error _HB_OPEN_Load_Device( HB_Device* d,
FORGET_Frame ( ) ;
return FT _Err_Ok;
return HB _Err_Ok;
}
@ -1395,7 +1379,7 @@ void _HB_OPEN_Free_Device( HB_Device* d,
mask = 0x00FF */
FT _Error _HB_OPEN_Get_Device ( HB_Device * d ,
HB _Error _HB_OPEN_Get_Device ( HB_Device * d ,
FT_UShort size ,
FT_Short * value )
{
@ -1418,7 +1402,7 @@ FT_Error _HB_OPEN_Get_Device( HB_Device* d,
if ( * value > = ( ( mask + 1 ) > > 1 ) )
* value - = mask + 1 ;
return FT _Err_Ok;
return HB _Err_Ok;
}
else
{