Browse Source

Font can now be omitted from setFont/newFont to use the default font.

rude 15 years ago
parent
commit
05439961d2

+ 4 - 4
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -195,7 +195,7 @@ namespace opengl
 		return 1;
 	}
 
-	int w_newFont(lua_State * L)
+	int w_newFont1(lua_State * L)
 	{
 		Data * d = 0;
 
@@ -320,7 +320,7 @@ namespace opengl
 		return 4;
 	}
 
-	int w_setFont(lua_State * L)
+	int w_setFont1(lua_State * L)
 	{
 		// The second parameter is an optional int.
 		int size = luaL_optint(L, 2, 12);
@@ -787,7 +787,7 @@ namespace opengl
 		{ "newImage", w_newImage },
 		{ "newGlyph", w_newGlyph },
 		{ "newQuad", w_newQuad },
-		{ "newFont", w_newFont },
+		{ "newFont1", w_newFont1 },
 		{ "newImageFont", w_newImageFont },
 		{ "newSpriteBatch", w_newSpriteBatch },
 		{ "newParticleSystem", w_newParticleSystem },
@@ -797,7 +797,7 @@ namespace opengl
 		{ "setBackgroundColor", w_setBackgroundColor },
 		{ "getBackgroundColor", w_getBackgroundColor },
 
-		{ "setFont", w_setFont },
+		{ "setFont1", w_setFont1 },
 		{ "getFont", w_getFont },
 
 		{ "setBlendMode", w_setBlendMode },

+ 2 - 2
src/modules/graphics/opengl/wrap_Graphics.h

@@ -52,7 +52,7 @@ namespace opengl
 	int w_newImage(lua_State * L);
 	int w_newGlyph(lua_State * L);
 	int w_newFrame(lua_State * L);
-	int w_newFont(lua_State * L);
+	int w_newFont1(lua_State * L);
 	int w_newImageFont(lua_State * L);
 	int w_newSpriteBatch(lua_State * L);
 	int w_newParticleSystem(lua_State * L);
@@ -60,7 +60,7 @@ namespace opengl
 	int w_getColor(lua_State * L);
 	int w_setBackgroundColor(lua_State * L);
 	int w_getBackgroundColor(lua_State * L);
-	int w_setFont(lua_State * L);
+	int w_setFont1(lua_State * L);
 	int w_getFont(lua_State * L);
 	int w_setBlendMode(lua_State * L);
 	int w_setColorMode(lua_State * L);

+ 16 - 0
src/scripts/graphics.lua

@@ -18,6 +18,22 @@ freely, subject to the following restrictions:
 3. This notice may not be removed or altered from any source distribution.
 --]]
 
+function love.graphics.newFont(font, size)
+	if type(font) == "number" then
+		size = font
+		font = love._vera_ttf
+	end
+	return love.graphics.newFont1(font, size)
+end
+
+love.graphics.setFont = function(font, size)
+	if type(font) == "number" then
+		size = font
+		font = love._vera_ttf
+	end
+	return love.graphics.setFont1(font, size)
+end
+
 love.graphics.print = function (...)
 	if not love.graphics.getFont() then 
 		love.graphics.setFont(love._vera_ttf, 12)

+ 51 - 27
src/scripts/graphics.lua.h

@@ -83,35 +83,59 @@ const char graphics_lua[] =
 	0x65,0x6D,0x6F,0x76,0x65,0x64,0x20,0x6F,0x72,0x20,0x61,0x6C,0x74,0x65,0x72,
 	0x65,0x64,0x20,0x66,0x72,0x6F,0x6D,0x20,0x61,0x6E,0x79,0x20,0x73,0x6F,0x75,
 	0x72,0x63,0x65,0x20,0x64,0x69,0x73,0x74,0x72,0x69,0x62,0x75,0x74,0x69,0x6F,
-	0x6E,0x2E,0x0D,0x0A,0x2D,0x2D,0x5D,0x5D,0x0D,0x0A,0x0D,0x0A,0x6C,0x6F,0x76,
-	0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,0x70,0x72,0x69,0x6E,
-	0x74,0x20,0x3D,0x20,0x66,0x75,0x6E,0x63,0x74,0x69,0x6F,0x6E,0x20,0x28,0x2E,
-	0x2E,0x2E,0x29,0x0D,0x0A,0x09,0x69,0x66,0x20,0x6E,0x6F,0x74,0x20,0x6C,0x6F,
-	0x76,0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,0x67,0x65,0x74,
-	0x46,0x6F,0x6E,0x74,0x28,0x29,0x20,0x74,0x68,0x65,0x6E,0x20,0x0D,0x0A,0x09,
-	0x09,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,
-	0x73,0x65,0x74,0x46,0x6F,0x6E,0x74,0x28,0x6C,0x6F,0x76,0x65,0x2E,0x5F,0x76,
-	0x65,0x72,0x61,0x5F,0x74,0x74,0x66,0x2C,0x20,0x31,0x32,0x29,0x0D,0x0A,0x09,
-	0x65,0x6E,0x64,0x0D,0x0A,0x09,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,
-	0x68,0x69,0x63,0x73,0x2E,0x70,0x72,0x69,0x6E,0x74,0x31,0x28,0x2E,0x2E,0x2E,
-	0x29,0x0D,0x0A,0x09,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,
-	0x63,0x73,0x2E,0x70,0x72,0x69,0x6E,0x74,0x20,0x3D,0x20,0x6C,0x6F,0x76,0x65,
+	0x6E,0x2E,0x0D,0x0A,0x2D,0x2D,0x5D,0x5D,0x0D,0x0A,0x0D,0x0A,0x66,0x75,0x6E,
+	0x63,0x74,0x69,0x6F,0x6E,0x20,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,
+	0x68,0x69,0x63,0x73,0x2E,0x6E,0x65,0x77,0x46,0x6F,0x6E,0x74,0x28,0x66,0x6F,
+	0x6E,0x74,0x2C,0x20,0x73,0x69,0x7A,0x65,0x29,0x0D,0x0A,0x09,0x69,0x66,0x20,
+	0x74,0x79,0x70,0x65,0x28,0x66,0x6F,0x6E,0x74,0x29,0x20,0x3D,0x3D,0x20,0x22,
+	0x6E,0x75,0x6D,0x62,0x65,0x72,0x22,0x20,0x74,0x68,0x65,0x6E,0x0D,0x0A,0x09,
+	0x09,0x73,0x69,0x7A,0x65,0x20,0x3D,0x20,0x66,0x6F,0x6E,0x74,0x0D,0x0A,0x09,
+	0x09,0x66,0x6F,0x6E,0x74,0x20,0x3D,0x20,0x6C,0x6F,0x76,0x65,0x2E,0x5F,0x76,
+	0x65,0x72,0x61,0x5F,0x74,0x74,0x66,0x0D,0x0A,0x09,0x65,0x6E,0x64,0x0D,0x0A,
+	0x09,0x72,0x65,0x74,0x75,0x72,0x6E,0x20,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,
+	0x61,0x70,0x68,0x69,0x63,0x73,0x2E,0x6E,0x65,0x77,0x46,0x6F,0x6E,0x74,0x31,
+	0x28,0x66,0x6F,0x6E,0x74,0x2C,0x20,0x73,0x69,0x7A,0x65,0x29,0x0D,0x0A,0x65,
+	0x6E,0x64,0x0D,0x0A,0x0D,0x0A,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,
+	0x68,0x69,0x63,0x73,0x2E,0x73,0x65,0x74,0x46,0x6F,0x6E,0x74,0x20,0x3D,0x20,
+	0x66,0x75,0x6E,0x63,0x74,0x69,0x6F,0x6E,0x28,0x66,0x6F,0x6E,0x74,0x2C,0x20,
+	0x73,0x69,0x7A,0x65,0x29,0x0D,0x0A,0x09,0x69,0x66,0x20,0x74,0x79,0x70,0x65,
+	0x28,0x66,0x6F,0x6E,0x74,0x29,0x20,0x3D,0x3D,0x20,0x22,0x6E,0x75,0x6D,0x62,
+	0x65,0x72,0x22,0x20,0x74,0x68,0x65,0x6E,0x0D,0x0A,0x09,0x09,0x73,0x69,0x7A,
+	0x65,0x20,0x3D,0x20,0x66,0x6F,0x6E,0x74,0x0D,0x0A,0x09,0x09,0x66,0x6F,0x6E,
+	0x74,0x20,0x3D,0x20,0x6C,0x6F,0x76,0x65,0x2E,0x5F,0x76,0x65,0x72,0x61,0x5F,
+	0x74,0x74,0x66,0x0D,0x0A,0x09,0x65,0x6E,0x64,0x0D,0x0A,0x09,0x72,0x65,0x74,
+	0x75,0x72,0x6E,0x20,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,
+	0x63,0x73,0x2E,0x73,0x65,0x74,0x46,0x6F,0x6E,0x74,0x31,0x28,0x66,0x6F,0x6E,
+	0x74,0x2C,0x20,0x73,0x69,0x7A,0x65,0x29,0x0D,0x0A,0x65,0x6E,0x64,0x0D,0x0A,
+	0x0D,0x0A,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,
+	0x2E,0x70,0x72,0x69,0x6E,0x74,0x20,0x3D,0x20,0x66,0x75,0x6E,0x63,0x74,0x69,
+	0x6F,0x6E,0x20,0x28,0x2E,0x2E,0x2E,0x29,0x0D,0x0A,0x09,0x69,0x66,0x20,0x6E,
+	0x6F,0x74,0x20,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,0x63,
+	0x73,0x2E,0x67,0x65,0x74,0x46,0x6F,0x6E,0x74,0x28,0x29,0x20,0x74,0x68,0x65,
+	0x6E,0x20,0x0D,0x0A,0x09,0x09,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,
+	0x68,0x69,0x63,0x73,0x2E,0x73,0x65,0x74,0x46,0x6F,0x6E,0x74,0x28,0x6C,0x6F,
+	0x76,0x65,0x2E,0x5F,0x76,0x65,0x72,0x61,0x5F,0x74,0x74,0x66,0x2C,0x20,0x31,
+	0x32,0x29,0x0D,0x0A,0x09,0x65,0x6E,0x64,0x0D,0x0A,0x09,0x6C,0x6F,0x76,0x65,
 	0x2E,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,0x70,0x72,0x69,0x6E,0x74,
-	0x31,0x0D,0x0A,0x65,0x6E,0x64,0x0D,0x0A,0x0D,0x0A,0x6C,0x6F,0x76,0x65,0x2E,
+	0x31,0x28,0x2E,0x2E,0x2E,0x29,0x0D,0x0A,0x09,0x6C,0x6F,0x76,0x65,0x2E,0x67,
+	0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,0x70,0x72,0x69,0x6E,0x74,0x20,0x3D,
+	0x20,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,
+	0x70,0x72,0x69,0x6E,0x74,0x31,0x0D,0x0A,0x65,0x6E,0x64,0x0D,0x0A,0x0D,0x0A,
+	0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,0x70,
+	0x72,0x69,0x6E,0x74,0x66,0x20,0x3D,0x20,0x66,0x75,0x6E,0x63,0x74,0x69,0x6F,
+	0x6E,0x20,0x28,0x2E,0x2E,0x2E,0x29,0x0D,0x0A,0x09,0x69,0x66,0x20,0x6E,0x6F,
+	0x74,0x20,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,
+	0x2E,0x67,0x65,0x74,0x46,0x6F,0x6E,0x74,0x28,0x29,0x20,0x74,0x68,0x65,0x6E,
+	0x20,0x0D,0x0A,0x09,0x09,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,0x68,
+	0x69,0x63,0x73,0x2E,0x73,0x65,0x74,0x46,0x6F,0x6E,0x74,0x28,0x6C,0x6F,0x76,
+	0x65,0x2E,0x5F,0x76,0x65,0x72,0x61,0x5F,0x74,0x74,0x66,0x2C,0x20,0x31,0x32,
+	0x29,0x0D,0x0A,0x09,0x65,0x6E,0x64,0x0D,0x0A,0x09,0x6C,0x6F,0x76,0x65,0x2E,
 	0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,0x70,0x72,0x69,0x6E,0x74,0x66,
-	0x20,0x3D,0x20,0x66,0x75,0x6E,0x63,0x74,0x69,0x6F,0x6E,0x20,0x28,0x2E,0x2E,
-	0x2E,0x29,0x0D,0x0A,0x09,0x69,0x66,0x20,0x6E,0x6F,0x74,0x20,0x6C,0x6F,0x76,
-	0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,0x67,0x65,0x74,0x46,
-	0x6F,0x6E,0x74,0x28,0x29,0x20,0x74,0x68,0x65,0x6E,0x20,0x0D,0x0A,0x09,0x09,
-	0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,0x73,
-	0x65,0x74,0x46,0x6F,0x6E,0x74,0x28,0x6C,0x6F,0x76,0x65,0x2E,0x5F,0x76,0x65,
-	0x72,0x61,0x5F,0x74,0x74,0x66,0x2C,0x20,0x31,0x32,0x29,0x0D,0x0A,0x09,0x65,
-	0x6E,0x64,0x0D,0x0A,0x09,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,0x68,
-	0x69,0x63,0x73,0x2E,0x70,0x72,0x69,0x6E,0x74,0x66,0x31,0x28,0x2E,0x2E,0x2E,
-	0x29,0x0D,0x0A,0x09,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,
-	0x63,0x73,0x2E,0x70,0x72,0x69,0x6E,0x74,0x66,0x20,0x3D,0x20,0x6C,0x6F,0x76,
-	0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,0x70,0x72,0x69,0x6E,
-	0x74,0x66,0x31,0x0D,0x0A,0x65,0x6E,0x64,0x0D,0x0A,0x0D,0x0A,
+	0x31,0x28,0x2E,0x2E,0x2E,0x29,0x0D,0x0A,0x09,0x6C,0x6F,0x76,0x65,0x2E,0x67,
+	0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,0x70,0x72,0x69,0x6E,0x74,0x66,0x20,
+	0x3D,0x20,0x6C,0x6F,0x76,0x65,0x2E,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,
+	0x2E,0x70,0x72,0x69,0x6E,0x74,0x66,0x31,0x0D,0x0A,0x65,0x6E,0x64,0x0D,0x0A,
+	0x0D,0x0A,
 };
 // [/graphics.lua]