From 2c5b636919997d39fd5e2927350b1fd636a68104 Mon Sep 17 00:00:00 2001 From: Matthew Einhorn Date: Wed, 26 Mar 2014 22:28:36 -0400 Subject: [PATCH 1/4] Change fonts to be passed to pygame as file objects instead of filenames due to pygame unicode issues: #1827. Also adds cache to keep file handle open while in use. --- kivy/core/text/text_pygame.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kivy/core/text/text_pygame.py b/kivy/core/text/text_pygame.py index 0ec1394cf..bb034be57 100644 --- a/kivy/core/text/text_pygame.py +++ b/kivy/core/text/text_pygame.py @@ -14,6 +14,7 @@ except: raise pygame_cache = {} +pygame_font_handles = {} pygame_cache_order = [] # init pygame font @@ -40,12 +41,13 @@ class LabelPygame(LabelBase): fontid = self._get_font_id() if fontid not in pygame_cache: # try first the file if it's a filename - fontobject = None + font_handle = fontobject = None fontname = self.options['font_name_r'] ext = fontname.split('.')[-1] if ext.lower() == 'ttf': # fontobject - fontobject = pygame.font.Font(fontname, + font_handle = open(fontname, 'rb') + fontobject = pygame.font.Font(font_handle, int(self.options['font_size'])) # fallback to search a system font @@ -60,12 +62,14 @@ class LabelPygame(LabelBase): fontobject = pygame.font.Font(font, int(self.options['font_size'])) pygame_cache[fontid] = fontobject + pygame_font_handles[fontid] = font_handle pygame_cache_order.append(fontid) # to prevent too much file open, limit the number of opened fonts to 64 while len(pygame_cache_order) > 64: popid = pygame_cache_order.pop(0) del pygame_cache[popid] + del pygame_font_handles[popid] return pygame_cache[fontid] From 059e5afd9b0bf81e70be177e60b37d21a557be4f Mon Sep 17 00:00:00 2001 From: Matthew Einhorn Date: Wed, 26 Mar 2014 22:30:07 -0400 Subject: [PATCH 2/4] Fix font test to use unicode font filename for proper loading to allow passing test on windows (and other os's). --- kivy/tests/test_fonts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kivy/tests/test_fonts.py b/kivy/tests/test_fonts.py index 53c06822b..700995f9c 100644 --- a/kivy/tests/test_fonts.py +++ b/kivy/tests/test_fonts.py @@ -6,7 +6,7 @@ class FontTestCase(unittest.TestCase): def setUp(self): import os - self.font_name = os.path.join(os.path.dirname(__file__), 'कीवी.ttf') + self.font_name = os.path.join(os.path.dirname(__file__), u'कीवी.ttf') if not os.path.exists(self.font_name): from zipfile import ZipFile with ZipFile(os.path.join(os.path.dirname(__file__), From caba8d6d4821a41110878523f2a639cd37da65a4 Mon Sep 17 00:00:00 2001 From: Matthew Einhorn Date: Wed, 26 Mar 2014 23:14:58 -0400 Subject: [PATCH 3/4] close font handle when finished. --- kivy/core/text/text_pygame.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kivy/core/text/text_pygame.py b/kivy/core/text/text_pygame.py index bb034be57..363b690c8 100644 --- a/kivy/core/text/text_pygame.py +++ b/kivy/core/text/text_pygame.py @@ -69,7 +69,9 @@ class LabelPygame(LabelBase): while len(pygame_cache_order) > 64: popid = pygame_cache_order.pop(0) del pygame_cache[popid] - del pygame_font_handles[popid] + font_handle = pygame_font_handles.pop(popid) + if font_handle is not None: + font_handle.close() return pygame_cache[fontid] From 0fc3551f0fc8e99b5eb1f432b5c4d70a99a5c44e Mon Sep 17 00:00:00 2001 From: matham Date: Fri, 4 Apr 2014 11:18:54 -0400 Subject: [PATCH 4/4] Update windows installation to say cmd environemnt is not changed globally. --- doc/sources/installation/installation-windows.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/sources/installation/installation-windows.rst b/doc/sources/installation/installation-windows.rst index 31c38ed1a..0295f1501 100644 --- a/doc/sources/installation/installation-windows.rst +++ b/doc/sources/installation/installation-windows.rst @@ -25,8 +25,12 @@ Installing the portable version :scale: 75% #. In the folder where you unzipped the package, you have a script called `kivy.bat`. - Use this file for launching any kivy application as described below - + Use this file for launching any kivy application as described below. + + .. note:: + Launching the kivy.bat file will open a command window already set up to run kivy's + Python. The environment settings are only changed for this command window and will + not effect the system environment. .. _windows-run-app: