|
From: | Nir Rostoker |
Subject: | RE: [Freetype] FT 2.1.4 new version |
Date: | Wed, 26 Feb 2003 10:47:47 +0200 |
Thanks for the reply.
-----Original Message-----
From: David Turner [mailto:address@hidden]
Sent: Tuesday, February 25, 2003 10:57 PM
To: address@hidden
Subject: Re: [Freetype] FT 2.1.4 new version
Hello Nir,
Nir Rostoker wrote:
> 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 work has been done in this direction. More precisely, there is now a function called FT_Stream_Extract_Frame which will "extract" a frame of contiguous bytes from a file. If it's directly available from memory, this just sets a pointer, otherwise, it allocates a buffer and copies the data into it. Hence, it saves RAM when the font is in ROM
The function FT_Stream_Release_Frame is used to "release" the frame, i.e. do nothing or free the buffer. There are also convenience macros named FT_FRAME_EXTRACT and FT_FRAME_RELEASE
This is used to "load" the CVT and a few other tables (but not the "loca", "hmtx" and "vmtx"). Changing the engine to do so might be a good idea though it is not planned for the immediate future.
Don't forget that the best way to have the feature incorporated into the engine is to send a working patch the current CVS sources. If it's not completely stupid, the chances that it gets accepted are fairly high :-)
Regards,
- David Turner
- The FreeType Project (www.freetype.org)
> *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
>
>
_______________________________________________
Freetype mailing list
address@hidden http://www.freetype.org/mailman/listinfo/freetype
[Prev in Thread] | Current Thread | [Next in Thread] |