Example #1
0
 def update(self, fileref = None, rect = None, visible = None, string = None, color = None, just = None, size = None, userlineheight = None):
     dirtyrect = None
     
     # Invalidate render
     self._texture = None
     
     #Update attributes
     if fileref != None:
         self._file = fileref
     if rect != None:
         if len(rect) == 4:
             self._rect = pygame.Rect(rect)
         else:
             self._rect = pygame.Rect(rect,(0,0))
     if visible != None:
         self._visible = visible
     if string  != None:
         self._string = string
     if color != None:
         self._color = color
     if just != None:
         self._just = just
     if size != None:
         self._size = size
     if userlineheight != None:
         self._userlineheight = userlineheight
     if self._file == None or self._rect == None:
         self._visible = 0
     #If the object is visible, redraw it
     if globals.isslidevisible(self._slide):
         if self._visible:
             #If any of these changed we need to reload the font
             if fileref or size:
                 self._font = globals.loadfont(self._file, self._size, self._datfile, self._encryption)
                 #If default line spacing is not overridden, get the default
                 if self._userlineheight != None:
                     self._lineheight = self._userlineheight
                 else:
                     self._lineheight = self._font.get_linesize()
                 #Clear the character table
                 self._chartable = None
                 #Clear the objects surface
                 self._objectsurface = None
             #If any of these changed we need to rerender the text, so clear the objects surface
             if string or rect or just or userlineheight or color:
                 self._objectsurface = None
             return
         else:
             #Image is not visible, so clear the buffers to save memory
             self._clearbuffers()
     else:
         #Image is not visible, so clear the buffers to save memory
         self._clearbuffers()
Example #2
0
    def prepareTexture(self):
        #Load the font if needed 
        if self._font == None:
            self._font = globals.loadfont(self._file, self._size)
            #If default line spacing is not overridden, get the default
            if self._userlineheight != None:
                self._lineheight = self._userlineheight
            else:
                self._lineheight = self._font.get_linesize()

        #newsurface = pygame.Surface((512, 512), pygame.SRCALPHA)
        #newsurface.fill(pygame.Color(0, 0, 0, 0)) # fill with transparency

        newsurface = self._rendertext()
        
        self._texture = GLTexture(newsurface, None, False, False)