diff --git a/kivy/core/text/_text_sdl2.pyx b/kivy/core/text/_text_sdl2.pyx index 9581bb7ed..0947ef41b 100644 --- a/kivy/core/text/_text_sdl2.pyx +++ b/kivy/core/text/_text_sdl2.pyx @@ -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 = 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'])) diff --git a/kivy/core/text/text_pygame.py b/kivy/core/text/text_pygame.py index abbf2dce7..ced2b721c 100644 --- a/kivy/core/text/text_pygame.py +++ b/kivy/core/text/text_pygame.py @@ -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'])) diff --git a/kivy/core/text/text_sdlttf.pyx b/kivy/core/text/text_sdlttf.pyx index 9b52582a3..a0c619242 100644 --- a/kivy/core/text/text_sdlttf.pyx +++ b/kivy/core/text/text_sdlttf.pyx @@ -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