Skip to content

Make FontManager.defaultFont a property, to avoid hardcoding the prefix. #12472

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 1 commit into from
Jan 2, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Oct 10, 2018

When serialized to json, FontManager stores paths that are relative to
mpl-data (i.e. fonts shipped by Matplotlib) to relative paths; this
ensures that the resulting fontList.json stays valid across multiple
venvs (as the venv prefix does not end up in the json file).

The same issue happens with defaultFont: currently, it includes
the venv prefix. Instead of adding more layers to the json
serialization/deserialization, just don't store it into fontList.json
but compute defaultFont dynamically instead.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 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 v3.1 milestone Oct 10, 2018
Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Please add a short comment to the property that it's lazily evaluated (with font-cache) to not store the full path in the serialized object.

When serialized to json, FontManager stores paths that are relative to
mpl-data (i.e. fonts shipped by Matplotlib) to relative paths; this
ensures that the resulting fontList.json stays valid across multiple
venvs (as the venv prefix does not end up in the json file).

The same issue happens with defaultFont: currently, it includes
the venv prefix.  Instead of adding more layers to the json
serialization/deserialization, just don't store it into fontList.json
but compute defaultFont dynamically instead.
@anntzer
Copy link
Contributor Author

anntzer commented Oct 10, 2018

Done.

Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

This seems fine, though we should watch if it has odd side effects.

@jklymak jklymak merged commit 8ba0972 into matplotlib:master Jan 2, 2019
@anntzer anntzer deleted the defaultfont branch January 2, 2019 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants