'Trying to change Google Colab font family to Arial
I am trying to use the Arimo-font in Google Colab. I´ve been using some code that I got from a SO post:
from matplotlib import font_manager as fm, pyplot as plt
### Downloading Arial-like font from googles github page
!wget https://github.com/google/fonts/blob/
f6d3dee82ebbc3bec83e78e200f6d0b62a9d702e/apache/arimo/Arimo%5Bwght%5D.ttf
font_files = fm.findSystemFonts('.')
# Go through and add each to Matplotlib's font cache.
for font_file in font_files:
fm.fontManager.addfont(font_file)
Use your new font on all your plots.
plt.rc('font', family='Open Sans')
But when I do this, I get the error:
RuntimeError Traceback (most recent call last)
<ipython-input-20-d9d8c3099d94> in <module>()
8 # Go through and add each to Matplotlib's font cache.
9 for font_file in font_files:
---> 10 fm.fontManager.addfont(font_file)
11
12 # Use your new font on all your plots.
/usr/local/lib/python3.7/dist-packages/matplotlib/font_manager.py in addfont(self, path)
1011 self.afmlist.append(prop)
1012 else:
-> 1013 font = ft2font.FT2Font(path)
1014 prop = ttfFontProperty(font)
1015 self.ttflist.append(prop)
RuntimeError: In FT2Font: Can not load face. Unknown file format.
What is this error and how can I remove it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|