[cairo-commit] src/cairo-ft-font.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon Jul 29 16:20:49 PDT 2013


 src/cairo-ft-font.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

New commits:
commit 7d26341072b13a78d4b3fe58779057ac020be487
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Jul 29 19:20:33 2013 -0400

    [ft] Fix math

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;
 	      }
 	    }


More information about the cairo-commit mailing list