🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

BMFONT minor issue fixed

Started by
2 comments, last by WitchLord 3 years, 2 months ago

Hi,

I found a minor issue in bmFont 1.14 (latest version): when you use the autofitter and the only not fitting character is the invalid glyph the program access the noFit array with a negative index because the invalid glyph has -1 as id.

I've attached a patch fixing this bug

thank you for your great work

V

Index: source/fontgen.cpp
===================================================================
--- source/fontgen.cpp	(revision 28)
+++ source/fontgen.cpp	(working copy)
@@ -2035,7 +2035,9 @@
 
 			for( int n = 0; n < numChars; n++ )
 			{
-				if( ch[n] == 0 )
+			  // avoid to access the noFit array with a negative value
+			  // (it could appen if the only not fitting character is the invalid glyph)
+				if( ch[n] == 0 || ch[n]->m_id < 0)
 					continue;
 
 				noFit[ch[n]->m_id] = true;
@@ -3145,4 +3147,4 @@
 void CFontGen::ClearFailedCharacters()
 {
 	memset(noFit, 0, sizeof(noFit));
-}
\ No newline at end of file
+}
Advertisement

Thanks a lot for the report and patch.

I'll have it checked in to the repository as soon as I can.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I've check in this patch now.

Thanks,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement