*Some examples for the changes we have made:*
_*CVT table:*_**
Instead of loading the CVT table to the RAM and read CVT values from
there, I just set a pointer to the CVT in the Fontfile based on the ROM,
this is done in the
TT_Load_CVT() function.
When CVT values are needed we parse it on the fly by the TT_GetCVT()
function.
The functions TT_GetCVT() , TT_Load_CVT() are show below.
/*
<Function>
*/
/* TT_GetCVT
*/
/*
*/
/*
<Description>
*/
/* Given a face and a CVT table entry index in that face, returns
the */
/* CVT value
*/
FT_UShort
TT_GetCVT( TT_Face face,
FT_UInt index )
{
FT_Byte* p;
//
// In case glyph location is 16bit
//
p = (FT_Byte*) ( ((FT_UShort*)face->cvtPtr) + index );
return (FT_UShort)( FT_GET_USHORT_BE( p ) );
}
Respectvly TT_Load_CVT() function was to be changed -
/*
<Function>
*/
/*
TT_Load_CVT */
/*
<Description>
*/
/* Loads the control value table into a face
object. */
/*
<InOut>
*/
/* face :: A handle to the target face object. */
/*
<Input>
*/
/* stream :: A handle to the input
stream. */
/*
<Return>
*/
/* FreeType error code. 0 means
success. */
FT_LOCAL_DEF FT_Error
TT_Load_CVT( TT_Face face,
FT_Stream stream )
{
FT_Error error;
FT_ULong table_len;
FT_TRACE2(( "CVT " ));
error = face->goto_table( face, TTAG_cvt, stream, &table_len );
if ( error )
{
FT_TRACE2(( "is missing!\n" ));
face->cvt_size = 0;
face->cvtPtr= NULL;
error = TT_Err_Ok;
goto Exit;
}
face->cvt_size = table_len / 2;
face->cvtPtr = (FT_Short*) ( stream->base + stream->pos );
Exit:
return error;
}
_*GlyphLocations table:*_**
In the same manner we take care of the* GlyphLocations table*.
Instead of loading the GlyphLocations table to the RAM and read
GlyphLocations values from there, I just set a pointer to the
GlyphLocations in the Fontfile based on the ROM,
this is done in the TT_Prepare_Locations() function.
When GlyphLocations values are needed we parse it on the fly by the
TT_Find_Location() function.
The functions TT_Prepare_Locations() , TT_Find_Location() are show below.
/*
<Function>
*/
/*
TT_Prepare_Locations */
/*
<Description>
*/
/* Set-up member variables in the face object to point to the */
/* locations table, for later usage by
TT_Find_Location. */
/*
<InOut>
*/
/* face :: A handle to the target face
object. */
/*
<Input>
*/
/* stream :: The input
stream. */
/*
<Return>
*/
/* FreeType error code. 0 means
success. */
FT_LOCAL_DEF FT_Error
TT_Prepare_Locations( TT_Face face,
FT_Stream stream )
{
FT_Error error;
FT_Short LongOffsets;
FT_ULong table_len;
FT_TRACE2(( "Locations " ));
LongOffsets = face->header.Index_To_Loc_Format;
error = face->goto_table( face, TTAG_loca, stream, &table_len );
if ( error )
{
error = TT_Err_Locations_Missing;
goto Exit;
}
/*
<Function>
*/
/*
TT_Find_Location */
/*
<Description>
*/
/* Given a face and a glyph index in that face, returns
the */
/* glyph_location entry for that
glyph. */
/*
<InOut>
*/
/* face :: A handle to the target face
object. */
/*
<Input>
*/
/* index :: glyph index to get location
for */
/*
<Return>
*/
/* FT_ULong, which holds the location
value */
/*
*/
FT_Long
TT_Find_Location( TT_Face face,
FT_UInt index )
{
FT_Byte* p;
//
// In case glyph location is 16bit
//
if ( face->glyph_locationsShort )
{
p = (FT_Byte*) ( ((FT_UShort*)face->glyph_locationsPtr)
+ index );
return (FT_Long)( FT_GET_USHORT_BE( p ) * 2 );
}
//
// In case glyph location is 32bit
//
else
{
p = (FT_Byte*) ( face->glyph_locationsPtr + index );
return (FT_Long)( FT_GET_ULONG_BE( p ) );
}
}
Yours,
Rostoker Nir