Repository: kivy/kivy

Issue:
codeinput.py example missing Pro.ttf
I was trying the various kivy examples, and one of them failed, the `codeinput.py` file, with the following error:

```
sinclair@blastocyst  $ kivy /Users/sinclair/kivy/examples/widgets/codeinput.py
[INFO              ] Kivy v1.8.0
[INFO              ] [Logger      ] Record log in /Users/sinclair/.kivy/logs/kivy_14-12-27_20.txt
[INFO              ] [Factory     ] 157 symbols loaded
[DEBUG             ] [Cache       ] register <kv.lang> with limit=None, timeout=Nones
[DEBUG             ] [Cache       ] register <kv.image> with limit=None, timeout=60s
[DEBUG             ] [Cache       ] register <kv.atlas> with limit=None, timeout=Nones
[INFO              ] [Image       ] Providers: img_imageio, img_tex, img_dds, img_pygame, img_gif (img_pil ignored)
[DEBUG             ] [Cache       ] register <kv.texture> with limit=1000, timeout=60s
[DEBUG             ] [Cache       ] register <kv.shader> with limit=1000, timeout=3600s
[INFO              ] [Text        ] Provider: pygame
[DEBUG             ] [Window      ] Ignored <egl_rpi> (import error)
[INFO              ] [Window      ] Provider: pygame(['window_egl_rpi'] ignored)
[DEBUG             ] [Window      ] Display driver Quartz
[DEBUG             ] [Window      ] Actual window size: 800x600
[DEBUG             ] [Window      ] Actual color bits r8 g8 b8 a8
[DEBUG             ] [Window      ] Actual depth bits: 24
[DEBUG             ] [Window      ] Actual stencil bits: 8
[DEBUG             ] [Window      ] Actual multisampling samples: 4
[INFO              ] [GL          ] OpenGL version <2.1 INTEL-10.0.86>
[INFO              ] [GL          ] OpenGL vendor <Intel Inc.>
[INFO              ] [GL          ] OpenGL renderer <Intel HD Graphics 5000 OpenGL Engine>
[INFO              ] [GL          ] OpenGL parsed version: 2, 1
[INFO              ] [GL          ] Shading version <1.20>
[INFO              ] [GL          ] Texture max size <16384>
[INFO              ] [GL          ] Texture max units <16>
[DEBUG             ] [Shader      ] Fragment compiled successfully
[DEBUG             ] [Shader      ] Vertex compiled successfully
[DEBUG             ] [ImageImageIO] Load </Applications/Kivy.app/Contents/Resources/kivy/kivy/data/glsl/default.png>
[INFO              ] [GL          ] BGRA texture support is available
[INFO              ] [Window      ] virtual keyboard not allowed, single mode, not docked
[DEBUG             ] [Cache       ] register <kv.loader> with limit=500, timeout=60s
[INFO              ] [Loader      ] using a thread pool of 2 workers
[DEBUG             ] [Cache       ] register <textinput.label> with limit=None, timeout=60.0s
[DEBUG             ] [Cache       ] register <textinput.width> with limit=None, timeout=60.0s
[DEBUG             ] [App         ] Loading kv </Users/sinclair/kivy/examples/widgets/codeinputtest.kv>
 Traceback (most recent call last):
   File "/Users/sinclair/kivy/examples/widgets/codeinput.py", line 179, in <module>
     CodeInputTest().run()
   File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/app.py", line 766, in run
     root = self.build()
   File "/Users/sinclair/kivy/examples/widgets/codeinput.py", line 111, in build
     values=sorted(map(str, fonts.get_fonts())))
   File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/uix/spinner.py", line 116, in __init__
     self._build_dropdown()
   File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/uix/spinner.py", line 130, in _build_dropdown
     self._update_dropdown()
   File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/uix/spinner.py", line 139, in _update_dropdown
     item = cls(text=value)
   File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/uix/behaviors.py", line 72, in __init__
     super(ButtonBehavior, self).__init__(**kwargs)
   File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/uix/label.py", line 141, in __init__
     self._create_label()
   File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/uix/label.py", line 161, in _create_label
     self._label = CoreLabel(**dkw)
   File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/core/text/__init__.py", line 136, in __init__
     self.resolve_font_name()
   File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/core/text/__init__.py", line 196, in resolve_font_name
     raise IOError('Label: File %r not found' % fontname)
 IOError: Label: File u'/Library/Fonts/ Pro.ttf' not found
```

I am using OS X 10.10.1

I tried adding a font file called "Pro.ttf" at that location to make it happy, but the result was the same.



Discussion:

Resolving patch:
diff --git a/examples/widgets/codeinput.py b/examples/widgets/codeinput.py
--- a/examples/widgets/codeinput.py
+++ b/examples/widgets/codeinput.py
@@ -134,8 +134,9 @@ def _update_size(self, instance, size):
         self.codeinput.font_size = float(size)
 
     def _update_font(self, instance, fnt_name):
-        instance.font_name = self.codeinput.font_name =\
-            fonts.match_font(fnt_name)
+        font_name = fonts.match_font(fnt_name)
+        if os.path.exists(font_name):
+            instance.font_name = self.codeinput.font_name = font_name
 
     def _file_menu_selected(self, instance, value):
         if value == 'File':


Test patch: