[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] PATCH: OTF fonts in windows/linux



Even though freetype supports OTF fonts, it looks like they are
rejected by pygame because of their extension.  This patch enables
.otf fonts in pygame.font.get_fonts().

It's minimally tested (i.e., the enabled OTF fonts render properly),
but seems to work.

-Ian

-- 
Ian Katz
Research Engineer, MIT Sea Grant AUV Laboratory
ijk5@xxxxxxx / 617 253 9312
*** /usr/lib/python2.6/dist-packages/pygame/sysfont.py	2010-10-27 14:43:05.966510229 -0400
--- scratch/sysfont.py	2010-10-27 14:44:49.254511698 -0400
***************
*** 273,279 ****
                      # no goodness with str or MBCS encoding... skip this font.
                      continue
     
!             if font[-4:].lower() not in [".ttf", ".ttc"]:
                  continue
              if os.sep not in font:
                  font = os.path.join(fontdir, font)
--- 273,279 ----
                      # no goodness with str or MBCS encoding... skip this font.
                      continue
     
!             if font[-4:].lower() not in [".ttf", ".ttc", ".otf"]:
                  continue
              if os.sep not in font:
                  font = os.path.join(fontdir, font)
***************
*** 462,468 ****
          for line in entries.split('\n'):
              try:
                  filename, family, style = line.split(':', 2)
!                 if filename[-4:].lower() in ['.ttf', '.ttc']:
                      bold = style.find('Bold') >= 0
                      italic = style.find('Italic') >= 0
                      oblique = style.find('Oblique') >= 0
--- 462,468 ----
          for line in entries.split('\n'):
              try:
                  filename, family, style = line.split(':', 2)
!                 if filename[-4:].lower() in ['.ttf', '.ttc', '.otf']:
                      bold = style.find('Bold') >= 0
                      italic = style.find('Italic') >= 0
                      oblique = style.find('Oblique') >= 0