ref: ae7dc1f62d826083d418e86cce3f66a76dff038a
parent: c06b9cf56d0421275f3dd39488613026f23b79f2
author: Alexei Podtelezhnikov <[email protected]>
date: Thu Sep 28 18:59:31 EDT 2017
[smooth, raster] Miscellaneous cleanups. * src/raster/ftrend1.c (ft_raster1_render): Clean up the exit. * src/smooth/ftsmooth.c (ft_smooth_render_generic): Reduce translations and clean up the exit. (ft_smooth_render_lcd, ft_smooth_render_lcd): Remove unused `error'..
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-09-28 Alexei Podtelezhnikov <[email protected]>
+
+ [smooth, raster] Miscellaneous cleanups.
+
+ * src/raster/ftrend1.c (ft_raster1_render): Clean up the exit.
+ * src/smooth/ftsmooth.c (ft_smooth_render_generic): Reduce
+ translations and clean up the exit.
+ (ft_smooth_render_lcd, ft_smooth_render_lcd): Remove unused `error'.
+
2017-09-28 Ben Wagner <[email protected]>
[truetype] Really, really fix #52082.
--- a/src/raster/ftrend1.c
+++ b/src/raster/ftrend1.c
@@ -97,7 +97,7 @@
FT_Render_Mode mode,
const FT_Vector* origin )
{
- FT_Error error;
+ FT_Error error = FT_Err_Ok;
FT_Outline* outline = &slot->outline;
FT_Bitmap* bitmap = &slot->bitmap;
FT_Memory memory = render->root.memory;
@@ -152,27 +152,23 @@
/* set up parameters */
params.target = bitmap;
params.source = outline;
- params.flags = 0;
+ params.flags = FT_RASTER_FLAG_DEFAULT;
/* render outline into the bitmap */
error = render->raster_render( render->raster, ¶ms );
- if ( error )
- goto Exit;
- /* everything is fine; the glyph is now officially a bitmap */
- slot->format = FT_GLYPH_FORMAT_BITMAP;
-
- error = FT_Err_Ok;
-
Exit:
- if ( x_shift || y_shift )
- FT_Outline_Translate( outline, -x_shift, -y_shift );
- if ( slot->format != FT_GLYPH_FORMAT_BITMAP &&
- slot->internal->flags & FT_GLYPH_OWN_BITMAP )
+ if ( !error )
+ /* everything is fine; the glyph is now officially a bitmap */
+ slot->format = FT_GLYPH_FORMAT_BITMAP;
+ else if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
{
FT_FREE( bitmap->buffer );
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
+
+ if ( x_shift || y_shift )
+ FT_Outline_Translate( outline, -x_shift, -y_shift );
return error;
}
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -97,7 +97,7 @@
const FT_Vector* origin,
FT_Render_Mode required_mode )
{
- FT_Error error;
+ FT_Error error = FT_Err_Ok;
FT_Outline* outline = &slot->outline;
FT_Bitmap* bitmap = &slot->bitmap;
FT_Memory memory = render->root.memory;
@@ -240,7 +240,7 @@
/* by 1/3 pixel. */
width /= 3;
- FT_Outline_Translate( outline, 21, 0 );
+ bitmap->buffer += width;
error = render->raster_render( render->raster, ¶ms );
if ( error )
@@ -247,6 +247,7 @@
goto Exit;
FT_Outline_Translate( outline, -21, 0 );
+ x_shift -= 21;
bitmap->buffer += width;
error = render->raster_render( render->raster, ¶ms );
@@ -253,16 +254,14 @@
if ( error )
goto Exit;
- FT_Outline_Translate( outline, -21, 0 );
- bitmap->buffer += width;
+ FT_Outline_Translate( outline, 42, 0 );
+ x_shift += 42;
+ bitmap->buffer -= 2 * width;
error = render->raster_render( render->raster, ¶ms );
if ( error )
goto Exit;
- FT_Outline_Translate( outline, 21, 0 );
- bitmap->buffer -= 2 * width;
-
/* XXX: Rearrange the bytes according to FT_PIXEL_MODE_LCD. */
/* XXX: It is more efficient to render every third byte above. */
@@ -293,56 +292,49 @@
bitmap->pitch *= 3;
bitmap->rows /= 3;
- FT_Outline_Translate( outline, 0, 21 );
- bitmap->buffer += 2 * pitch;
+ bitmap->buffer += pitch;
error = render->raster_render( render->raster, ¶ms );
if ( error )
goto Exit;
- FT_Outline_Translate( outline, 0, -21 );
- bitmap->buffer -= pitch;
+ FT_Outline_Translate( outline, 0, 21 );
+ y_shift += 21;
+ bitmap->buffer += pitch;
error = render->raster_render( render->raster, ¶ms );
if ( error )
goto Exit;
- FT_Outline_Translate( outline, 0, -21 );
- bitmap->buffer -= pitch;
+ FT_Outline_Translate( outline, 0, -42 );
+ y_shift -= 42;
+ bitmap->buffer -= 2 * pitch;
error = render->raster_render( render->raster, ¶ms );
if ( error )
goto Exit;
- FT_Outline_Translate( outline, 0, 21 );
-
bitmap->pitch /= 3;
bitmap->rows *= 3;
}
else /* grayscale */
- {
error = render->raster_render( render->raster, ¶ms );
- if ( error )
- goto Exit;
- }
#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
- /* everything is fine; the glyph is now officially a bitmap */
- slot->format = FT_GLYPH_FORMAT_BITMAP;
-
- error = FT_Err_Ok;
-
Exit:
- if ( x_shift || y_shift )
- FT_Outline_Translate( outline, -x_shift, -y_shift );
- if ( slot->format != FT_GLYPH_FORMAT_BITMAP &&
- slot->internal->flags & FT_GLYPH_OWN_BITMAP )
+ if ( !error )
+ /* everything is fine; the glyph is now officially a bitmap */
+ slot->format = FT_GLYPH_FORMAT_BITMAP;
+ else if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
{
FT_FREE( bitmap->buffer );
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
+ if ( x_shift || y_shift )
+ FT_Outline_Translate( outline, -x_shift, -y_shift );
+
return error;
}
@@ -369,8 +361,6 @@
FT_Render_Mode mode,
const FT_Vector* origin )
{
- FT_Error error;
-
return ft_smooth_render_generic( render, slot, mode, origin,
FT_RENDER_MODE_LCD );
}
@@ -383,8 +373,6 @@
FT_Render_Mode mode,
const FT_Vector* origin )
{
- FT_Error error;
-
return ft_smooth_render_generic( render, slot, mode, origin,
FT_RENDER_MODE_LCD_V );
}