forked from minhngoc25a/freetype2
[ot-svg] Create an SVG Document structure for use in `other' field
of `FT_GlyphSlot'.
This commit is contained in:
parent
877736d057
commit
0bf6444911
|
@ -148,6 +148,38 @@ FT_BEGIN_HEADER
|
||||||
SVG_Lib_Free free_hook,
|
SVG_Lib_Free free_hook,
|
||||||
SVG_Lib_Render render_hook );
|
SVG_Lib_Render render_hook );
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
*
|
||||||
|
* @struct:
|
||||||
|
* FT_SVG_DocumentRec_
|
||||||
|
*
|
||||||
|
* @description:
|
||||||
|
* A structure that models one SVG document.
|
||||||
|
*
|
||||||
|
* @fields:
|
||||||
|
* svg_document ::
|
||||||
|
* A pointer to the SVG document string.
|
||||||
|
*
|
||||||
|
* svg_document_length ::
|
||||||
|
* The length of the SVG document string.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct FT_SVG_DocumentRec_
|
||||||
|
{
|
||||||
|
FT_Byte* svg_document;
|
||||||
|
FT_ULong svg_document_length;
|
||||||
|
} FT_SVG_DocumentRec;
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
*
|
||||||
|
* @type:
|
||||||
|
* FT_SVG_Document
|
||||||
|
*
|
||||||
|
* @description:
|
||||||
|
* A handle to a FT_SVG_DocumentRec object.
|
||||||
|
*/
|
||||||
|
typedef struct FT_SVG_DocumentRec_* FT_SVG_Document;
|
||||||
|
|
||||||
FT_END_HEADER
|
FT_END_HEADER
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -838,6 +838,12 @@
|
||||||
if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY )
|
if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY )
|
||||||
load_flags &= ~FT_LOAD_RENDER;
|
load_flags &= ~FT_LOAD_RENDER;
|
||||||
|
|
||||||
|
if ( ( load_flags & FT_LOAD_COLOR ) &&
|
||||||
|
( ((TT_Face)face)->svg ) )
|
||||||
|
{
|
||||||
|
FT_Load_Glyph( face, glyph_index, FT_LOAD_DEFAULT );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine whether we need to auto-hint or not.
|
* Determine whether we need to auto-hint or not.
|
||||||
* The general rules are:
|
* The general rules are:
|
||||||
|
|
|
@ -347,6 +347,19 @@
|
||||||
if ( load_flags & FT_LOAD_SBITS_ONLY )
|
if ( load_flags & FT_LOAD_SBITS_ONLY )
|
||||||
return FT_THROW( Invalid_Argument );
|
return FT_THROW( Invalid_Argument );
|
||||||
|
|
||||||
|
/* check for OT-SVG */
|
||||||
|
if ( ( load_flags & FT_LOAD_COLOR ) &&
|
||||||
|
( ((TT_Face)glyph->root.face)->svg ) )
|
||||||
|
{
|
||||||
|
SFNT_Service sfnt = (SFNT_Service)((TT_Face)glyph->root.face)->sfnt;
|
||||||
|
error = sfnt->load_svg_doc( (FT_GlyphSlot)glyph, glyph_index );
|
||||||
|
if( error == FT_Err_Ok )
|
||||||
|
{
|
||||||
|
glyph->root.format = FT_GLYPH_FORMAT_SVG;
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* if we have a CID subfont, use its matrix (which has already */
|
/* if we have a CID subfont, use its matrix (which has already */
|
||||||
/* been multiplied with the root matrix) */
|
/* been multiplied with the root matrix) */
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include FT_INTERNAL_STREAM_H
|
#include FT_INTERNAL_STREAM_H
|
||||||
#include FT_TRUETYPE_TAGS_H
|
#include FT_TRUETYPE_TAGS_H
|
||||||
#include FT_GZIP_H
|
#include FT_GZIP_H
|
||||||
|
#include FT_SVG_RENDERER_H
|
||||||
|
|
||||||
|
|
||||||
#include "ttsvg.h"
|
#include "ttsvg.h"
|
||||||
|
@ -39,7 +40,7 @@
|
||||||
FT_UShort version; /* Table version (starting at 0) */
|
FT_UShort version; /* Table version (starting at 0) */
|
||||||
FT_UShort num_entries; /* Number of SVG document records */
|
FT_UShort num_entries; /* Number of SVG document records */
|
||||||
/* Pointer to the starting of SVG Document List */
|
/* Pointer to the starting of SVG Document List */
|
||||||
FT_Byte* svg_doc_list;
|
FT_Byte* svg_doc_list;
|
||||||
/* Memory that backs up SVG */
|
/* Memory that backs up SVG */
|
||||||
void* table;
|
void* table;
|
||||||
FT_ULong table_size;
|
FT_ULong table_size;
|
||||||
|
@ -68,7 +69,7 @@
|
||||||
|
|
||||||
if( FT_FRAME_EXTRACT( table_size, table ))
|
if( FT_FRAME_EXTRACT( table_size, table ))
|
||||||
goto NoSVG;
|
goto NoSVG;
|
||||||
|
|
||||||
/* Allocate the memory for the Svg object */
|
/* Allocate the memory for the Svg object */
|
||||||
if( FT_NEW( svg ) )
|
if( FT_NEW( svg ) )
|
||||||
goto NoSVG;
|
goto NoSVG;
|
||||||
|
@ -114,7 +115,7 @@
|
||||||
{
|
{
|
||||||
FT_FRAME_RELEASE( svg->table );
|
FT_FRAME_RELEASE( svg->table );
|
||||||
FT_FREE( svg );
|
FT_FREE( svg );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_Error
|
FT_Error
|
||||||
|
@ -159,12 +160,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_LOCAL_DEF(FT_Error)
|
FT_LOCAL_DEF(FT_Error)
|
||||||
tt_face_load_svg_doc( FT_GlyphSlot glyph_,
|
tt_face_load_svg_doc( FT_GlyphSlot glyph,
|
||||||
FT_UInt glyph_index )
|
FT_UInt glyph_index )
|
||||||
{
|
{
|
||||||
|
|
||||||
TT_GlyphSlot glyph = (TT_GlyphSlot) glyph_;
|
|
||||||
|
|
||||||
/* TODO: (OT-SVG) 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 */
|
||||||
|
@ -179,10 +178,12 @@
|
||||||
FT_Bool is_gzip_encoded = FALSE;
|
FT_Bool is_gzip_encoded = FALSE;
|
||||||
|
|
||||||
FT_Error error = FT_Err_Ok;
|
FT_Error error = FT_Err_Ok;
|
||||||
TT_Face face = (TT_Face)glyph->root.face;
|
TT_Face face = (TT_Face)glyph->face;
|
||||||
FT_Memory memory = face->root.memory;
|
FT_Memory memory = face->root.memory;
|
||||||
Svg* svg = face->svg;
|
Svg* svg = face->svg;
|
||||||
|
|
||||||
|
FT_SVG_Document svg_document;
|
||||||
|
|
||||||
/* handle svg being 0x0 situation here */
|
/* handle svg being 0x0 situation here */
|
||||||
doc_list = svg->svg_doc_list;
|
doc_list = svg->svg_doc_list;
|
||||||
num_entries = FT_NEXT_USHORT( doc_list );
|
num_entries = FT_NEXT_USHORT( doc_list );
|
||||||
|
@ -221,12 +222,17 @@
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
glyph->svg_document = uncomp_buffer;
|
doc_list = uncomp_buffer;
|
||||||
glyph->svg_document_length = uncomp_size;
|
doc_length = uncomp_size;
|
||||||
return FT_Err_Ok;
|
return FT_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
glyph->svg_document = doc_list;
|
if ( FT_NEW( svg_document ) )
|
||||||
glyph->svg_document_length = doc_length;
|
return FT_THROW( Out_Of_Memory );
|
||||||
|
|
||||||
|
svg_document->svg_document = doc_list;
|
||||||
|
svg_document->svg_document_length = doc_length;
|
||||||
|
|
||||||
|
glyph->other = svg_document;
|
||||||
return FT_Err_Ok;
|
return FT_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue