From 0f4d293597e358fac97725c67082358674eceae7 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 12 Feb 2002 19:52:13 +0000 Subject: [PATCH] support loading ttf's directly --- direct/src/showbase/Loader.py | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/direct/src/showbase/Loader.py b/direct/src/showbase/Loader.py index 6e69db39cb..eb8a64c2e5 100644 --- a/direct/src/showbase/Loader.py +++ b/direct/src/showbase/Loader.py @@ -103,18 +103,28 @@ class Loader: Loader.notify.debug("Loading font: %s" % (modelPath)) if phaseChecker: phaseChecker(modelPath) - node = ModelPool.loadModel(modelPath) - # Create a temp node path so you can adjust priorities - nodePath = hidden.attachNewNode(node) - nodePath.adjustAllPriorities(priority) - # Now create text font from the node - # Temporary try..except for old pandas. - try: + + # Check the filename extension. + fn = Filename(modelPath) + extension = fn.getExtension() + + if extension == "" or extension == "egg" or extension == "bam": + # A traditional model file is probably an old-style, + # static font. + node = ModelPool.loadModel(modelPath) + # Create a temp node path so you can adjust priorities + nodePath = hidden.attachNewNode(node) + nodePath.adjustAllPriorities(priority) + # Now create text font from the node font = StaticTextFont(node) - except: - font = TextFont(node) - # And remove node path - nodePath.removeNode() + + # And remove node path + nodePath.removeNode() + else: + # Otherwise, it must be a new-style, dynamic font. Maybe + # it's just a TTF file or something. + font = DynamicTextFont(fn) + return font # texture loading funcs