[Pychord-commits] r17 - in trunk: . PyChord font

danilo at garage.maemo.org danilo at garage.maemo.org
Mon Oct 8 22:03:39 EEST 2007


Author: danilo
Date: 2007-10-08 22:03:38 +0300 (Mon, 08 Oct 2007)
New Revision: 17

Added:
   trunk/font/
   trunk/font/VeraMono.ttf
Modified:
   trunk/PyChord/Chstrings.py
Log:
Font fixes


Modified: trunk/PyChord/Chstrings.py
===================================================================
--- trunk/PyChord/Chstrings.py	2007-10-08 12:57:17 UTC (rev 16)
+++ trunk/PyChord/Chstrings.py	2007-10-08 19:03:38 UTC (rev 17)
@@ -22,7 +22,7 @@
     
     rect = Rect([0,0],[800,480])
         
-    def __init__( self, text, pos=None, font=None, ptsize=30,
+    def __init__( self, text, pos=None, font='font/VeraMono.ttf', ptsize=20,
                   fgcolor="0xFFFFFF", bgcolor=None ):
         """
         This function create a new Chstring.
@@ -54,7 +54,7 @@
         """
             Increase font size by 5 points
         """
-        self.ptsize += 5
+        self.ptsize += 3
         
         # Cleaning text images
         for i in range(1,len(self.image)):
@@ -76,20 +76,22 @@
         """
             Decrease font size by 5 points
         """
-        self.ptsize -= 5
         
-        for i in range(1,len(self.image)):
-            self.image.pop()
+        if self.ptsize > 4:
+            self.ptsize -= 3
             
-        self.font    = pygame.font.Font( self.tfont, self.ptsize )
-        
-        for t in self.text:
-            if self.bgcolor:
-                self.image.append(self.font.render( t[:-1], True, self.fgcolor,self.bgcolor ))
-            else:                
-                self.image.append(self.font.render( t[:-1], True, self.fgcolor ))
-        
-        self.wdirty = True
+            for i in range(1,len(self.image)):
+                self.image.pop()
+                
+            self.font    = pygame.font.Font( self.tfont, self.ptsize )
+            
+            for t in self.text:
+                if self.bgcolor:
+                    self.image.append(self.font.render( t[:-1], True, self.fgcolor,self.bgcolor ))
+                else:                
+                    self.image.append(self.font.render( t[:-1], True, self.fgcolor ))
+            
+            self.wdirty = True
     
     def update( self):
         """
@@ -133,8 +135,8 @@
         im.fill((0,0,0))
         screen.blit( im, (0,0))
         for im in self.image:
-            if (self.pos[1] + i*25 <= 480) and (self.pos[1] + i*25 >= 0):
-                screen.blit( im, (self.pos[0],self.pos[1] + 25*i))
+            if (self.pos[1] + i*(self.ptsize-10) <= 480) and (self.pos[1] + i*(self.ptsize) >= 0):
+                screen.blit( im, (self.pos[0],self.pos[1] + (self.ptsize)*i))
             i += 1
     # draw()
     

Added: trunk/font/VeraMono.ttf
===================================================================
(Binary files differ)


Property changes on: trunk/font/VeraMono.ttf
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream



More information about the Pychord-commits mailing list