diff --git a/direct/src/gui/GuiGlobals.py b/direct/src/gui/GuiGlobals.py index b90c23a50c..04e821ff4e 100644 --- a/direct/src/gui/GuiGlobals.py +++ b/direct/src/gui/GuiGlobals.py @@ -15,7 +15,7 @@ drawOrder = 100 def getDefaultFont(): global font if font == None: - font = loader.loadModelNode("models/fonts/Comic") + font = loader.loadFont("models/fonts/Comic") return font def setDefaultFont(newFont): diff --git a/direct/src/showbase/Loader.py b/direct/src/showbase/Loader.py index e1a33e92d0..ed84effe6a 100644 --- a/direct/src/showbase/Loader.py +++ b/direct/src/showbase/Loader.py @@ -74,7 +74,10 @@ class Loader: useful for special models like fonts that you don't care about where they're parented to, and you don't want a NodePath anyway--it prevents accumulation of instances of the font - model under hidden.""" + model under hidden. + + However, if you're loading a font, see loadFont(), below. + """ Loader.notify.debug("Loading model once node: %s" % (modelPath)) if phaseChecker: @@ -86,7 +89,29 @@ class Loader: """ Loader.notify.debug("Unloading model: %s" % (modelPath)) ModelPool.releaseModel(modelPath) - + + # font loading funcs + def loadFont(self, modelPath): + """loadFont(self, string) + + This loads a special model that will be sent to a TextNode as + a "font"--this is a model generated with egg-mkfont (or + ttf2egg) that consists of a flat hierarchy, with one node per + each letter of the font. The TextNode will assemble these + letters together, given a string. + """ + Loader.notify.debug("Loading font: %s" % (modelPath)) + if phaseChecker: + phaseChecker(modelPath) + node = ModelPool.loadModel(modelPath) + + #*** Temporary try-except to support old pandas without TextFont. + try: + font = TextFont(node) + except: + font = node + return font + # texture loading funcs def loadTexture(self, texturePath, alphaPath = None): """loadTexture(self, string)