I’m drawing text in 3D using the TextNode and a monospace (fixed-width) font. The fixed width works perfectly except for the space character which is usually wider but sometimes narrower than the other characters. This obviously throws off any attempts to align columns of text.
I tried several monospace fonts, and if you import a monospace ttf font file, the spaces are almost twice as wide as the other characters. So I tried using egg-mkfont to generate font egg files and the results are better but the space character is still slightly wider or narrow depending on the font.
Has anyone else encountered this issue? Can anyone suggest a solution? Perhaps by editing the egg file?
Hmm, what monospace fonts are you using? I haven’t seen this problem before, but it’s true I don’t use a lot of monospace fonts.
You can always specify an explicit value for spaceAdvance to the loader.loadFont() call.
I tried courier, consola and dejavu. All had the same problem. I’ve settled on dejavu, and using your suggestion of setting spaceAdvance explicitly, I was able to get the space character to maintain fixed width. Thank-you! Through trial and error, spaceAdvance = 0.3 seems be the exact character width, at least for dejavu.
For the record, I did discover (and fix) a problem with loading static fonts as generated by egg-mkfont; the space width wasn’t being automatically respected in that case. But I haven’t been able to reproduce the reported problem with ttf files loaded directly: in my experiments, the space always comes out at the correct width.
What operating system are you running on, and which build of Panda?
I have a similar issue with my fonts.
I use the panda3d-cvs AUR package from Arch Linux.
You can find my font on github here github.com/Kivutar/tethical/blo … ts/fft.egg
Yes, but that’s an egg file. As I said, there was a problem with fonts that were converted to egg files. (The problem has been fixed in 1.8, but you will also have to reconvert your egg file with the 1.8 version of egg-mkfont, as well as run your application in 1.8.)
I’m not aware of any problems with loading a .ttf file directly into Panda.