Hack up python-gi more to make spline UI work again

This patch should fix the following error when running the spline UI:

    $ bazel run -c opt frc971/control_loops/python:spline_graph
    ...
    (spline_graph.py:1566468): Pango-WARNING **: 15:38:14.022: failed to create cairo scaled font, expect ugly output. the offending font is 'FreeMono 9.9990234375'

    (spline_graph.py:1566468): Pango-WARNING **: 15:38:14.022: font_face status is: file not found

    (spline_graph.py:1566468): Pango-WARNING **: 15:38:14.022: scaled_font status is: file not found

    (spline_graph.py:1566468): Pango-WARNING **: 15:38:14.023: failed to create cairo scaled font, expect ugly output. the offending font is 'FreeMono 9.9990234375'

    (spline_graph.py:1566468): Pango-WARNING **: 15:38:14.023: font_face status is: file not found

    (spline_graph.py:1566468): Pango-WARNING **: 15:38:14.023: scaled_font status is: file not found

I'm not happy with the patch, but it's the best I could come up with.
The challenge is that when the fonts were getting cached (by who knows
what), they get stored as fake absolute paths that are relative to the
runfiles directory. For example, instead of the following path:

    /bazel-cache/phil/bazel/_bazel_phil/32b4413f2be52d89dcb7e47a312ea96e/execroot/org_frc971/bazel-out/k8-opt/bin/frc971/control_loops/python/spline_graph.runfiles/org_frc971/external/matplotlib_repo/usr/share/fonts/truetype/freefont/FreeMonoOblique.ttf

the cache contains this path:

    /usr/share/fonts/truetype/freefont/FreeMonoOblique.ttf

As far as I can tell it's because of the `FONTCONFIG_SYSROOT` setting.

Then pango at a later time tries to load this font as an absolute
path which doesn't exist on the host system. So the hacky approach
here is to store the absolute paths in the font cache so that pango
can resolve them properly.

Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I41411f826a51ec3dc88db1a68cd8ffc0fb041444
diff --git a/debian/python_gi_init.patch b/debian/python_gi_init.patch
index 76e5c40..50cb6ac 100644
--- a/debian/python_gi_init.patch
+++ b/debian/python_gi_init.patch
@@ -1,6 +1,6 @@
 --- a/__init__.py	1969-12-31 16:00:00.000000000 -0800
 +++ b/__init__.py	2018-10-17 21:45:04.908201161 -0700
-@@ -29,6 +29,19 @@ import os
+@@ -29,6 +29,22 @@ import os
  import importlib
  import types
  
@@ -12,7 +12,10 @@
 +# Tell fontconfig where to find the sandboxed font files.
 +os.environ["FONTCONFIG_PATH"] = os.path.join(_base, "etc/fonts/")
 +os.environ["FONTCONFIG_FILE"] = os.path.join(_base, "etc/fonts/fonts.conf")
-+os.environ["FONTCONFIG_SYSROOT"] = _base
++# The sysroot here needs to be "/". If it were _base, then the font caches
++# would contain _base-relative paths in them. Unfortunately pango interprets
++# those as absolute paths and ends up failing to find all fonts.
++os.environ["FONTCONFIG_SYSROOT"] = "/"
 +os.environ["GDK_PIXBUF_MODULEDIR"] = os.path.join(_base, "rpathed", "usr", "lib", "x86_64-linux-gnu", "gdk-pixbuf-2.0", "2.10.0", "loaders")
 +os.environ["GDK_PIXBUF_MODULE_FILE"] = os.path.join(os.environ["GDK_PIXBUF_MODULEDIR"], "loaders.cache")
 +os.system(os.path.join(_base, "usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders") + " --update-cache")