From f972c9923f2796589454422d5e0aa5415c2de1f0 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Thu, 11 Sep 2014 02:42:56 -0300 Subject: [PATCH] Fixed love.graphics.reset reverting the current font to nil and breaking love.graphics.print. --- src/modules/graphics/opengl/Graphics.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index f44d2b7e6..e98dec6a2 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -615,6 +615,12 @@ Color Graphics::getBackgroundColor() const void Graphics::setFont(Font *font) { + // Hack: the Lua-facing love.graphics.print function will set the current + // font if needed, but only on its first call... we want to make sure a nil + // font is never accidentally set (e.g. via love.graphics.reset.) + if (font == nullptr) + return; + DisplayState &state = states.back(); state.font.set(font); } @@ -1289,11 +1295,6 @@ void Graphics::pop() { DisplayState &newstate = states[states.size() - 2]; - // Hack: the Lua-facing love.graphics.print function will set the current - // font if needed, but only on its first call... we always want a font. - if (newstate.font.get() == nullptr) - newstate.font.set(states.back().font.get()); - restoreStateChecked(newstate); // The last two states in the stack should be equal now.