Advertisement

BMFONT minor issue fixed

Started by February 17, 2021 09:55 AM
2 comments, last by WitchLord 3 years, 7 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
+}

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

Advertisement

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