From 251ec931f99f89cae92d6172bba0d6915f7f2827 Mon Sep 17 00:00:00 2001 From: James Turk Date: Sun, 5 Oct 2003 19:59:29 +0000 Subject: [PATCH] fix in ZFont crash when drawing empty string --- changelog.txt | 3 ++- src/ZE_ZFont.cpp | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 38f2218..82bdcc4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,5 @@ ZEngine Version Log for Version 0.8.5 -$Id: changelog.txt,v 1.51 2003/10/03 21:54:42 cozman Exp $ +$Id: changelog.txt,v 1.52 2003/10/05 19:59:29 cozman Exp $ Changes are marked with symbols that describe them: ! is code that breaks backwards compatibility (used after 0.8.0-rc1, previous versions broke compatibility) @@ -24,6 +24,7 @@ Changes are marked with symbols that describe them: - Removal of VC6 project files and official support. - Removal of SDL_net support in favour of external library. # Sweep of non-used legacy code. + # Fix crash in drawing blank string with ZFont. # Tests modified to show off loading of compressed files. # Moved image,sound,music and font loading code from legacy ZEngine location to respective classes. # Tiny optimizations within newer ZImage code. diff --git a/src/ZE_ZFont.cpp b/src/ZE_ZFont.cpp index b6eac3f..5cae2cb 100644 --- a/src/ZE_ZFont.cpp +++ b/src/ZE_ZFont.cpp @@ -13,7 +13,7 @@ \brief Source file for ZFont. Implementation of ZFont, the basic Font class for ZEngine. -
$Id: ZE_ZFont.cpp,v 1.13 2003/09/24 02:03:18 cozman Exp $
+
$Id: ZE_ZFont.cpp,v 1.14 2003/10/05 19:59:29 cozman Exp $
\author James Turk **/ @@ -85,12 +85,16 @@ void ZFont::Release() void ZFont::DrawText(std::string text, ZImage &image) const { + if(text.length() == 0) + text = " "; image.Attach(TTF_RenderText_Blended(rFont, text.c_str(), rColor)); image.SetAlpha(rColor.unused); //the images alpha comes from the SetColor a parameter } void ZFont::DrawShadedText(std::string text, ZImage &image) const { + if(text.length() == 0) + text = " "; image.Attach(TTF_RenderText_Shaded(rFont, text.c_str(), rColor, rBGColor)); image.SetAlpha(rColor.unused); }