directgui skinning an text...

And it is, but if I make a custom texture card for the button and use it, the text will be centered only on the x.

import direct.directbase.DirectStart
from direct.gui.DirectGui import *
from pandac.PandaModules import *

model = loader.loadModel('button')

button = DirectButton(relief = None, text = ("Play"), text_scale = 0.1, geom = model, geom_pos = (0,0,0.02))
				 
run()

Here is an example texture card I made, nothing special:
mediafire.com/?tnzidnln5ly

I can do something like adding

geom_pos = (0,0,0.02)

but why should I? I have also tried using the argument

text_align = TextNode.ACenter

It is normal when not using a custom texture card

The text is placed with its baseline on the line z = 0. So, yes, you should be aware of this when you construct your custom geometry.

David

The geometry is created with egg-texture-cards.exe.
Its also mentioned in the manual, so there should probably be a way to specify it when creating the egg file?

All of the Panda3D command-line tools will explain themselves with a “-h” parameter, so “egg-texture-cards -h” will tell you (among other things) that you can specify:

  -g left,right,bottom,top
               Specifies the geometry of each polygon.  The default is a
               unit polygon centered on the origin: -0.5,0.5,-0.5,0.5.
               Polygons are always created on the X-Y plane.  If -p is
               not also specified, all polygons will be the same size
               and shape.

David

OK, so if I understood the ‘baseline’ correctly, I should use these values for perfect aligning?:

-g -0.5,0.5,-0.375,0.625

Try it and let us know how it works. :slight_smile:

David

Well the z center of the button will be the z center of the lowercase letters… works for me.
But is this the ‘right’ way of doing it?