|
|
|
@ -32,6 +32,8 @@ |
|
|
|
|
|
|
|
|
|
#include "ttsvg.h" |
|
|
|
|
|
|
|
|
|
/* TODO: (OT-SVG) Decide whether to add documentation here or not */ |
|
|
|
|
|
|
|
|
|
typedef struct Svg_ |
|
|
|
|
{ |
|
|
|
|
FT_UShort version; /* Table version (starting at 0) */ |
|
|
|
@ -131,15 +133,16 @@ |
|
|
|
|
FT_Bool found = FALSE; |
|
|
|
|
FT_UInt i = 0; |
|
|
|
|
|
|
|
|
|
/* For now it's linear search, later convert to binary search */ |
|
|
|
|
/* TODO: (OT-SVG) Convert to efficient search algorithm */ |
|
|
|
|
/* TODO: (OT-SVG) Use Frame Fields here instead of `FT_NEXT_*' */ |
|
|
|
|
for ( i = 0; i < num_entries; i++) |
|
|
|
|
{ |
|
|
|
|
start_glyph_id = FT_NEXT_USHORT( stream ); |
|
|
|
|
end_glyph_id = FT_NEXT_USHORT( stream ); |
|
|
|
|
cur_doc_offset = FT_NEXT_ULONG( stream ); |
|
|
|
|
cur_doc_length = FT_NEXT_ULONG( stream ); |
|
|
|
|
|
|
|
|
|
if ( ( glyph_index >= start_glyph_id) &&
|
|
|
|
|
|
|
|
|
|
if ( ( glyph_index >= start_glyph_id) && |
|
|
|
|
( glyph_index <= end_glyph_id ) ) |
|
|
|
|
{ |
|
|
|
|
found = TRUE; |
|
|
|
@ -162,9 +165,9 @@ |
|
|
|
|
|
|
|
|
|
TT_GlyphSlot glyph = (TT_GlyphSlot) glyph_; |
|
|
|
|
|
|
|
|
|
/* TODO: properly clean stuff here on errors */ |
|
|
|
|
/* TODO: (OT-SVG) properly clean stuff here on errors */ |
|
|
|
|
|
|
|
|
|
FT_Byte* doc_list; /* Pointer to the Svg Document List */
|
|
|
|
|
FT_Byte* doc_list; /* Pointer to the Svg Document List */ |
|
|
|
|
FT_UShort num_entries; /* Total no of entires in doc list */ |
|
|
|
|
|
|
|
|
|
FT_ULong doc_offset; |
|
|
|
@ -176,32 +179,39 @@ |
|
|
|
|
FT_Bool is_gzip_encoded = FALSE; |
|
|
|
|
|
|
|
|
|
FT_Error error = FT_Err_Ok; |
|
|
|
|
TT_Face face = (TT_Face)glyph->root.face;
|
|
|
|
|
TT_Face face = (TT_Face)glyph->root.face; |
|
|
|
|
FT_Memory memory = face->root.memory; |
|
|
|
|
Svg* svg = face->svg; |
|
|
|
|
|
|
|
|
|
/* handle svg being 0x0 situation here */ |
|
|
|
|
doc_list = svg->svg_doc_list; |
|
|
|
|
num_entries = FT_NEXT_USHORT( doc_list ); |
|
|
|
|
|
|
|
|
|
error = find_doc( doc_list, num_entries, glyph_index,
|
|
|
|
|
|
|
|
|
|
error = find_doc( doc_list, num_entries, glyph_index, |
|
|
|
|
&doc_offset, &doc_length ); |
|
|
|
|
if ( error != FT_Err_Ok ) |
|
|
|
|
return error; |
|
|
|
|
|
|
|
|
|
doc_list = svg->svg_doc_list; /* Reset to so we can use it again */ |
|
|
|
|
doc_list = (FT_Byte*)( doc_list + doc_offset ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( ( doc_list[0] == 0x1F ) && ( doc_list[1] == 0x8B ) |
|
|
|
|
&& ( doc_list[2] == 0x08 ) ) |
|
|
|
|
{ |
|
|
|
|
is_gzip_encoded = TRUE; |
|
|
|
|
|
|
|
|
|
/* get the size of the orignal document. This helps in alotting the
|
|
|
|
|
* buffer to accomodate the uncompressed version. The last 4 bytes |
|
|
|
|
* of the compressed document are equal to orignal_size modulo 2^32. |
|
|
|
|
* Since SVG docs will be lesser in size then 2^32, we can use this |
|
|
|
|
* accurately. The four bytes are stored in little-endian format. |
|
|
|
|
*/ |
|
|
|
|
uncomp_size = (FT_ULong)doc_list[doc_length - 1] << 24 | |
|
|
|
|
(FT_ULong)doc_list[doc_length - 2] << 16 | |
|
|
|
|
(FT_ULong)doc_list[doc_length - 3] << 8 | |
|
|
|
|
(FT_ULong)doc_list[doc_length - 4]; |
|
|
|
|
|
|
|
|
|
/* TODO: memory allocated here needs to be freed somewhere */ |
|
|
|
|
/* TODO: (OT-SVG) memory allocated here needs to be freed somewhere */ |
|
|
|
|
uncomp_buffer = (FT_Byte*) memory->alloc(memory, uncomp_size); |
|
|
|
|
error = FT_Gzip_Uncompress( memory, uncomp_buffer, &uncomp_size, |
|
|
|
|
doc_list, doc_length ); |
|
|
|
@ -214,11 +224,9 @@ |
|
|
|
|
glyph->svg_document = uncomp_buffer; |
|
|
|
|
glyph->svg_document_length = uncomp_size; |
|
|
|
|
return FT_Err_Ok; |
|
|
|
|
}
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
glyph->svg_document = doc_list; |
|
|
|
|
glyph->svg_document_length = doc_length; |
|
|
|
|
return FT_Err_Ok; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|