Trapping errors from loader.loadFont(...)

I have been pulling out my hair for the past hour trying to figure out why my text wasn’t showing up from the following code :

	self.mFont = loader.loadFont(fontFile)
	Assert(self.mFont != None,"Failed loading font file : "+fontFile)

	...

	self.mHelpDisplay = \
		CreateTextDisplay(
			self.XOffset,
			self.YOffset,
			textScale,	
			textColor[0], textColor[1], textColor[2], textColor[3],
			self.mFont
		)

As it turns out, loader.loadFont(…) does not return None when it fails to load a font file. It returns an empty font. I know this because ‘print self.mFont’ give me “StaticTextFont empty; 0 characters available in font:”.

Is there any way to tell programatically if loader.loadFont(…) fails? That is … is there some boolean expression I can substitute for the ‘self.mFont!=None’ in my assert statement?

Thx,
Paul

This should do the trick:

mFont.isValid( )

enn0x

Perfect Thanks!