[cairo-commit] src/cairo-ft-font.c
Behdad Esfahbod
behdad at kemper.freedesktop.org
Wed Aug 9 05:06:30 UTC 2017
src/cairo-ft-font.c | 9 +++++++++
1 file changed, 9 insertions(+)
New commits:
commit f3515954e0bc9c9ca413a84a8dd842145cec83a7
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Aug 8 22:04:55 2017 -0700
[ft] Fix color font loading on big-endian systems
Untested, but the logic is correct: FreeType's BGRA type is always
laid out in that order in memory. Cairo's ARGB32 is endianness-
dependent. On little-endian systems the two are the same. On big-endian
we need to flip.
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index e1070f4c..3b308757 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -1255,6 +1255,15 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
memcpy (data, bitmap->buffer, stride * height);
}
+
+ if (!_cairo_is_little_endian ())
+ {
+ /* Byteswap. */
+ unsigned int i, count = height * width;
+ uint32_t *p = (uint32_t *) data;
+ for (i = 0; i < count; i++)
+ p[i] = be32_to_cpu (p[i]);
+ }
format = CAIRO_FORMAT_ARGB32;
break;
#endif
More information about the cairo-commit
mailing list