From: Byeongsik Jeon <bsjeon(a)hanmail.net>
Signed-off-by: Byeongsik Jeon <bsjeon(a)hanmail.net>
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/gdi32/freetype.c | 52 ++++++++++++++++++++-----------------------
1 file changed, 24 insertions(+), 28 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 0f14072037c..b602323168c 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -2639,8 +2639,8 @@ enum matrices_index
matrix_unrotated
};
-static BOOL get_transform_matrices( struct gdi_font *font, BOOL vertical, const MAT2 *user_transform,
- FT_Matrix matrices[3] )
+static FT_Matrix *get_transform_matrices( struct gdi_font *font, BOOL vertical, const MAT2 *user_transform,
+ FT_Matrix matrices[3] )
{
static const FT_Matrix identity_mat = { (1 << 16), 0, 0, (1 << 16) };
BOOL needs_transform = FALSE;
@@ -2739,7 +2739,7 @@ static BOOL get_transform_matrices( struct gdi_font *font, BOOL vertical, const
needs_transform = TRUE;
}
- return needs_transform;
+ return needs_transform ? matrices : NULL;
}
static BOOL get_bold_glyph_outline(FT_GlyphSlot glyph, LONG ppem, FT_Glyph_Metrics *metrics)
@@ -2836,12 +2836,11 @@ static FT_Vector get_advance_metric( struct gdi_font *font, FT_Pos base_advance,
return adv;
}
-static FT_BBox get_transformed_bbox( const FT_Glyph_Metrics *metrics,
- BOOL needs_transform, const FT_Matrix metrices[3] )
+static FT_BBox get_transformed_bbox( const FT_Glyph_Metrics *metrics, const FT_Matrix *matrices )
{
FT_BBox bbox = { 0, 0, 0, 0 };
- if (!needs_transform)
+ if (!matrices)
{
bbox.xMin = (metrics->horiBearingX) & -64;
bbox.xMax = (metrics->horiBearingX + metrics->width + 63) & -64;
@@ -2860,7 +2859,7 @@ static FT_BBox get_transformed_bbox( const FT_Glyph_Metrics *metrics,
vec.x = metrics->horiBearingX + xc * metrics->width;
vec.y = metrics->horiBearingY - yc * metrics->height;
TRACE( "Vec %ld, %ld\n", vec.x, vec.y );
- pFT_Vector_Transform( &vec, &metrices[matrix_vert] );
+ pFT_Vector_Transform( &vec, &matrices[matrix_vert] );
if (xc == 0 && yc == 0)
{
bbox.xMin = bbox.xMax = vec.x;
@@ -2886,14 +2885,13 @@ static FT_BBox get_transformed_bbox( const FT_Glyph_Metrics *metrics,
}
static void compute_metrics( struct gdi_font *font, FT_BBox bbox, const FT_Glyph_Metrics *metrics,
- BOOL vertical, BOOL vertical_metrics,
- BOOL needs_transform, const FT_Matrix matrices[3],
+ BOOL vertical, BOOL vertical_metrics, const FT_Matrix *matrices,
GLYPHMETRICS *gm, ABC *abc )
{
FT_Vector adv, vec, origin;
FT_Fixed base_advance = vertical_metrics ? metrics->vertAdvance : metrics->horiAdvance;
- if (!needs_transform)
+ if (!matrices)
{
adv = get_advance_metric( font, base_advance, NULL );
gm->gmCellIncX = adv.x >> 6;
@@ -2967,7 +2965,7 @@ static void compute_metrics( struct gdi_font *font, FT_BBox bbox, const FT_Glyph
static const BYTE masks[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
static DWORD get_mono_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox,
- BOOL fake_bold, BOOL needs_transform, FT_Matrix matrices[3],
+ BOOL fake_bold, const FT_Matrix *matrices,
DWORD buflen, BYTE *buf )
{
DWORD width = (bbox.xMax - bbox.xMin ) >> 6;
@@ -3015,7 +3013,7 @@ static DWORD get_mono_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox,
ft_bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
ft_bitmap.buffer = buf;
- if (needs_transform)
+ if (matrices)
pFT_Outline_Transform( &glyph->outline, &matrices[matrix_vert] );
pFT_Outline_Translate( &glyph->outline, -bbox.xMin, -bbox.yMin );
@@ -3033,7 +3031,7 @@ static DWORD get_mono_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox,
}
static DWORD get_antialias_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox, UINT format,
- BOOL fake_bold, BOOL needs_transform, FT_Matrix matrices[3],
+ BOOL fake_bold, const FT_Matrix *matrices,
DWORD buflen, BYTE *buf )
{
DWORD width = (bbox.xMax - bbox.xMin ) >> 6;
@@ -3081,7 +3079,7 @@ static DWORD get_antialias_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox, UINT
ft_bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
ft_bitmap.buffer = buf;
- if (needs_transform)
+ if (matrices)
pFT_Outline_Transform( &glyph->outline, &matrices[matrix_vert] );
pFT_Outline_Translate( &glyph->outline, -bbox.xMin, -bbox.yMin );
@@ -3111,7 +3109,7 @@ static DWORD get_antialias_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox, UINT
}
static DWORD get_subpixel_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox, UINT format,
- BOOL fake_bold, BOOL needs_transform, FT_Matrix matrices[3],
+ BOOL fake_bold, const FT_Matrix *matrices,
GLYPHMETRICS *gm, DWORD buflen, BYTE *buf )
{
DWORD width = (bbox.xMax - bbox.xMin ) >> 6;
@@ -3189,7 +3187,7 @@ static DWORD get_subpixel_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox, UINT f
if (!buf || !buflen) return needed;
if (needed > buflen) return GDI_ERROR;
- if (needs_transform)
+ if (matrices)
pFT_Outline_Transform( &glyph->outline, &matrices[matrix_vert] );
#ifdef FT_LCD_FILTER_H
@@ -3500,8 +3498,7 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph
FT_Error err;
FT_BBox bbox;
FT_Int load_flags = get_load_flags(format);
- FT_Matrix matrices[3];
- BOOL needsTransform = FALSE;
+ FT_Matrix transform_matrices[3], *matrices = NULL;
BOOL vertical_metrics;
TRACE("%p, %04x, %08x, %p, %08x, %p, %p\n", font, glyph, format, lpgm, buflen, buf, lpmat);
@@ -3512,7 +3509,7 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph
format &= ~GGO_UNHINTED;
- needsTransform = get_transform_matrices( font, tategaki, lpmat, matrices );
+ matrices = get_transform_matrices( font, tategaki, lpmat, transform_matrices );
vertical_metrics = (tategaki && FT_HAS_VERTICAL(ft_face));
/* there is a freetype bug where vertical metrics are only
@@ -3520,7 +3517,7 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph
if (vertical_metrics && FT_SimpleVersion < FT_VERSION_VALUE(2, 4, 0))
vertical_metrics = FALSE;
- if (needsTransform || format != GGO_BITMAP) load_flags |= FT_LOAD_NO_BITMAP;
+ if (matrices || format != GGO_BITMAP) load_flags |= FT_LOAD_NO_BITMAP;
if (vertical_metrics) load_flags |= FT_LOAD_VERTICAL_LAYOUT;
err = pFT_Load_Glyph(ft_face, glyph, load_flags);
@@ -3557,9 +3554,8 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph
/* metrics.width = min( metrics.width, ptm->tmMaxCharWidth << 6 ); */
}
- bbox = get_transformed_bbox( &metrics, needsTransform, matrices );
- compute_metrics( font, bbox, &metrics, tategaki, vertical_metrics, needsTransform, matrices,
- lpgm, abc );
+ bbox = get_transformed_bbox( &metrics, matrices );
+ compute_metrics( font, bbox, &metrics, tategaki, vertical_metrics, matrices, lpgm, abc );
switch (format)
{
@@ -3568,21 +3564,21 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph
case GGO_BITMAP:
return get_mono_glyph_bitmap( ft_face->glyph, bbox, font->fake_bold,
- needsTransform, matrices, buflen, buf );
+ matrices, buflen, buf );
case GGO_GRAY2_BITMAP:
case GGO_GRAY4_BITMAP:
case GGO_GRAY8_BITMAP:
case WINE_GGO_GRAY16_BITMAP:
return get_antialias_glyph_bitmap( ft_face->glyph, bbox, format, font->fake_bold,
- needsTransform, matrices, buflen, buf );
+ matrices, buflen, buf );
case WINE_GGO_HRGB_BITMAP:
case WINE_GGO_HBGR_BITMAP:
case WINE_GGO_VRGB_BITMAP:
case WINE_GGO_VBGR_BITMAP:
return get_subpixel_glyph_bitmap( ft_face->glyph, bbox, format, font->fake_bold,
- needsTransform, matrices, lpgm, buflen, buf );
+ matrices, lpgm, buflen, buf );
case GGO_NATIVE:
if (ft_face->glyph->format == ft_glyph_format_outline)
@@ -3592,7 +3588,7 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph
if (buflen == 0) buf = NULL;
- if (needsTransform && buf)
+ if (matrices && buf)
pFT_Outline_Transform( outline, &matrices[matrix_vert] );
needed = get_native_glyph_outline(outline, buflen, NULL);
@@ -3612,7 +3608,7 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph
if (buflen == 0) buf = NULL;
- if (needsTransform && buf)
+ if (matrices && buf)
pFT_Outline_Transform( outline, &matrices[matrix_vert] );
needed = get_bezier_glyph_outline(outline, buflen, NULL);
--
2.23.0