Minor doc and styling improvements.

This commit is contained in:
Moazin Khatti 2019-08-24 14:58:31 +05:00
parent 3325b42e91
commit b84ae3420a
16 changed files with 120 additions and 68 deletions

View File

@ -497,11 +497,15 @@ FT_BEGIN_HEADER
* *
* OpenType SVG Glyph Support * OpenType SVG Glyph Support
* *
* If this macro is set, OpenType SVG glyphs will be supported. * If `FT_CONFIG_OPTION_SVG` is set, OpenType SVG glyphs will be
* supported.
* If `FT_CONFIG_OPTION_DEFAULT_SVG` is also set, a default library will
* also be integrated so no external hooks will be necessary.
*/ */
#define FT_CONFIG_OPTION_SVG #define FT_CONFIG_OPTION_SVG
#define FT_CONFIG_OPTION_DEFAULT_SVG #define FT_CONFIG_OPTION_DEFAULT_SVG
/************************************************************************** /**************************************************************************
* *
* Error Strings * Error Strings

View File

@ -493,18 +493,19 @@ FT_BEGIN_HEADER
#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS #undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
/************************************************************************** /**************************************************************************
* *
* OpenType SVG Glyph Support * OpenType SVG Glyph Support
* *
* If this macro is set, OpenType SVG glyphs will be supported. * If `FT_CONFIG_OPTION_SVG` is set, OpenType SVG glyphs will be
* supported.
* If `FT_CONFIG_OPTION_DEFAULT_SVG` is also set, a default library will
* also be integrated so no external hooks will be necessary.
*/ */
#define FT_CONFIG_OPTION_SVG #define FT_CONFIG_OPTION_SVG
/* #define FT_CONFIG_OPTION_DEFAULT_SVG */ /* #define FT_CONFIG_OPTION_DEFAULT_SVG */
/************************************************************************** /**************************************************************************
* *
* Error Strings * Error Strings

View File

@ -240,7 +240,7 @@ FT_BEGIN_HEADER
* FT_SvgGlyphRec * FT_SvgGlyphRec
* *
* @description: * @description:
* A structure used for SVG glyph images. This really is a 'sub-class' * A structure used for OT-SVG glyph images. This really is a 'sub-class'
* of @FT_GlyphRec. * of @FT_GlyphRec.
* *
* @fields: * @fields:
@ -251,7 +251,7 @@ FT_BEGIN_HEADER
* A pointer to the SVG document. * A pointer to the SVG document.
* *
* svg_document_length :: * svg_document_length ::
* The length of the svg_document. * The length of `svg_document`.
* *
* glyph_index :: * glyph_index ::
* The index of the glyph to be rendered. * The index of the glyph to be rendered.
@ -263,13 +263,13 @@ FT_BEGIN_HEADER
* The size of the EM square. * The size of the EM square.
* *
* start_glyph_id :: * start_glyph_id ::
* The starting glyph ID for the glyph range that this document has. * The first glyph ID in the glyph range is covered by this document.
* *
* end_glyph_id :: * end_glyph_id ::
* The ending glyph ID for the glyph range that this document has. * The last glyph ID in the glyph range is covered by this document.
* *
* transform :: * transform ::
* Transformation matrix to apply on the glyph while rendering. * A 2x2 transformation matrix to apply on the glyph while rendering it.
* *
* delta :: * delta ::
* Translation to apply on the glyph while rendering. * Translation to apply on the glyph while rendering.
@ -283,7 +283,10 @@ FT_BEGIN_HEADER
* `units_per_EM` is needed because the SVG is to be scaled in case its * `units_per_EM` is needed because the SVG is to be scaled in case its
* viewbox size differs from `units_per_EM`. For more info, refer to * viewbox size differs from `units_per_EM`. For more info, refer to
* the section _Coordinate Systems and Glyph Metrics_ of the OpenType * the section _Coordinate Systems and Glyph Metrics_ of the OpenType
* SVG specs. * SVG specs. The `transform` and `delta` are stored here because for an
* SVG document, there's no way to apply a transformation without parsing
* it. Thus, we just store the transform and later the renderer can apply
* it while rendering.
*/ */
typedef struct FT_SvgGlyphRec_ typedef struct FT_SvgGlyphRec_
{ {
@ -297,6 +300,7 @@ FT_BEGIN_HEADER
FT_UShort end_glyph_id; FT_UShort end_glyph_id;
FT_Matrix transform; FT_Matrix transform;
FT_Vector delta; FT_Vector delta;
} FT_SvgGlyphRec; } FT_SvgGlyphRec;

View File

@ -924,6 +924,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_SVG #ifdef FT_CONFIG_OPTION_SVG
void* svg_renderer_state; void* svg_renderer_state;
#endif #endif
} FT_LibraryRec; } FT_LibraryRec;

View File

@ -39,7 +39,7 @@ FT_TRACE_DEF( mm ) /* MM interface (ftmm.c) */
FT_TRACE_DEF( psprops ) /* PS driver properties (ftpsprop.c) */ FT_TRACE_DEF( psprops ) /* PS driver properties (ftpsprop.c) */
FT_TRACE_DEF( raccess ) /* resource fork accessor (ftrfork.c) */ FT_TRACE_DEF( raccess ) /* resource fork accessor (ftrfork.c) */
FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */ FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */
FT_TRACE_DEF( otsvg ) /* ot-svg renderer (ftsvg.c) */ FT_TRACE_DEF( otsvg ) /* ot-svg renderer (ftsvg.c) */
FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */ FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */
FT_TRACE_DEF( synth ) /* bold/slant synthesizer (ftsynth.c) */ FT_TRACE_DEF( synth ) /* bold/slant synthesizer (ftsynth.c) */

View File

@ -318,12 +318,12 @@ FT_BEGIN_HEADER
* TT_Load_Svg_Doc_Func * TT_Load_Svg_Doc_Func
* *
* @description: * @description:
* Scans the SVG documents list to find the document containing the glyph * Scan the SVG document list to find the document containing the glyph
* that has the id "glyph<glyph_index>". * that has the id "glyph<glyph_index>".
* *
* @input: * @input:
* glyph :: * glyph ::
* The glyph slot from which pointers to SVG documents list will be * The glyph slot from which pointers to SVG document list will be
* grabbed. The results will be stored back in the slot too. * grabbed. The results will be stored back in the slot too.
* *
* glyph_index :: * glyph_index ::
@ -807,6 +807,7 @@ FT_BEGIN_HEADER
TT_Load_Table_Func load_svg; TT_Load_Table_Func load_svg;
TT_Free_Table_Func free_svg; TT_Free_Table_Func free_svg;
TT_Load_Svg_Doc_Func load_svg_doc; TT_Load_Svg_Doc_Func load_svg_doc;
} SFNT_Interface; } SFNT_Interface;

View File

@ -33,6 +33,7 @@ FT_BEGIN_HEADER
typedef struct SVG_Interface_ typedef struct SVG_Interface_
{ {
Preset_Bitmap_Func preset_slot; Preset_Bitmap_Func preset_slot;
} SVG_Interface; } SVG_Interface;
typedef SVG_Interface* SVG_Service; typedef SVG_Interface* SVG_Service;

View File

@ -1647,6 +1647,7 @@ FT_BEGIN_HEADER
/* OpenType SVG Glyph Support */ /* OpenType SVG Glyph Support */
void* svg; void* svg;
} TT_FaceRec; } TT_FaceRec;

View File

@ -36,7 +36,7 @@ FT_BEGIN_HEADER
* SVG_Lib_Init_Func * SVG_Lib_Init_Func
* *
* @description: * @description:
* A callback used to initiate the SVG Rendering port * A callback used to initiate the SVG Rendering port.
* *
* @input: * @input:
* library :: * library ::
@ -46,7 +46,6 @@ FT_BEGIN_HEADER
* @return: * @return:
* FreeType error code. 0 means success. * FreeType error code. 0 means success.
*/ */
typedef FT_Error typedef FT_Error
(*SVG_Lib_Init_Func)( FT_Library library ); (*SVG_Lib_Init_Func)( FT_Library library );
@ -65,7 +64,6 @@ FT_BEGIN_HEADER
* A instance of library. This is required to free the renderer's * A instance of library. This is required to free the renderer's
* state which will be held in the library. * state which will be held in the library.
*/ */
typedef void typedef void
(*SVG_Lib_Free_Func)( FT_Library library ); (*SVG_Lib_Free_Func)( FT_Library library );
@ -85,7 +83,6 @@ FT_BEGIN_HEADER
* @return: * @return:
* FreeType error code. 0 means success. * FreeType error code. 0 means success.
*/ */
typedef FT_Error typedef FT_Error
(*SVG_Lib_Render_Func)( FT_GlyphSlot slot ); (*SVG_Lib_Render_Func)( FT_GlyphSlot slot );
@ -104,11 +101,33 @@ FT_BEGIN_HEADER
* @return: * @return:
* FreeType error code. 0 means success. * FreeType error code. 0 means success.
*/ */
typedef FT_Error typedef FT_Error
(*SVG_Lib_Preset_Slot_Func)( FT_GlyphSlot slot, FT_Bool cache); (*SVG_Lib_Preset_Slot_Func)( FT_GlyphSlot slot, FT_Bool cache);
/**************************************************************************
*
* @struct:
* SVG_RendererHooks
*
* @description:
* A structure that stores the four hooks needed to render OT-SVG glyphs
* properly. The structure is publicly used to set the hooks via driver
* properties.
*
* @fields:
* init_svg ::
* The initialization hook.
*
* free_svg ::
* The cleanup hook.
*
* render_hook ::
* The render hook.
*
* preset_slot ::
* The preset hook.
*/
typedef struct SVG_RendererHooks_ typedef struct SVG_RendererHooks_
{ {
/* Api Hooks for OT-SVG Rendering */ /* Api Hooks for OT-SVG Rendering */
@ -117,6 +136,7 @@ FT_BEGIN_HEADER
SVG_Lib_Render_Func render_svg; SVG_Lib_Render_Func render_svg;
SVG_Lib_Preset_Slot_Func preset_slot; SVG_Lib_Preset_Slot_Func preset_slot;
} SVG_RendererHooks; } SVG_RendererHooks;
@ -130,10 +150,10 @@ FT_BEGIN_HEADER
* *
* @fields: * @fields:
* svg_document :: * svg_document ::
* A pointer to the SVG document string. * A pointer to the SVG document.
* *
* svg_document_length :: * svg_document_length ::
* The length of the SVG document string. * The length of `svg_document`.
* *
* metrics :: * metrics ::
* A metrics object storing the size information. * A metrics object storing the size information.
@ -142,13 +162,13 @@ FT_BEGIN_HEADER
* The size of the EM square. * The size of the EM square.
* *
* start_glyph_id :: * start_glyph_id ::
* The starting glyph ID for the glyph range that this document has. * The first glyph ID in the glyph range is covered by this document.
* *
* end_glyph_id :: * end_glyph_id ::
* The ending glyph ID for the glyph range that this document has. * The last glyph ID in the glyph range is covered by this document.
* *
* transform :: * transform ::
* Transformation matrix to apply on the glyph while rendering. * A 2x2 transformation matrix to apply on the glyph while rendering it.
* *
* delta :: * delta ::
* Translation to apply on the glyph while rendering. * Translation to apply on the glyph while rendering.
@ -173,6 +193,7 @@ FT_BEGIN_HEADER
FT_UShort end_glyph_id; FT_UShort end_glyph_id;
FT_Matrix transform; FT_Matrix transform;
FT_Vector delta; FT_Vector delta;
} FT_SVG_DocumentRec; } FT_SVG_DocumentRec;
/************************************************************************** /**************************************************************************

View File

@ -343,6 +343,7 @@
FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph; FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
FT_Memory memory = svg_glyph->library->memory; FT_Memory memory = svg_glyph->library->memory;
/* just free the memory */ /* just free the memory */
memory->free( memory, glyph->svg_document ); memory->free( memory, glyph->svg_document );
} }
@ -356,6 +357,7 @@
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
FT_Memory memory = FT_GLYPH( source )->library->memory; FT_Memory memory = FT_GLYPH( source )->library->memory;
if ( svg_source->format != FT_GLYPH_FORMAT_SVG ) if ( svg_source->format != FT_GLYPH_FORMAT_SVG )
{ {
error = FT_THROW( Invalid_Glyph_Format ); error = FT_THROW( Invalid_Glyph_Format );
@ -395,15 +397,14 @@
const FT_Matrix* _matrix, const FT_Matrix* _matrix,
const FT_Vector* _delta ) const FT_Vector* _delta )
{ {
FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph; FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
FT_Matrix* matrix = (FT_Matrix*)_matrix;
FT_Vector* delta = (FT_Vector*)_delta;
FT_Matrix tmp_matrix;
FT_Vector tmp_delta;
FT_Matrix a, b;
FT_Pos x, y;
FT_Matrix* matrix = (FT_Matrix*)_matrix;
FT_Vector* delta = (FT_Vector*)_delta;
FT_Matrix tmp_matrix;
FT_Vector tmp_delta;
FT_Matrix a, b;
FT_Pos x, y;
if ( !matrix ) if ( !matrix )
{ {
@ -443,12 +444,12 @@
ft_svg_glyph_prepare( FT_Glyph svg_glyph, ft_svg_glyph_prepare( FT_Glyph svg_glyph,
FT_GlyphSlot slot ) FT_GlyphSlot slot )
{ {
FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph; FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
FT_Memory memory = svg_glyph->library->memory; FT_Memory memory = svg_glyph->library->memory;
FT_SVG_Document document; FT_SVG_Document document;
if ( FT_NEW( document ) ) if ( FT_NEW( document ) )
return error; return error;

View File

@ -358,6 +358,7 @@
FT_UShort advanceX; FT_UShort advanceX;
FT_UShort advanceY; FT_UShort advanceY;
if ( ( size->root.metrics.x_ppem < 1 || if ( ( size->root.metrics.x_ppem < 1 ||
size->root.metrics.y_ppem < 1 ) ) size->root.metrics.y_ppem < 1 ) )
{ {
@ -367,6 +368,7 @@
FT_TRACE3(( "Attemping to load SVG glyph\n" )); FT_TRACE3(( "Attemping to load SVG glyph\n" ));
sfnt = (SFNT_Service)((TT_Face)glyph->root.face)->sfnt; sfnt = (SFNT_Service)((TT_Face)glyph->root.face)->sfnt;
error = sfnt->load_svg_doc( (FT_GlyphSlot)glyph, glyph_index ); error = sfnt->load_svg_doc( (FT_GlyphSlot)glyph, glyph_index );
if( error == FT_Err_Ok ) if( error == FT_Err_Ok )
{ {
@ -388,6 +390,7 @@
((float)glyph->root.face->units_per_EM) * 64.0; ((float)glyph->root.face->units_per_EM) * 64.0;
glyph->root.metrics.horiAdvance = advanceX; glyph->root.metrics.horiAdvance = advanceX;
glyph->root.metrics.vertAdvance = advanceY; glyph->root.metrics.vertAdvance = advanceY;
return error; return error;
} }
FT_TRACE3(( "Failed to load SVG glyph\n" )); FT_TRACE3(( "Failed to load SVG glyph\n" ));

View File

@ -1305,6 +1305,7 @@
tt_face_get_name, /* TT_Get_Name_Func get_name */ tt_face_get_name, /* TT_Get_Name_Func get_name */
sfnt_get_name_id, /* TT_Get_Name_ID_Func get_name_id */ sfnt_get_name_id, /* TT_Get_Name_ID_Func get_name_id */
PUT_SVG_SUPPORT( tt_face_load_svg ), PUT_SVG_SUPPORT( tt_face_load_svg ),
/* TT_Load_Table_Func load_svg */ /* TT_Load_Table_Func load_svg */
PUT_SVG_SUPPORT( tt_face_free_svg ), PUT_SVG_SUPPORT( tt_face_free_svg ),

View File

@ -46,6 +46,7 @@
/* Memory that backs up SVG */ /* Memory that backs up SVG */
void* table; void* table;
FT_ULong table_size; FT_ULong table_size;
} Svg; } Svg;
#undef FT_COMPONENT #undef FT_COMPONENT
@ -57,14 +58,11 @@
{ {
FT_Error error; FT_Error error;
FT_Memory memory = face->root.memory; FT_Memory memory = face->root.memory;
FT_ULong table_size; FT_ULong table_size;
FT_Byte* table = NULL; FT_Byte* table = NULL;
FT_Byte* p = NULL; FT_Byte* p = NULL;
Svg* svg = NULL; Svg* svg = NULL;
FT_ULong offsetToSVGDocumentList;
FT_ULong offsetToSVGDocumentList;
error = face->goto_table( face, TTAG_SVG, stream, &table_size ); error = face->goto_table( face, TTAG_SVG, stream, &table_size );
@ -134,16 +132,19 @@
FT_UShort end_glyph_id; FT_UShort end_glyph_id;
FT_ULong offset; FT_ULong offset;
FT_ULong length; FT_ULong length;
} Svg_doc; } Svg_doc;
static Svg_doc static Svg_doc
extract_svg_doc( FT_Byte* stream ) extract_svg_doc( FT_Byte* stream )
{ {
Svg_doc doc; Svg_doc doc;
doc.start_glyph_id = FT_NEXT_USHORT( stream ); doc.start_glyph_id = FT_NEXT_USHORT( stream );
doc.end_glyph_id = FT_NEXT_USHORT( stream ); doc.end_glyph_id = FT_NEXT_USHORT( stream );
doc.offset = FT_NEXT_ULONG( stream ); doc.offset = FT_NEXT_ULONG( stream );
doc.length = FT_NEXT_ULONG( stream ); doc.length = FT_NEXT_ULONG( stream );
return doc; return doc;
} }
@ -242,10 +243,11 @@
} }
else else
{ {
*doc_offset = mid_doc.offset; *doc_offset = mid_doc.offset;
*doc_length = mid_doc.length; *doc_length = mid_doc.length;
*start_glyph = mid_doc.start_glyph_id; *start_glyph = mid_doc.start_glyph_id;
*end_glyph = mid_doc.end_glyph_id; *end_glyph = mid_doc.end_glyph_id;
error = FT_Err_Ok; error = FT_Err_Ok;
} }
return error; return error;
@ -257,12 +259,10 @@
{ {
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_UShort num_entries; /* Total no of entires in doc list */
FT_ULong doc_offset; FT_ULong doc_offset;
FT_ULong doc_length; FT_ULong doc_length;
FT_UShort start_glyph_id; FT_UShort start_glyph_id;
FT_UShort end_glyph_id; FT_UShort end_glyph_id;
FT_ULong uncomp_size; FT_ULong uncomp_size;
FT_Byte* uncomp_buffer; FT_Byte* uncomp_buffer;
@ -273,6 +273,7 @@
FT_SVG_Document svg_document = glyph->other; FT_SVG_Document svg_document = glyph->other;
FT_ASSERT( !( svg == NULL ) ); FT_ASSERT( !( svg == NULL ) );
doc_list = svg->svg_doc_list; doc_list = svg->svg_doc_list;
@ -336,13 +337,13 @@
glyph->other = svg_document; glyph->other = svg_document;
Exit: Exit:
return error; return error;
} }
#else /* !FT_CONFIG_OPTION_SVG */ #else /* !FT_CONFIG_OPTION_SVG */
/* ANSI C doesn't like empty source files */ /* ANSI C doesn't like empty source files */
typedef int _tt_cpal_dummy; typedef int _tt_svg_dummy;
#endif /* !FT_CONFIG_OPTION_SVG */ #endif /* !FT_CONFIG_OPTION_SVG */

View File

@ -23,24 +23,25 @@
#include FT_INTERNAL_SVG_INTERFACE_H #include FT_INTERNAL_SVG_INTERFACE_H
#include FT_BBOX_H #include FT_BBOX_H
#include "ftsvg.h"
#include "svgtypes.h" #include "svgtypes.h"
#ifdef FT_CONFIG_OPTION_DEFAULT_SVG #ifdef FT_CONFIG_OPTION_DEFAULT_SVG
#include "rsvg_port.h" #include "rsvg_port.h"
#endif #endif
#include <stdio.h>
#include "ftsvg.h"
#undef FT_COMPONENT #undef FT_COMPONENT
#define FT_COMPONENT otsvg #define FT_COMPONENT otsvg
#ifdef FT_CONFIG_OPTION_SVG #ifdef FT_CONFIG_OPTION_SVG
/* ft_svg_init */ /* ft_svg_init */
static FT_Error static FT_Error
ft_svg_init( SVG_Renderer svg_module ) ft_svg_init( SVG_Renderer svg_module )
{ {
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
svg_module->loaded = FALSE; svg_module->loaded = FALSE;
#ifdef FT_CONFIG_OPTION_DEFAULT_SVG #ifdef FT_CONFIG_OPTION_DEFAULT_SVG
FT_TRACE3(( "ft_svg_init: Default hooks being set\n" )); FT_TRACE3(( "ft_svg_init: Default hooks being set\n" ));
@ -53,6 +54,7 @@
FT_TRACE3(( "ft_svg_init: No default hooks set\n" )); FT_TRACE3(( "ft_svg_init: No default hooks set\n" ));
svg_module->hooks_set = FALSE; svg_module->hooks_set = FALSE;
#endif #endif
return error; return error;
} }
@ -60,6 +62,8 @@
ft_svg_done( SVG_Renderer svg_module ) ft_svg_done( SVG_Renderer svg_module )
{ {
FT_Library library = svg_module->root.root.library; FT_Library library = svg_module->root.root.library;
if ( svg_module->loaded == TRUE && if ( svg_module->loaded == TRUE &&
svg_module->hooks_set == TRUE ) svg_module->hooks_set == TRUE )
svg_module->hooks.free_svg( library ); svg_module->hooks.free_svg( library );
@ -71,8 +75,9 @@
FT_GlyphSlot slot, FT_GlyphSlot slot,
FT_Bool cache ) FT_Bool cache )
{ {
SVG_Renderer svg_renderer = (SVG_Renderer)module; SVG_Renderer svg_renderer = (SVG_Renderer)module;
SVG_RendererHooks hooks = svg_renderer->hooks; SVG_RendererHooks hooks = svg_renderer->hooks;
if ( svg_renderer->hooks_set == FALSE ) if ( svg_renderer->hooks_set == FALSE )
{ {
@ -97,6 +102,7 @@
SVG_RendererHooks hooks = svg_renderer->hooks; SVG_RendererHooks hooks = svg_renderer->hooks;
if ( svg_renderer->hooks_set == FALSE ) if ( svg_renderer->hooks_set == FALSE )
{ {
FT_TRACE1(( "Hooks are NOT set. Can't render OT-SVG glyphs\n" )); FT_TRACE1(( "Hooks are NOT set. Can't render OT-SVG glyphs\n" ));
@ -111,6 +117,7 @@
} }
ft_svg_preset_slot( (FT_Module)renderer, slot, TRUE); ft_svg_preset_slot( (FT_Module)renderer, slot, TRUE);
size_image_buffer = slot->bitmap.pitch * slot->bitmap.rows; size_image_buffer = slot->bitmap.pitch * slot->bitmap.rows;
FT_MEM_ALLOC( slot->bitmap.buffer, size_image_buffer); FT_MEM_ALLOC( slot->bitmap.buffer, size_image_buffer);
if ( error ) if ( error )
@ -138,6 +145,7 @@
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
SVG_Renderer renderer = (SVG_Renderer)module; SVG_Renderer renderer = (SVG_Renderer)module;
if ( !ft_strcmp( property_name, "svg_hooks" ) ) if ( !ft_strcmp( property_name, "svg_hooks" ) )
{ {
SVG_RendererHooks* hooks; SVG_RendererHooks* hooks;
@ -151,9 +159,8 @@
renderer->hooks_set = TRUE; renderer->hooks_set = TRUE;
} }
else else
{
error = FT_THROW( Missing_Property ); error = FT_THROW( Missing_Property );
}
return error; return error;
} }
@ -165,15 +172,15 @@
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
SVG_Renderer renderer = (SVG_Renderer)module; SVG_Renderer renderer = (SVG_Renderer)module;
if ( !ft_strcmp( property_name, "svg_hooks" ) ) if ( !ft_strcmp( property_name, "svg_hooks" ) )
{ {
SVG_RendererHooks* hooks = (SVG_RendererHooks*)value; SVG_RendererHooks* hooks = (SVG_RendererHooks*)value;
*hooks = renderer->hooks; *hooks = renderer->hooks;
} }
else else
{
error = FT_THROW( Missing_Property ); error = FT_THROW( Missing_Property );
}
return error; return error;
} }
@ -199,6 +206,7 @@
result = ft_service_list_lookup( ft_svg_services, ft_svg_interface ); result = ft_service_list_lookup( ft_svg_services, ft_svg_interface );
if ( result ) if ( result )
return result; return result;
return 0; return 0;
} }
@ -208,14 +216,14 @@
const FT_Matrix* _matrix, const FT_Matrix* _matrix,
const FT_Vector* _delta ) const FT_Vector* _delta )
{ {
FT_SVG_Document doc = (FT_SVG_Document)slot->other; FT_SVG_Document doc = (FT_SVG_Document)slot->other;
FT_Matrix* matrix = (FT_Matrix*)_matrix;
FT_Vector* delta = (FT_Vector*)_delta;
FT_Matrix tmp_matrix;
FT_Vector tmp_delta;
FT_Matrix a, b;
FT_Pos x, y;
FT_Matrix* matrix = (FT_Matrix*)_matrix;
FT_Vector* delta = (FT_Vector*)_delta;
FT_Matrix tmp_matrix;
FT_Vector tmp_delta;
FT_Matrix a, b;
FT_Pos x, y;
if ( !matrix ) if ( !matrix )
{ {
@ -246,9 +254,9 @@
FT_MulFix(matrix->yx, doc->delta.x), FT_MulFix(matrix->yx, doc->delta.x),
FT_MulFix(matrix->yy, doc->delta.y)), FT_MulFix(matrix->yy, doc->delta.y)),
delta->y); delta->y);
doc->delta.x = x;
doc->delta.y = y;
doc->delta.x = x;
doc->delta.y = y;
doc->transform = a; doc->transform = a;
return FT_Err_Ok; return FT_Err_Ok;

View File

@ -29,6 +29,7 @@
FT_Bool loaded; FT_Bool loaded;
FT_Bool hooks_set; FT_Bool hooks_set;
SVG_RendererHooks hooks; /* Holds out hooks to the outside library */ SVG_RendererHooks hooks; /* Holds out hooks to the outside library */
} SVG_RendererRec; } SVG_RendererRec;
typedef struct SVG_RendererRec_* SVG_Renderer; typedef struct SVG_RendererRec_* SVG_Renderer;

View File

@ -2917,8 +2917,10 @@
FT_UShort advanceX; FT_UShort advanceX;
FT_UShort advanceY; FT_UShort advanceY;
FT_TRACE3(( "Attemping to load SVG glyph\n" )); FT_TRACE3(( "Attemping to load SVG glyph\n" ));
sfnt = (SFNT_Service)((TT_Face)glyph->face)->sfnt; sfnt = (SFNT_Service)((TT_Face)glyph->face)->sfnt;
error = sfnt->load_svg_doc( glyph, glyph_index ); error = sfnt->load_svg_doc( glyph, glyph_index );
if( error == FT_Err_Ok ) if( error == FT_Err_Ok )
{ {
@ -2940,6 +2942,7 @@
((float)glyph->face->units_per_EM) * 64.0; ((float)glyph->face->units_per_EM) * 64.0;
glyph->metrics.horiAdvance = advanceX; glyph->metrics.horiAdvance = advanceX;
glyph->metrics.vertAdvance = advanceY; glyph->metrics.vertAdvance = advanceY;
return error; return error;
} }
FT_TRACE3(( "Failed to load SVG glyph\n" )); FT_TRACE3(( "Failed to load SVG glyph\n" ));