diff options
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/ftglyph.c | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c index fa60ea1e7..17fe8b810 100644 --- a/src/base/ftglyph.c +++ b/src/base/ftglyph.c @@ -326,6 +326,8 @@ glyph->units_per_EM = document->units_per_EM; glyph->start_glyph_id = document->start_glyph_id; glyph->end_glyph_id = document->end_glyph_id; + glyph->transform = document->transform; + glyph->delta = document->delta; /* copy the document into glyph */ FT_MEM_COPY( glyph->svg_document, document->svg_document, doc_length ); @@ -372,6 +374,8 @@ target->units_per_EM = source->units_per_EM; target->start_glyph_id = source->start_glyph_id; target->end_glyph_id = source->end_glyph_id; + target->transform = source->transform; + target->delta = source->delta; /* allocate space for the svg document */ target->svg_document = memory->alloc( memory, @@ -385,6 +389,55 @@ return error; } + FT_CALLBACK_DEF( void ) + ft_svg_glyph_transform( FT_Glyph svg_glyph, + const FT_Matrix* _matrix, + const FT_Vector* _delta ) + { + FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph; + + FT_Matrix* matrix = _matrix; + FT_Vector* delta = _delta; + + FT_Matrix tmp_matrix; + FT_Vector tmp_delta; + FT_Matrix a, b; + FT_Pos x, y; + + if ( !matrix ) + { + tmp_matrix.xx = 0x10000; + tmp_matrix.xy = 0; + tmp_matrix.yx = 0; + tmp_matrix.yy = 0x10000; + matrix = &tmp_matrix; + } + + if ( !delta ) + { + tmp_delta.x = 0; + tmp_delta.y = 0; + delta = &tmp_delta; + } + + a = glyph->transform; + b = *matrix; + FT_Matrix_Multiply( &b, &a ); + + x = ADD_LONG(ADD_LONG( + FT_MulFix(matrix->xx, glyph->delta.x), + FT_MulFix(matrix->xy, glyph->delta.y)), + delta->x); + y = ADD_LONG(ADD_LONG( + FT_MulFix(matrix->yx, glyph->delta.x), + FT_MulFix(matrix->yy, glyph->delta.y)), + delta->y); + glyph->delta.x = x; + glyph->delta.y = y; + + glyph->transform = a; + } + FT_CALLBACK_DEF( FT_Error ) ft_svg_glyph_prepare( FT_Glyph svg_glyph, FT_GlyphSlot slot ) @@ -404,6 +457,8 @@ document->units_per_EM = glyph->units_per_EM; document->start_glyph_id = glyph->start_glyph_id; document->end_glyph_id = glyph->end_glyph_id; + document->transform = glyph->transform; + document->delta = glyph->delta; slot->format = FT_GLYPH_FORMAT_SVG; slot->glyph_index = glyph->glyph_index; @@ -421,7 +476,7 @@ ft_svg_glyph_init, /* FT_Glyph_InitFunc glyph_init */ ft_svg_glyph_done, /* FT_Glyph_DoneFunc glyph_done */ ft_svg_glyph_copy, /* FT_Glyph_CopyFunc glyph_copy */ - NULL, /* FT_Glyph_TransformFunc glyph_transform */ + ft_svg_glyph_transform, /* FT_Glyph_TransformFunc glyph_transform */ NULL, /* FT_Glyph_GetBBoxFunc glyph_bbox */ ft_svg_glyph_prepare /* FT_Glyph_PrepareFunc glyph_prepare */ ) |