mirror of https://github.com/kivy/kivy.git
core/text: allow others font extension to be loaded
Freetype itself supports much more than ttf: otf, woff, etc. See the full list at http://www.freetype.org/freetype2/
This commit is contained in:
parent
0167171e3e
commit
c990565739
|
@ -97,8 +97,9 @@ cdef TTF_Font *_get_font(self):
|
|||
# try first the file if it's a filename
|
||||
fontname = self.options['font_name_r']
|
||||
bytes_fontname = <bytes>fontname.encode('utf-8')
|
||||
ext = fontname.split('.')[-1]
|
||||
if ext.lower() == 'ttf':
|
||||
ext = fontname.rsplit('.', 1)
|
||||
if len(ext) == 2:
|
||||
# try to open the fount if it has an extension
|
||||
fontobject = TTF_OpenFont(bytes_fontname,
|
||||
int(self.options['font_size']))
|
||||
|
||||
|
|
|
@ -43,9 +43,9 @@ class LabelPygame(LabelBase):
|
|||
# try first the file if it's a filename
|
||||
font_handle = fontobject = None
|
||||
fontname = self.options['font_name_r']
|
||||
ext = fontname.split('.')[-1]
|
||||
if ext.lower() == 'ttf':
|
||||
# fontobject
|
||||
ext = fontname.rsplit('.', 1)
|
||||
if len(ext) == 2:
|
||||
# try to open the font if it has an extension
|
||||
font_handle = open(fontname, 'rb')
|
||||
fontobject = pygame.font.Font(font_handle,
|
||||
int(self.options['font_size']))
|
||||
|
|
|
@ -106,8 +106,8 @@ cdef TTF_Font *_get_font(self):
|
|||
if fontid not in pygame_cache:
|
||||
# try first the file if it's a filename
|
||||
fontname = self.options['font_name_r']
|
||||
ext = fontname.split('.')[-1]
|
||||
if ext.lower() == 'ttf':
|
||||
ext = fontname.rsplit('.', 1)
|
||||
if len(ext) == 2:
|
||||
fontobject = TTF_OpenFont(fontname, int(self.options['font_size']))
|
||||
|
||||
# fallback to search a system font
|
||||
|
|
Loading…
Reference in New Issue