Update of /cvsroot/freevo/freevo/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26807

Modified Files:
        osd.py 
Log Message:
search system for fonts

Index: osd.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/osd.py,v
retrieving revision 1.135
retrieving revision 1.136
diff -C2 -d -r1.135 -r1.136
*** osd.py      7 Feb 2004 11:50:57 -0000       1.135
--- osd.py      11 Feb 2004 14:23:33 -0000      1.136
***************
*** 11,14 ****
--- 11,17 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.136  2004/02/11 14:23:33  dischi
+ # search system for fonts
+ #
  # Revision 1.135  2004/02/07 11:50:57  dischi
  # fix geometry calculation for border fonts
***************
*** 289,329 ****
          return w
  
      def __getfont__(self, filename, ptsize):
          ptsize = int(ptsize / 0.7)  # XXX pygame multiplies by 0.7 for some reason
  
!         _debug_('Loading font "%s"' % filename,2)
!         try:
!             font = pygame.font.Font(filename, ptsize)
!         except (RuntimeError, IOError):
!             _debug_('Couldnt load font "%s"' % os.path.basename(filename).lower())
!                 
!             # Are there any alternate fonts defined?
!             if not 'OSD_FONT_ALIASES' in dir(config):
!                 print 'No font aliases defined!'
!                 raise # Nope
                  
              # Ok, see if there is an alternate font to use
-             fontname = os.path.basename(filename).lower()
              if fontname in config.OSD_FONT_ALIASES:
                  alt_fname = os.path.join(config.FONT_DIR, 
config.OSD_FONT_ALIASES[fontname])
                  _debug_('trying alternate: %s' % os.path.basename(alt_fname).lower())
!                 try:
!                     font = pygame.font.Font(alt_fname, ptsize)
!                 except (RuntimeError, IOError):
!                     print 'Couldnt load alternate font "%s"' % alt_fname
!                     raise
!             else:
!                 global font_warning
!                 if not fontname in font_warning:
!                     print 'WARNING: No alternate found in the alias list!'
!                     print 'Falling back to default font, this may look very ugly'
!                     font_warning.append(fontname)
!                 try:
!                     font = pygame.font.Font(config.OSD_DEFAULT_FONTNAME, ptsize)
!                 except (RuntimeError, IOError):
!                     print 'Couldnt load font "%s"' % config.OSD_DEFAULT_FONTNAME
!                     raise
!         f = Font(filename, ptsize, font)
!         return f.font
  
          
--- 292,345 ----
          return w
  
+     def __loadfont__(self, filename, ptsize):
+         if os.path.isfile(filename):
+             try:
+                 return pygame.font.Font(filename, ptsize)
+             except (RuntimeError, IOError):
+                 return None
+         return None
+     
+         
      def __getfont__(self, filename, ptsize):
          ptsize = int(ptsize / 0.7)  # XXX pygame multiplies by 0.7 for some reason
  
!         _debug_('Loading font "%s"' % filename, 2)
!         font   = self.__loadfont__(filename, ptsize)
!         if not font:
!             
!             # search OSD_EXTRA_FONT_PATH for this font
!             fontname = os.path.basename(filename).lower()
!             for path in config.OSD_EXTRA_FONT_PATH:
!                 fname = os.path.join(path, fontname)
!                 font  = self.__loadfont__(fname, ptsize)
!                 if font:
!                     break
!                 font  = self.__loadfont__(fname.replace('_bold', 'bd'), ptsize)
!                 if font:
!                     break
                  
+         if not font:
+             _debug_('Couldnt load font "%s"' % os.path.basename(filename).lower())
+ 
              # Ok, see if there is an alternate font to use
              if fontname in config.OSD_FONT_ALIASES:
                  alt_fname = os.path.join(config.FONT_DIR, 
config.OSD_FONT_ALIASES[fontname])
                  _debug_('trying alternate: %s' % os.path.basename(alt_fname).lower())
!                 font = self.__loadfont__(alt_fname, ptsize)
! 
!         if not font:
!             # not good
!             global font_warning
!             if not fontname in font_warning:
!                 print 'WARNING: No alternate found in the alias list!'
!                 print 'Falling back to default font, this may look very ugly'
!                 font_warning.append(fontname)
!             font = self.__loadfont__(config.OSD_DEFAULT_FONTNAME, ptsize)
! 
!         if not font:
!             print 'Couldnt load font "%s"' % config.OSD_DEFAULT_FONTNAME
!             raise
! 
!         return font
  
          



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to