We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Bug when running Vispy offline for the first time
There appears to be a bug when you run Vispy offline and you don't have the freetype thing already downloaded. Not completely sure about the exact conditions responsible for the crash, require some testing...


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `vispy/util/fonts/_freetype.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # -----------------------------------------------------------------------------
3 # Copyright (c) 2014, Vispy Development Team. All Rights Reserved.
4 # Distributed under the (new) BSD License. See LICENSE.txt for more info.
5 # -----------------------------------------------------------------------------
6 
7 # Use freetype to get glyph bitmaps
8 
9 import sys
10 import numpy as np
11 
12 from ...ext.freetype import (FT_LOAD_RENDER, FT_LOAD_NO_HINTING,
13                              FT_LOAD_NO_AUTOHINT, Face)
14 
15 
16 # Convert face to filename
17 from ._vispy_fonts import _vispy_fonts, _get_vispy_font_filename
18 if sys.platform.startswith('linux'):
19     from ...ext.fontconfig import find_font
20 elif sys.platform.startswith('win'):
21     from ._win32 import find_font  # noqa, analysis:ignore
22 else:
23     raise NotImplementedError
24 
25 _font_dict = {}
26 
27 
28 def _load_font(face, bold, italic):
29     key = '%s-%s-%s' % (face, bold, italic)
30     if key in _font_dict:
31         return _font_dict[key]
32     if face in _vispy_fonts:
33         fname = _get_vispy_font_filename(face, bold, italic)
34     else:
35         fname = find_font(face, bold, italic)
36     font = Face(fname)
37     _font_dict[key] = font
38     return font
39 
40 
41 def _load_glyph(f, char, glyphs_dict):
42     """Load glyph from font into dict"""
43     flags = FT_LOAD_RENDER | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT
44     face = _load_font(f['face'], f['bold'], f['italic'])
45     face.set_char_size(f['size'] * 64)
46     # get the character of interest
47     face.load_char(char, flags)
48     bitmap = face.glyph.bitmap
49     width = face.glyph.bitmap.width
50     height = face.glyph.bitmap.rows
51     bitmap = np.array(bitmap.buffer)
52     w0 = bitmap.size // height if bitmap.size > 0 else 0
53     bitmap.shape = (height, w0)
54     bitmap = bitmap[:, :width].astype(np.ubyte)
55 
56     left = face.glyph.bitmap_left
57     top = face.glyph.bitmap_top
58     advance = face.glyph.advance.x / 64.
59     glyph = dict(char=char, offset=(left, top), bitmap=bitmap,
60                  advance=advance, kerning={})
61     glyphs_dict[char] = glyph
62     # Generate kerning
63     for other_char, other_glyph in glyphs_dict.items():
64         kerning = face.get_kerning(other_char, char)
65         glyph['kerning'][other_char] = kerning.x / 64.
66         kerning = face.get_kerning(char, other_char)
67         other_glyph['kerning'][char] = kerning.x / 64.
68
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/vispy/util/fonts/_freetype.py b/vispy/util/fonts/_freetype.py
--- a/vispy/util/fonts/_freetype.py
+++ b/vispy/util/fonts/_freetype.py
@@ -9,9 +9,6 @@
 import sys
 import numpy as np
 
-from ...ext.freetype import (FT_LOAD_RENDER, FT_LOAD_NO_HINTING,
-                             FT_LOAD_NO_AUTOHINT, Face)
-
 
 # Convert face to filename
 from ._vispy_fonts import _vispy_fonts, _get_vispy_font_filename
@@ -25,7 +22,11 @@
 _font_dict = {}
 
 
+# Nest freetype imports in case someone doesn't have freetype on their system
+# and isn't using fonts (Windows)
+
 def _load_font(face, bold, italic):
+    from ...ext.freetype import Face
     key = '%s-%s-%s' % (face, bold, italic)
     if key in _font_dict:
         return _font_dict[key]
@@ -40,6 +41,8 @@
 
 def _load_glyph(f, char, glyphs_dict):
     """Load glyph from font into dict"""
+    from ...ext.freetype import (FT_LOAD_RENDER, FT_LOAD_NO_HINTING,
+                                 FT_LOAD_NO_AUTOHINT)
     flags = FT_LOAD_RENDER | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT
     face = _load_font(f['face'], f['bold'], f['italic'])
     face.set_char_size(f['size'] * 64)

{"golden_diff": "diff --git a/vispy/util/fonts/_freetype.py b/vispy/util/fonts/_freetype.py\n--- a/vispy/util/fonts/_freetype.py\n+++ b/vispy/util/fonts/_freetype.py\n@@ -9,9 +9,6 @@\n import sys\n import numpy as np\n \n-from ...ext.freetype import (FT_LOAD_RENDER, FT_LOAD_NO_HINTING,\n-                             FT_LOAD_NO_AUTOHINT, Face)\n-\n \n # Convert face to filename\n from ._vispy_fonts import _vispy_fonts, _get_vispy_font_filename\n@@ -25,7 +22,11 @@\n _font_dict = {}\n \n \n+# Nest freetype imports in case someone doesn't have freetype on their system\n+# and isn't using fonts (Windows)\n+\n def _load_font(face, bold, italic):\n+    from ...ext.freetype import Face\n     key = '%s-%s-%s' % (face, bold, italic)\n     if key in _font_dict:\n         return _font_dict[key]\n@@ -40,6 +41,8 @@\n \n def _load_glyph(f, char, glyphs_dict):\n     \"\"\"Load glyph from font into dict\"\"\"\n+    from ...ext.freetype import (FT_LOAD_RENDER, FT_LOAD_NO_HINTING,\n+                                 FT_LOAD_NO_AUTOHINT)\n     flags = FT_LOAD_RENDER | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT\n     face = _load_font(f['face'], f['bold'], f['italic'])\n     face.set_char_size(f['size'] * 64)\n", "issue": "Bug when running Vispy offline for the first time\nThere appears to be a bug when you run Vispy offline and you don't have the freetype thing already downloaded. Not completely sure about the exact conditions responsible for the crash, require some testing...\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# -----------------------------------------------------------------------------\n# Copyright (c) 2014, Vispy Development Team. All Rights Reserved.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n# -----------------------------------------------------------------------------\n\n# Use freetype to get glyph bitmaps\n\nimport sys\nimport numpy as np\n\nfrom ...ext.freetype import (FT_LOAD_RENDER, FT_LOAD_NO_HINTING,\n                             FT_LOAD_NO_AUTOHINT, Face)\n\n\n# Convert face to filename\nfrom ._vispy_fonts import _vispy_fonts, _get_vispy_font_filename\nif sys.platform.startswith('linux'):\n    from ...ext.fontconfig import find_font\nelif sys.platform.startswith('win'):\n    from ._win32 import find_font  # noqa, analysis:ignore\nelse:\n    raise NotImplementedError\n\n_font_dict = {}\n\n\ndef _load_font(face, bold, italic):\n    key = '%s-%s-%s' % (face, bold, italic)\n    if key in _font_dict:\n        return _font_dict[key]\n    if face in _vispy_fonts:\n        fname = _get_vispy_font_filename(face, bold, italic)\n    else:\n        fname = find_font(face, bold, italic)\n    font = Face(fname)\n    _font_dict[key] = font\n    return font\n\n\ndef _load_glyph(f, char, glyphs_dict):\n    \"\"\"Load glyph from font into dict\"\"\"\n    flags = FT_LOAD_RENDER | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT\n    face = _load_font(f['face'], f['bold'], f['italic'])\n    face.set_char_size(f['size'] * 64)\n    # get the character of interest\n    face.load_char(char, flags)\n    bitmap = face.glyph.bitmap\n    width = face.glyph.bitmap.width\n    height = face.glyph.bitmap.rows\n    bitmap = np.array(bitmap.buffer)\n    w0 = bitmap.size // height if bitmap.size > 0 else 0\n    bitmap.shape = (height, w0)\n    bitmap = bitmap[:, :width].astype(np.ubyte)\n\n    left = face.glyph.bitmap_left\n    top = face.glyph.bitmap_top\n    advance = face.glyph.advance.x / 64.\n    glyph = dict(char=char, offset=(left, top), bitmap=bitmap,\n                 advance=advance, kerning={})\n    glyphs_dict[char] = glyph\n    # Generate kerning\n    for other_char, other_glyph in glyphs_dict.items():\n        kerning = face.get_kerning(other_char, char)\n        glyph['kerning'][other_char] = kerning.x / 64.\n        kerning = face.get_kerning(char, other_char)\n        other_glyph['kerning'][char] = kerning.x / 64.\n", "path": "vispy/util/fonts/_freetype.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# -----------------------------------------------------------------------------\n# Copyright (c) 2014, Vispy Development Team. All Rights Reserved.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n# -----------------------------------------------------------------------------\n\n# Use freetype to get glyph bitmaps\n\nimport sys\nimport numpy as np\n\n\n# Convert face to filename\nfrom ._vispy_fonts import _vispy_fonts, _get_vispy_font_filename\nif sys.platform.startswith('linux'):\n    from ...ext.fontconfig import find_font\nelif sys.platform.startswith('win'):\n    from ._win32 import find_font  # noqa, analysis:ignore\nelse:\n    raise NotImplementedError\n\n_font_dict = {}\n\n\n# Nest freetype imports in case someone doesn't have freetype on their system\n# and isn't using fonts (Windows)\n\ndef _load_font(face, bold, italic):\n    from ...ext.freetype import Face\n    key = '%s-%s-%s' % (face, bold, italic)\n    if key in _font_dict:\n        return _font_dict[key]\n    if face in _vispy_fonts:\n        fname = _get_vispy_font_filename(face, bold, italic)\n    else:\n        fname = find_font(face, bold, italic)\n    font = Face(fname)\n    _font_dict[key] = font\n    return font\n\n\ndef _load_glyph(f, char, glyphs_dict):\n    \"\"\"Load glyph from font into dict\"\"\"\n    from ...ext.freetype import (FT_LOAD_RENDER, FT_LOAD_NO_HINTING,\n                                 FT_LOAD_NO_AUTOHINT)\n    flags = FT_LOAD_RENDER | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT\n    face = _load_font(f['face'], f['bold'], f['italic'])\n    face.set_char_size(f['size'] * 64)\n    # get the character of interest\n    face.load_char(char, flags)\n    bitmap = face.glyph.bitmap\n    width = face.glyph.bitmap.width\n    height = face.glyph.bitmap.rows\n    bitmap = np.array(bitmap.buffer)\n    w0 = bitmap.size // height if bitmap.size > 0 else 0\n    bitmap.shape = (height, w0)\n    bitmap = bitmap[:, :width].astype(np.ubyte)\n\n    left = face.glyph.bitmap_left\n    top = face.glyph.bitmap_top\n    advance = face.glyph.advance.x / 64.\n    glyph = dict(char=char, offset=(left, top), bitmap=bitmap,\n                 advance=advance, kerning={})\n    glyphs_dict[char] = glyph\n    # Generate kerning\n    for other_char, other_glyph in glyphs_dict.items():\n        kerning = face.get_kerning(other_char, char)\n        glyph['kerning'][other_char] = kerning.x / 64.\n        kerning = face.get_kerning(char, other_char)\n        other_glyph['kerning'][char] = kerning.x / 64.\n", "path": "vispy/util/fonts/_freetype.py"}]}