[Scummvm-cvs-logs] SF.net SVN: scummvm:[44470] tools/trunk/create_sjisfnt.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue Sep 29 22:33:22 CEST 2009


Revision: 44470
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44470&view=rev
Author:   lordhoto
Date:     2009-09-29 20:33:21 +0000 (Tue, 29 Sep 2009)

Log Message:
-----------
Cleanup.

Modified Paths:
--------------
    tools/trunk/create_sjisfnt.cpp

Modified: tools/trunk/create_sjisfnt.cpp
===================================================================
--- tools/trunk/create_sjisfnt.cpp	2009-09-29 19:51:37 UTC (rev 44469)
+++ tools/trunk/create_sjisfnt.cpp	2009-09-29 20:33:21 UTC (rev 44470)
@@ -56,8 +56,10 @@
 	uint8 *plainData;
 };
 
-bool drawGlyph16x16(uint32 unicode, Glyph &glyph);
+bool setGlyphSize(int width, int height);
 
+bool drawGlyph(uint32 unicode, Glyph &glyph);
+
 } // end of anonymous namespace
 
 int main(int argc, char *argv[]) {
@@ -78,18 +80,22 @@
 		return -1;
 	}
 
-	atexit(deinitSJIStoUTF32Conversion);
+	std::atexit(deinitSJIStoUTF32Conversion);
 
 	if (!initFreeType(font)) {
 		error("Could not initialize FreeType library.");
 		return -1;
 	}
 
-	atexit(deinitFreeType);
+	std::atexit(deinitFreeType);
 
 	std::vector<Glyph> glyphs;
 	int chars = 0;
 
+	// The two byte SJIS chars will be rendered as 16x16
+	if (!setGlyphSize(16, 16))
+		return -1;
+
 	for (uint8 fB = 0x81; fB <= 0xEF; ++fB) {
 		if (fB >= 0xA0 && fB <= 0xDF)
 			continue;
@@ -115,7 +121,7 @@
 			Glyph data;
 			data.fB = fB;
 			data.sB = sB;
-			if (!drawGlyph16x16(utf32, data)) {
+			if (!drawGlyph(utf32, data)) {
 				warning("Could not render glyph: %.2X %.2X", fB, sB);
 				continue;
 			}
@@ -309,11 +315,8 @@
 		return false;
 	}
 
-	err = FT_Set_Pixel_Sizes(sjisFont, 16, 16);
-	if (err) {
-		warning("Could not initialize font for 16x16 outout.");
+	if (!setGlyphSize(16, 16))
 		return false;
-	}
 
 	err = FT_Select_Charmap(sjisFont, FT_ENCODING_UNICODE);
 	if (err) {
@@ -329,7 +332,17 @@
 	FT_Done_FreeType(ft);
 }
 
-bool drawGlyph16x16(uint32 unicode, Glyph &glyph) {
+bool setGlyphSize(int width, int height) {
+	FT_Error err = FT_Set_Pixel_Sizes(sjisFont, width, height);
+	if (err) {
+		warning("Could not initialize font for %dx%d outout.", width, height);
+		return false;
+	}
+
+	return true;
+}
+
+bool drawGlyph(uint32 unicode, Glyph &glyph) {
 	uint32 index = FT_Get_Char_Index(sjisFont, unicode);
 	if (!index)
 		return false;
@@ -352,7 +365,7 @@
 	glyph.plainData = 0;
 
 	if (glyph.height) {
-		glyph.plainData = new uint8[glyph.height * abs(glyph.pitch)];
+		glyph.plainData = new uint8[glyph.height * std::abs(glyph.pitch)];
 		if (!glyph.plainData)
 			return false;
 
@@ -369,7 +382,7 @@
 		}
 	}
 
-	glyph.pitch = abs(glyph.pitch);
+	glyph.pitch = std::abs(glyph.pitch);
 
 	return true;
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list