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, textColor, textColor, textColor, 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?