|
From: | Nir Rostoker |
Subject: | [Freetype] FT 2.1.4 new version |
Date: | Thu, 20 Feb 2003 12:31:28 +0200 |
Hi !
During work I've made on a previous version of FreeType, I have made some changes in order to reduce RAM consumption and use ROM instead.
Within this work a few changes were needed in order to reduce RAM consumption and using ROM instead.
The main changes we have made in a nutshell:
Not loading to RAM the CVT, glyhplocations, horizontal and vertical metrics and kerning table but instead parsing them on the fly when needed, from the font file on the ROM.
My question is:
I have noticed a new version of FT was released - 2.1.4
Are those changes, i.e., instead of loading those font tables to the RAM, parsing them on the fly from the ROM supported in the new FT version ?
If not is it scheduled for the near future ?
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
[Prev in Thread] | Current Thread | [Next in Thread] |