Commits

Alex Szpakowski committed 15ca8db

Cleaned up TrueType Rasterizer code

Comments (0)

Files changed (1)

src/modules/font/freetype/TrueTypeRasterizer.cpp

 namespace freetype
 {
 
-struct la
-{
-	unsigned char l,a;
-};
-
 TrueTypeRasterizer::TrueTypeRasterizer(FT_Library library, Data *data, int size)
 	: data(data)
 {
-	data->retain();
-
 	if (FT_New_Memory_Face(library,
 						  (const FT_Byte *)data->getData(),	/* first byte in memory */
 						  data->getSize(),					/* size in bytes        */
 	metrics.ascent = s.ascender >> 6;
 	metrics.descent = s.descender >> 6;
 	metrics.height = s.height >> 6;
+
+	data->retain();
 }
 
 TrueTypeRasterizer::~TrueTypeRasterizer()
 		throw love::Exception("TrueTypeFont Loading vm->error: FT_Get_Glyph failed\n");
 
 	FT_Glyph_To_Bitmap(&ftglyph, FT_RENDER_MODE_NORMAL, 0, 1);
-	FT_BitmapGlyph bitmap_glyph = (FT_BitmapGlyph)ftglyph;
+	FT_BitmapGlyph bitmap_glyph = (FT_BitmapGlyph) ftglyph;
 	FT_Bitmap &bitmap = bitmap_glyph->bitmap; //just to make things easier
 
 	// Get metrics
 
 	GlyphData *glyphData = new GlyphData(glyph, glyphMetrics, GlyphData::FORMAT_LUMINANCE_ALPHA);
 
+	int size = bitmap.rows * bitmap.width;
+	unsigned char *dst = (unsigned char *) glyphData->getData();
+
+	// Note that bitmap.buffer contains only luminosity. We copy that single value to
+	// our luminosity-alpha format.
+	for (int i = 0; i < size; i++)
 	{
-		int size = bitmap.rows*bitmap.width;
-		unsigned char *dst = (unsigned char *)glyphData->getData();
-
-		// Note that bitmap.buffer contains only luminosity. We copy that single value to
-		// our luminosity-alpha format.
-		for (int i = 0; i<size; i++)
-		{
-			dst[2*i] = 255;
-			dst[2*i+1] = bitmap.buffer[i];
-		}
+		dst[2*i] = 255;
+		dst[2*i+1] = bitmap.buffer[i];
 	}
 
 	// Having copied the data over, we can destroy the glyph
 
 int TrueTypeRasterizer::getNumGlyphs() const
 {
-	return 256;
+	return face->num_glyphs;
 }
 
 } // freetype