Add `start_glyph_id' and `end_glyph_id'.

These two fields are added to `FT_SvgGlyphRec' and
`FT_SVG_DocumentRec'. This is to allow the rendering port to create
a caching mechanism.
This commit is contained in:
Moazin Khatti 2019-06-24 19:34:37 +05:00
parent e48cf716f8
commit d8202166c0
4 changed files with 38 additions and 2 deletions

View File

@ -263,6 +263,12 @@ FT_BEGIN_HEADER
* units_per_EM ::
* The size of the EM square.
*
* start_glyph_id ::
* The starting glyph ID for the glyph range that this document has.
*
* end_glyph_id ::
* The ending glyph ID for the glyph range that this document has.
*
* @note:
* `metrics' and `units_per_EM' might look like repetitions since both
* fields are stored in face objects. However, the Glyph Management API
@ -282,6 +288,8 @@ FT_BEGIN_HEADER
FT_UInt glyph_index;
FT_Size_Metrics metrics;
FT_UShort units_per_EM;
FT_UShort start_glyph_id;
FT_UShort end_glyph_id;
/* TODO: (OT-SVG) Maybe put a transformation matrix here */
} FT_SvgGlyphRec;

View File

@ -169,6 +169,12 @@ FT_BEGIN_HEADER
* units_per_EM ::
* The size of the EM square.
*
* start_glyph_id ::
* The starting glyph ID for the glyph range that this document has.
*
* end_glyph_id ::
* The ending glyph ID for the glyph range that this document has.
*
* @note:
* `metrics' and `units_per_EM' might look like repetitions since both
* fields are stored in face objects. However, the Glyph Management API
@ -187,6 +193,10 @@ FT_BEGIN_HEADER
FT_ULong svg_document_length;
FT_Size_Metrics metrics;
FT_UShort units_per_EM;
FT_UShort start_glyph_id;
FT_UShort end_glyph_id;
/* TODO: (OT-SVG) Not storing glyph_index here for now. Might need to
* at some point. Review this! */
} FT_SVG_DocumentRec;
/**************************************************************************

View File

@ -328,6 +328,8 @@
glyph->glyph_index = slot->glyph_index;
glyph->metrics = document->metrics;
glyph->units_per_EM = document->units_per_EM;
glyph->start_glyph_id = document->start_glyph_id;
glyph->end_glyph_id = document->end_glyph_id;
/* copy the document into glyph */
FT_MEM_COPY( glyph->svg_document, document->svg_document, doc_length );
@ -378,6 +380,8 @@
target->svg_document_length = source->svg_document_length;
target->metrics = source->metrics;
target->units_per_EM = source->units_per_EM;
target->start_glyph_id = source->start_glyph_id;
target->end_glyph_id = source->end_glyph_id;
/* allocate space for the svg document */
target->svg_document = memory->alloc( memory,
@ -413,6 +417,9 @@
document->svg_document_length = glyph->svg_document_length;
document->metrics = glyph->metrics;
document->units_per_EM = glyph->units_per_EM;
document->start_glyph_id = glyph->start_glyph_id;
document->end_glyph_id = glyph->end_glyph_id;
slot->format = FT_GLYPH_FORMAT_SVG;
slot->other = document;

View File

@ -126,7 +126,9 @@
FT_UShort num_entries,
FT_UInt glyph_index,
FT_ULong *doc_offset,
FT_ULong *doc_length )
FT_ULong *doc_length,
FT_UShort *start_glyph,
FT_UShort *end_glyph )
{
FT_Error error;
FT_UShort start_glyph_id;
@ -158,7 +160,11 @@
if ( found != TRUE )
error = FT_THROW( Invalid_Glyph_Index );
else
{
*start_glyph = start_glyph_id;
*end_glyph = end_glyph_id;
error = FT_Err_Ok;
}
return error;
}
@ -174,6 +180,8 @@
FT_ULong doc_offset;
FT_ULong doc_length;
FT_UShort start_glyph_id;
FT_UShort end_glyph_id;
FT_ULong uncomp_size;
FT_Byte* uncomp_buffer;
@ -192,7 +200,8 @@
num_entries = FT_NEXT_USHORT( doc_list );
error = find_doc( doc_list, num_entries, glyph_index,
&doc_offset, &doc_length );
&doc_offset, &doc_length,
&start_glyph_id, &end_glyph_id );
if ( error != FT_Err_Ok )
return error;
@ -233,6 +242,8 @@
svg_document->svg_document_length = doc_length;
svg_document->metrics = glyph->face->size->metrics;
svg_document->units_per_EM = glyph->face->units_per_EM;
svg_document->start_glyph_id = start_glyph_id;
svg_document->end_glyph_id = end_glyph_id;
glyph->other = svg_document;
glyph->metrics.horiAdvance *= ((float)glyph->face->size->metrics.x_ppem)/((float)glyph->face->units_per_EM) * 64.0;