Skip to content

Cache paths of fonts shipped with mpl relative to the mpl data path. #10245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 9, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jan 14, 2018

This lets the font cache stay valid across multiple virtualenvs (as long
as the list of fonts shipped by mpl does not change).

xref #10201.

As a side note note the previously buggy line if fname.lower().find('DejaVuSans.ttf')>=0 which would always return False...

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer added this to the v2.2 milestone Jan 21, 2018
@anntzer anntzer modified the milestones: needs sorting, v3.0 Feb 26, 2018
@anntzer anntzer force-pushed the fontmanager-relpath branch 3 times, most recently from d9ad3ba to cd87892 Compare April 24, 2018 20:05
@anntzer anntzer added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Jul 7, 2018
@anntzer
Copy link
Contributor Author

anntzer commented Jul 7, 2018

I think the gain of keeping the fontcache across venvs is nice enough to mark this as RC.

@tacaswell
Copy link
Member

I think we need to add the matplotlib version number to the file incase we change the fonts we ship between versions again (to support multiple matplotlib versions across multiple venvs).

@anntzer anntzer force-pushed the fontmanager-relpath branch from cd87892 to 0a80831 Compare July 8, 2018 22:17
@anntzer
Copy link
Contributor Author

anntzer commented Jul 8, 2018

Done as a separate commit. Now also closes #4993 (until we decide to also change the format of the tex cache...).

@tacaswell
Copy link
Member

" exited with 0.
53.00s$ if [[ $RUN_FLAKE8 == 1 ]]; then
  flake8 --statistics && echo "Flake8 passed without any issues!"
fi
./lib/matplotlib/font_manager.py:0:1: X100 Superfluous per-file-ignores for E225
1     X100 Superfluous per-file-ignores for E225

Cleaned up too much style!

Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modulo removing the flake8 exception.

anntzer added 2 commits July 9, 2018 09:56
This lets the font cache stay valid across multiple virtualenvs (as long
as the list of fonts shipped by mpl does not change).
@anntzer anntzer force-pushed the fontmanager-relpath branch from 0a80831 to 9f821d1 Compare July 9, 2018 07:56
@anntzer
Copy link
Contributor Author

anntzer commented Jul 9, 2018

done

d["fname"] = str(
Path(d["fname"]).relative_to(mpl.get_data_path()))
except ValueError:
pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One concern is that are we sure every path we see here will be absolute?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fontconfig returns absolute paths, and we call os.path.abspath in findSystemFonts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: text
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants