forked from minhngoc25a/freetype2
Tracing implemented for OT-SVG code.
This commit is contained in:
parent
2cef19641a
commit
d7f6f8b16d
|
@ -39,6 +39,7 @@ FT_TRACE_DEF( mm ) /* MM interface (ftmm.c) */
|
|||
FT_TRACE_DEF( psprops ) /* PS driver properties (ftpsprop.c) */
|
||||
FT_TRACE_DEF( raccess ) /* resource fork accessor (ftrfork.c) */
|
||||
FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */
|
||||
FT_TRACE_DEF( otsvg ) /* ot-svg renderer (ftsvg.c) */
|
||||
FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */
|
||||
FT_TRACE_DEF( synth ) /* bold/slant synthesizer (ftsynth.c) */
|
||||
|
||||
|
|
|
@ -884,6 +884,7 @@
|
|||
if ( ( load_flags & FT_LOAD_COLOR ) &&
|
||||
( ttface->svg ) )
|
||||
{
|
||||
FT_TRACE3(( "SVG table exists, calling `FT_Load_Glyph' with `FT_LOAD_NO_SCALE'\n" ));
|
||||
/* load the TTF/CFF glyph without any scaling,
|
||||
* this is so that ultimately, these outlines
|
||||
* can be used to calculate the bounding box and
|
||||
|
|
|
@ -352,13 +352,16 @@
|
|||
if ( ( load_flags & FT_LOAD_COLOR ) &&
|
||||
( ((TT_Face)glyph->root.face)->svg ) )
|
||||
{
|
||||
FT_TRACE3(( "Attemping to load SVG glyph\n" ));
|
||||
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 )
|
||||
{
|
||||
FT_TRACE3(( "Successfully loaded SVG glyph\n" ));
|
||||
glyph->root.format = FT_GLYPH_FORMAT_SVG;
|
||||
return error;
|
||||
}
|
||||
FT_TRACE3(( "Failed to load SVG glyph\n" ));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -88,6 +88,9 @@
|
|||
p = svg->svg_doc_list;
|
||||
svg->num_entries = FT_NEXT_USHORT( p );
|
||||
|
||||
FT_TRACE3(( "version: %d\n", svg->version ));
|
||||
FT_TRACE3(( "num entiries: %d\n", svg->num_entries ));
|
||||
|
||||
svg->table = table;
|
||||
svg->table_size = table_size;
|
||||
|
||||
|
@ -182,8 +185,17 @@
|
|||
return error;
|
||||
}
|
||||
|
||||
FT_TRACE6(( "--- binary search glyph id: %d ---\n", glyph_index ));
|
||||
|
||||
start_doc = extract_svg_doc( stream + start_index * 12 );
|
||||
end_doc = extract_svg_doc( stream + end_index * 12 );
|
||||
|
||||
FT_TRACE6(( "--- start glyph ---\n" ));
|
||||
FT_TRACE6(( "start_id: %d\n", start_doc.start_glyph_id ));
|
||||
FT_TRACE6(( "end_id: %d\n", start_doc.end_glyph_id ));
|
||||
FT_TRACE6(( "--- end glyph ---\n" ));
|
||||
FT_TRACE6(( "start_id: %d\n", end_doc.start_glyph_id ));
|
||||
FT_TRACE6(( "end_id: %d\n", end_doc.end_glyph_id ));
|
||||
if ( ( compare_svg_doc( start_doc, glyph_index ) == -1 ) ||
|
||||
( compare_svg_doc( end_doc, glyph_index ) == 1 ) )
|
||||
{
|
||||
|
@ -195,27 +207,37 @@
|
|||
{
|
||||
i = ( start_index + end_index ) / 2;
|
||||
mid_doc = extract_svg_doc( stream + i * 12 );
|
||||
FT_TRACE6(( "--- current glyph ---\n" ));
|
||||
FT_TRACE6(( "start_id: %d\n", mid_doc.start_glyph_id ));
|
||||
FT_TRACE6(( "end_id: %d\n", mid_doc.end_glyph_id ));
|
||||
comp_res = compare_svg_doc( mid_doc, glyph_index );
|
||||
if ( comp_res == 1 )
|
||||
{
|
||||
start_index = i + 1;
|
||||
start_doc = extract_svg_doc( stream + start_index * 4 );
|
||||
FT_TRACE6(( "RIGHT\n" ));
|
||||
}
|
||||
else if ( comp_res == -1 )
|
||||
{
|
||||
end_index = i - 1;
|
||||
end_doc = extract_svg_doc( stream + end_index * 4 );
|
||||
FT_TRACE6(( "LEFT\n" ));
|
||||
}
|
||||
else
|
||||
{
|
||||
found = TRUE;
|
||||
FT_TRACE5(( "FOUND\n" ));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FT_TRACE5(( "--- binary search end ---\n" ));
|
||||
/* search algo end */
|
||||
if ( found != TRUE )
|
||||
{
|
||||
FT_TRACE5(( "NOT FOUND\n" ));
|
||||
error = FT_THROW( Invalid_Glyph_Index );
|
||||
}
|
||||
else
|
||||
{
|
||||
*doc_offset = mid_doc.offset;
|
||||
|
@ -274,6 +296,7 @@
|
|||
* 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.
|
||||
*/
|
||||
FT_TRACE4(( "SVG document found is GZIP compressed\n" ));
|
||||
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 |
|
||||
|
@ -300,6 +323,10 @@
|
|||
svg_document->start_glyph_id = start_glyph_id;
|
||||
svg_document->end_glyph_id = end_glyph_id;
|
||||
|
||||
FT_TRACE5(( "start_glyph_id: %d\n", start_glyph_id ));
|
||||
FT_TRACE5(( "end_glyph_id: %d\n", end_glyph_id ));
|
||||
FT_TRACE5(( "svg_document:\n%.*s\n", doc_length, doc_list ));
|
||||
|
||||
glyph->other = svg_document;
|
||||
glyph->metrics.horiAdvance *= ((float)glyph->face->size->metrics.x_ppem)/
|
||||
((float)glyph->face->units_per_EM) * 64.0;
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
|
||||
#include "ftsvg.h"
|
||||
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT otsvg
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_SVG
|
||||
/* ft_svg_init */
|
||||
static FT_Error
|
||||
|
@ -36,12 +39,14 @@
|
|||
FT_Error error = FT_Err_Ok;
|
||||
svg_module->loaded = FALSE;
|
||||
#ifdef FT_CONFIG_OPTION_DEFAULT_SVG
|
||||
FT_TRACE3(( "ft_svg_init: Default hooks being set\n" ));
|
||||
svg_module->hooks.init_svg = (SVG_Lib_Init_Func)rsvg_port_init;
|
||||
svg_module->hooks.free_svg = (SVG_Lib_Free_Func)rsvg_port_free;
|
||||
svg_module->hooks.render_svg = (SVG_Lib_Render_Func)rsvg_port_render;
|
||||
svg_module->hooks.get_buffer_size = (SVG_Lib_Get_Buffer_Size_Func)rsvg_port_get_buffer_size;
|
||||
svg_module->hooks_set = TRUE;
|
||||
#else
|
||||
FT_TRACE3(( "ft_svg_init: No default hooks set\n" ));
|
||||
svg_module->hooks_set = FALSE;
|
||||
#endif
|
||||
return error;
|
||||
|
@ -74,11 +79,13 @@
|
|||
|
||||
if ( svg_renderer->hooks_set == FALSE )
|
||||
{
|
||||
FT_TRACE1(( "Hooks are NOT set. Can't render OT-SVG glyphs\n" ));
|
||||
return FT_THROW( Missing_SVG_Hooks );
|
||||
}
|
||||
|
||||
if ( svg_renderer->loaded == FALSE )
|
||||
{
|
||||
FT_TRACE3(( "ft_svg_render: first rendering, calling init hook\n" ));
|
||||
error = hooks.init_svg( library );
|
||||
svg_renderer->loaded = TRUE;
|
||||
}
|
||||
|
|
|
@ -2911,14 +2911,17 @@
|
|||
/* check for OT-SVG */
|
||||
if ( ( load_flags & FT_LOAD_COLOR ) && ( ((TT_Face)glyph->face)->svg ) )
|
||||
{
|
||||
FT_TRACE3(( "Attemping to load SVG glyph\n" ));
|
||||
SFNT_Service sfnt;
|
||||
sfnt = (SFNT_Service)((TT_Face)glyph->face)->sfnt;
|
||||
error = sfnt->load_svg_doc( glyph, glyph_index );
|
||||
if( error == FT_Err_Ok )
|
||||
{
|
||||
FT_TRACE3(( "Successfully loaded SVG glyph\n" ));
|
||||
glyph->format = FT_GLYPH_FORMAT_SVG;
|
||||
return error;
|
||||
}
|
||||
FT_TRACE3(( "Failed to load SVG glyph\n" ));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue