matplotlib/cheatsheets

Issue with build process

btharbaugh opened this issue · 14 comments

I am attempting to build this repo with gitbash in Windows 10 pro. I have cloned the repo to a folder /git/cheatsheets and created /git/cheatsheets/fonts with all the required sub-folders as described in the README. However, when running the python scripts in the scripts directory I am getting a failure of

"findfont: Font family ['Source Code Pro'] not found. Falling back to DejaVu Sans."

I am guessing I have put the fonts folder in the wrong location and/or finding the fonts on the Windows file system is not working as expected.

Any help would be appreciated.

To build, you need to create the directories with the various fonts inside the font directory. For example, this a view of my font directory:

drwxr-xr-x@  8 rougier  staff  256 Jun 25 07:50 delicious-123/
drwxr-xr-x  21 rougier  staff  672 May  5 18:10 roboto/
drwxr-xr-x  13 rougier  staff  416 Jun 27 08:16 roboto-mono/
drwxr-xr-x  15 rougier  staff  480 Jun 27 07:46 roboto-slab/
drwxr-xr-x  17 rougier  staff  544 May  5 18:10 source-code-pro/
drwxr-xr-x  16 rougier  staff  512 May  5 18:10 source-sans-pro/
drwxr-xr-x  15 rougier  staff  480 May  5 18:10 source-serif-pro/

Yes, I am aware. That’s why I said I made the directory and sub directories. Mine looks the same with the exception of roboto-mono, that font I did not add.

Other fonts are ok ? The definition is similar to other fonts and I don't see what can be different.

No. Every font has the same error message. I only posted the one error message; but it appears every time it tries to use one of the custom fonts it fails.

Are the requested fonts all there? I think I yesterday had a similar problem where the downloaded font file did not include all the needed variants?

Anyway, this should be solved by #32 (comment).

The only font that is missing is the beautiful-123. But it never complained about that. The errors complain about Source Code Pro, Source Sans Pro and Source Serif Pro. The scripts run, but they all revert to some default font. Which, really isn't a huge deal, but if the scripts are looking somewhere else for the fonts I'd like to know where they should be.

Yes, I am facing the same issue. It is always complaining about 'Source Code Pro', 'Source Sans Pro', 'Source Serif Pro' and it is falling back into 'Dejavu Sans'. So are the scripts not looking into the fonts or Is my directory wrong?

@btharbaugh @jithendrabsy I guess you've download the fonts and put them a the relevant places. What is the xelatex message exactly ?

Hi,

I tried to build the cheatsheets myself and encountered the same error as mentioned above.
Here's an attempt to solve them.

It looks like Matplotlib is not aware of the fonts in the fonts directory. As requested in step 1, I downloaded all zip files containing the fonts in the fonts directory but then I added them all to my local font directory:

$ mkdir -p ~/.local/share/fonts/
$ cd fonts
$ for name in *.zip; do unzip ${name} -d ~/.local/share/fonts/; done

And then refresh the font list:

$ fc-cache -f -v

I also advise to clean Matplotlb cache:

$ rm -fr ~/.cache/matplotlib

Running all Python scripts in step 2 should now be OK.

By the way, I could be useful to define all dependencies before running these scripts, for instance with a conda environment:

$ conda create -n matplotlib-cheatsheets numpy matplotlib cartopy scipy
$ conda activate matplotlib-cheatsheets

Since the Roboto condensed font is also missing, It worth adding it to step 1:

In step 3, even if I created the required fonts directory and its sub-directories, I had the following error:

$ xelatex cheatsheet.tex
[blablabla]

(/usr/share/texlive/texmf-dist/tex/latex/microtype/microtype-xetex.def)
(/usr/share/texlive/texmf-dist/tex/latex/microtype/microtype.cfg))kpathsea:make_tex: Invalid filename `[fonts/source-serif-pro/SourceSerifPro-Light.otf]/OT', contains '['


! Package fontspec Error: The font "Light" cannot be found.

For immediate help type H <return>.
 ...                                              
                                                  
l.58   BoldItalicFont = It]

xelatex was looking for SourceSerifPro-Light.otf that was not provided in the zip file I downloaded from Google Font 😨

$ ls fonts/source-serif-pro/ -1
OFL.txt
SourceSerifPro-BlackItalic.ttf
SourceSerifPro-Black.ttf
SourceSerifPro-BoldItalic.ttf
SourceSerifPro-Bold.ttf
SourceSerifPro-ExtraLightItalic.ttf
SourceSerifPro-ExtraLight.ttf
SourceSerifPro-Italic.ttf
SourceSerifPro-LightItalic.ttf
SourceSerifPro-Light.ttf
SourceSerifPro-Regular.ttf
SourceSerifPro-SemiBoldItalic.ttf
SourceSerifPro-SemiBold.ttf

In cheatsheets.tex, I modified the line:

  Path = fonts/source-serif-pro/SourceSerifPro-, Extension = .otf,

by

  Path = fonts/source-serif-pro/SourceSerifPro-, Extension = .ttf,

but xelatex then complained again with:

! Package fontspec Error: The font "LightIt" cannot be found.

For immediate help type H <return>.
 ...                                              
                                                  
l.58   BoldItalicFont = It]

So I came back to the first trick I used with Matplotlib: use the user-wise fonts. I replaced lines 53--82 of cheatsheets.tex with:

\setmainfont{Source Serif Pro}
\setsansfont{Roboto}
\setmonofont{Source Code Pro}
\newfontfamily\RobotoCon{Roboto Condensed}
\newfontfamily\RobotoSlab{Roboto Slab}
\newfontfamily\Roboto{Roboto}

I compiled well up to this error:

LaTeX Warning: File `fonts.pdf' not found on input line 781.

! Unable to load picture or PDF file 'fonts.pdf'.
<to be read again> 
                   }
l.781 ...degraphics[width=\columnwidth]{fonts.pdf}

I didn't find the file in the figures directory. Is it missing?

@rougier what do you think?

  • Is the installation of the fonts user-wise with fc-cache -f -v a good or bad idea?
  • Is the file fonts.pdf missing?

@pierrepo The reason was a typo in gitignote that prevented fonts.py to be considered by git.

Can anyone comment on whether the Makefile added in #57 helps with the build process.

@jimustafa Yes, the Makefile works just fine 👍.

Great! Hey @rougier, hopefully this issue can now be closed.