Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/api/MultiLabel.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/api/MultiLabel.py b/src/api/MultiLabel.py
index 962fb19..3dee9de 100755
--- a/src/api/MultiLabel.py
+++ b/src/api/MultiLabel.py
@@ -17,6 +17,10 @@ class CMultiLabel(CLabel):
def __init__(self, fontName = "DejaVuSans.ttf", transparent=False):
CLabel.__init__(self, fontName, transparent)
+ self.vSize = 35
+
+ def set_vertical(self, aVer=35):
+ self.vSize = aVer
def _update_image(self):
self.image = pygame.Surface(self.size)
@@ -25,7 +29,9 @@ class CMultiLabel(CLabel):
self.image.set_colorkey(self.bgColor)
textLines = self.text.split('\n')
numLines = len(textLines)
- vSize = self.image.get_height() / numLines
+ #self.vSize = self.image.get_height() / numLines
+ total_text_height = self.vSize * numLines
+ fix = (self.image.get_height() - total_text_height) / 2
for lineNum in range(numLines):
currentLine = textLines[lineNum]
if self.transparent:
@@ -34,6 +40,6 @@ class CMultiLabel(CLabel):
fontSurface = self.font.render(currentLine, True, self.fgColor, self.bgColor)
#center the text
xPos = (self.image.get_width() - fontSurface.get_width())/2
- yPos = lineNum * vSize
+ yPos = lineNum * self.vSize + fix
self.image.blit(fontSurface, (xPos, yPos))
self.update()