setGlyphScale weirdness

I’m actually toying with TextProperties and I’m coding a script to build text with different properties, one of these is to have different sizes on the same text block. All works good until I got a situation with nested glyphscales where I noticed that (very) apparently looks like the nested glyphscale is relative to the one applied just before (as is without closing it with \2)
One piece of code will clear instantly what I’m saying:

import direct.directbase.DirectStart
from pandac.PandaModules import *
if __name__ == '__main__': 
  tpG1 = TextProperties()
  tpG2 = TextProperties()
  tpGReset = TextProperties()
  tpMgr = TextPropertiesManager.getGlobalPtr()
  tpMgr.setProperties("g1", tpG1)
  tpMgr.setProperties("g2", tpG2)
  tpMgr.setProperties("gr", tpGReset)
  t1="\1g2\1(I'm not nested)\2 \1g1\1Looks like \1g2\1nested glyphscales are relative \2 to the container.\2"
  t2="\1g2\1(I'm not nested)\2 \1g1\1Even \1gr\1\1g2\1applying \2 clearGlyphScale().\2"

I found it an incorrect behavior but anyway I thought that using clearGlyphScale() I would have an opportunity to override this but alas it failed. How do I do now?

I think I understand you correctly: nested glyph scales are relative to the containing glyph scale. This is by design: the glyph scale is intended to represent a relative scale factor, not an absolute size.

clearClearScale() doesn’t perform any counterscales. All it does is remove whatever glyph scale you have previously set, on that particular TextProperties object. Since you haven’t set any glyph scale on that object, it does nothing. If you want to completely undo the effect of the containing glyph scale, you will have to add a counterscale explicitly.

I suppose it could be a useful addition to have a fontSize parameter that is more akin to HTML’s parameter, which doesn’t accumulate in the same way. But the whole nature of Panda’s scene graph is cumulative like this, so it’s difficult to speak of an absolute font size: everything is always relative to its parent anyway, so what does an absolute font size even mean?


I’m indeed parsing html text to P3D Textnodes David, and this behavior is quite frustrating in this case. We knew the concept of relative scales between nested 3D objects but here we are talking about to apply properties (scales etc.) to, at least this was as I supposed, a same surface. What you say instead is that each time I nest a portion of text with property pushes, the engine nest a new node making it a node child and this explain that ‘weirdness’.
Well if this is so I guess I have to bonk my head to the wall until I’ll found a workaround to this.