summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2013-07-29 23:20:33 (GMT)
committerBehdad Esfahbod <behdad@behdad.org>2013-07-29 23:20:33 (GMT)
commit7d26341072b13a78d4b3fe58779057ac020be487 (patch)
treedb688c660d1e40cc3293830ed5ea6709235e3069
parent9444ef09ccde2735258cc1bd2f1912119a32dd88 (diff)
downloadcairo-7d26341072b13a78d4b3fe58779057ac020be487.tar.gz
cairo-7d26341072b13a78d4b3fe58779057ac020be487.tar.xz
[ft] Fix math
-rw-r--r--src/cairo-ft-font.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index feef95b..89d08e9 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -1252,16 +1252,11 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
if (bitmap->num_grays != 256)
{
unsigned int x, y;
- unsigned int shift;
- switch (bitmap->num_grays) {
- case 4: shift = 6; break;
- case 16: shift = 4; break;
- default: shift = 0; break;
- }
+ unsigned int mul = 255 / (bitmap->num_grays - 1);
FT_Byte *p = bitmap->buffer;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
- p[x] <<= shift;
+ p[x] *= mul;
p += bitmap->pitch;
}
}