Browse Source

support loading ttf's directly

David Rose 24 years ago
parent
commit
0f4d293597
1 changed files with 21 additions and 11 deletions
  1. 21 11
      direct/src/showbase/Loader.py

+ 21 - 11
direct/src/showbase/Loader.py

@@ -103,18 +103,28 @@ class Loader:
         Loader.notify.debug("Loading font: %s" % (modelPath))
         Loader.notify.debug("Loading font: %s" % (modelPath))
         if phaseChecker:
         if phaseChecker:
             phaseChecker(modelPath)
             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)
             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
         return font
 
 
     # texture loading funcs
     # texture loading funcs