From 191af5cd5be84b86fd0f46e9bfaba14000c1446f Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Wed, 23 Jan 2013 06:26:17 -0400 Subject: [PATCH] Minor cosmetics --- src/modules/font/ImageRasterizer.cpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/modules/font/ImageRasterizer.cpp b/src/modules/font/ImageRasterizer.cpp index 1de515bc7..d56d70a7e 100644 --- a/src/modules/font/ImageRasterizer.cpp +++ b/src/modules/font/ImageRasterizer.cpp @@ -67,32 +67,27 @@ GlyphData *ImageRasterizer::getGlyphData(unsigned int glyph) const } gm.height = metrics.height; - + GlyphData *g = new GlyphData(glyph, gm, GlyphData::FORMAT_RGBA); - + if (gm.width == 0) return g; - - unsigned char *gd = (unsigned char *) g->getData(); - love::image::pixel *pixels = (love::image::pixel *) imageData->getData(); + + love::image::pixel *gdpixels = (love::image::pixel *) g->getData(); + love::image::pixel *imagepixels = (love::image::pixel *) imageData->getData(); // copy glyph pixels from imagedata to glyphdata - for (unsigned int i = 0; i < gm.width * (unsigned int) getHeight(); i++) + for (int i = 0; i < g->getWidth() * g->getHeight(); i++) { - love::image::pixel p = pixels[ it->second.x + (i % gm.width) + (imageData->getWidth() * (i / gm.width)) ]; + love::image::pixel p = imagepixels[ it->second.x + (i % gm.width) + (imageData->getWidth() * (i / gm.width)) ]; - // Replace spacer color with an empty pixel + // Use transparency instead of the spacer color if (equal(p, spacer)) - gd[i*4+0] = gd[i*4+1] = gd[i*4+2] = gd[i*4+3] = 0; + gdpixels[i].r = gdpixels[i].g = gdpixels[i].b = gdpixels[i].a = 0; else - { - gd[i*4+0] = p.r; - gd[i*4+1] = p.g; - gd[i*4+2] = p.b; - gd[i*4+3] = p.a; - } + gdpixels[i] = p; } - + return g; }