本文整理汇总了Python中panda3d.core.TextNode.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Python TextNode.getWidth方法的具体用法?Python TextNode.getWidth怎么用?Python TextNode.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.TextNode
的用法示例。
在下文中一共展示了TextNode.getWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: attachHostNameToSign
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import getWidth [as 别名]
def attachHostNameToSign(self, locator):
if self.hostName == '':
return
nameText = TextNode('nameText')
nameText.setCardAsMargin(0.1, 0.1, 0.1, 0.1)
nameText.setCardDecal(True)
nameText.setCardColor(1.0, 1.0, 1.0, 0.0)
r = 232.0 / 255.0
g = 169.0 / 255.0
b = 23.0 / 255.0
nameText.setTextColor(r, g, b, 1)
nameText.setAlign(nameText.ACenter)
nameText.setFont(ToontownGlobals.getBuildingNametagFont())
nameText.setShadowColor(0, 0, 0, 1)
nameText.setBin('fixed')
if TTLocalizer.BuildingNametagShadow:
nameText.setShadow(*TTLocalizer.BuildingNametagShadow)
nameWordWrap = 11.0
nameText.setWordwrap(nameWordWrap)
scaleMult = 0.48
houseName = self.hostName
nameText.setText(houseName)
textWidth = nameText.getWidth()
xScale = 1.0 * scaleMult
if textWidth > nameWordWrap:
xScale = nameWordWrap / textWidth * scaleMult
sign_origin = locator
namePlate = sign_origin.attachNewNode(nameText)
namePlate.setDepthWrite(0)
namePlate.setPos(0, 0, 0)
namePlate.setScale(xScale)
示例2: getSpaceGap
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import getWidth [as 别名]
def getSpaceGap(gap, font=None):
txtn = TextNode('tt')
if font: txtn.setFont(font)
s = ''
txtn.setText(s)
while txtn.getWidth() < gap:
s += ' '
txtn.setText(s)
return s
示例3: getTextSize
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import getWidth [as 别名]
def getTextSize(txt, style):
tn = TextNode(txt)
tn.setText(txt)
tn.setFont(loader.loadFont(style['font']))
tn.setSlant(style['slant'])
#tn.setFont(style['font'])
fontSize = style['font-size']
lineHeight = tn.getLineHeight()
f = tn.getFrameActual()
return (tn.getWidth()*fontSize,\
(f[3]-f[2])*fontSize,\
lineHeight*fontSize,\
(0, f[1]*fontSize, f[2]*fontSize, f[3]*fontSize))