Font reloading [SOLVED]

When I try to load the same font again - it seems that Panda return link to the first loaded font. For example I try to set different outline (red and green), but I get the same results for both loaded fonts.

font1 = loader.loadFont('arial.ttf', outlineColor = Vec4(1,0,0,1), outlineWidth = 0.5)
font2 = loader.loadFont('arial.ttf', outlineColor = Vec4(0,1,0,1), outlineWidth = 0.5)

TextNode1 = TextNode('text1')

TextNode2 = TextNode('text2')

t1 = render2d.attachNewNode(TextNode1.generate())
t2 = render2d.attachNewNode(TextNode2.generate())


This is a feature, because normally you do want it to share the same font object. But when you want to do something unusual like make a specialization of a particular font in one particular color or something, you need to explicitly load a different copy of the font object.

The easiest way to do this is to insert a call to FontPool.releaseFont(‘arial.ttf’) before the second call to loader.loadFont(‘arial.ttf’). Another way is to replace the second call to loadFont() with the call font2 = font1.makeCopy(), and then set the parameters explicitly.


It’s work, thanks for the fast reply :slight_smile: