diff --git a/include/freetype/ftglyph.h b/include/freetype/ftglyph.h index 6f8fdb87c..fc503f931 100644 --- a/include/freetype/ftglyph.h +++ b/include/freetype/ftglyph.h @@ -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; diff --git a/include/freetype/svgrenderer.h b/include/freetype/svgrenderer.h index 449a443a8..b33e4234a 100644 --- a/include/freetype/svgrenderer.h +++ b/include/freetype/svgrenderer.h @@ -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; /************************************************************************** diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c index 22cf25b75..f558476d3 100644 --- a/src/base/ftglyph.c +++ b/src/base/ftglyph.c @@ -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; diff --git a/src/sfnt/ttsvg.c b/src/sfnt/ttsvg.c index 798c9071a..41c0e16a1 100644 --- a/src/sfnt/ttsvg.c +++ b/src/sfnt/ttsvg.c @@ -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;