[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'..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
diff --git a/ChangeLog b/ChangeLog
index 19f54a9..dba8499 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-09-28 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [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 <bungeman@google.com>
[truetype] Really, really fix #52082.
diff --git a/src/raster/ftrend1.c b/src/raster/ftrend1.c
index a5b8153..bbce7bb 100644
--- 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,28 +152,24 @@
/* 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;
}
diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c
index 50ce44b..7946f28 100644
--- 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,29 +240,28 @@
/* by 1/3 pixel. */
width /= 3;
- FT_Outline_Translate( outline, 21, 0 );
+ bitmap->buffer += width;
error = render->raster_render( render->raster, ¶ms );
if ( error )
goto Exit;
FT_Outline_Translate( outline, -21, 0 );
+ x_shift -= 21;
bitmap->buffer += width;
error = render->raster_render( render->raster, ¶ms );
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 );
}