[cairo-commit] 2 commits - src/cairo-ft-font.c
Behdad Esfahbod
behdad at kemper.freedesktop.org
Sun Aug 4 17:13:46 PDT 2013
src/cairo-ft-font.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
New commits:
commit 46d9db96d460fea72f0420102e8a90c6a7231f79
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Aug 4 20:08:46 2013 -0400
[ft] Ensure alignment of bitmaps received from FreeType
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 975f9d2..0dfe9be 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -1189,6 +1189,14 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
bitmap->pixel_mode == FT_PIXEL_MODE_GRAY)
{
stride = bitmap->pitch;
+
+ /* We don't support stride not multiple of 4. */
+ if (stride & 3)
+ {
+ assert (!own_buffer);
+ goto convert;
+ }
+
if (own_buffer) {
data = bitmap->buffer;
} else {
@@ -1224,6 +1232,7 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
#endif
case FT_PIXEL_MODE_GRAY2:
case FT_PIXEL_MODE_GRAY4:
+ convert:
if (!own_buffer && library)
{
/* This is pretty much the only case that we can get in here. */
commit 34a747e7bdeba1cfe17318f80fbe6720d47bc023
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Aug 4 19:59:06 2013 -0400
[ft] Fix alignment
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 0c9a6de..975f9d2 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -1232,10 +1232,9 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
FT_Bitmap tmp;
FT_Int align;
- if ( bitmap->pixel_mode == FT_PIXEL_MODE_GRAY2 )
- align = ( bitmap->width + 3 ) / 4;
- else
- align = ( bitmap->width + 1 ) / 2;
+ format = CAIRO_FORMAT_A8;
+
+ align = cairo_format_stride_for_width (format, bitmap->width);
FT_Bitmap_New( &tmp );
@@ -1263,8 +1262,6 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
}
memcpy (data, bitmap->buffer, stride * height);
-
- format = CAIRO_FORMAT_A8;
break;
}
/* These could be triggered by very rare types of TrueType fonts */
More information about the cairo-commit
mailing list