-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Added _repr_html_ for fonts #21904
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
Added _repr_html_ for fonts #21904
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted in #18039 I don't think this implementation is satisfactory; for example STIXGeneral is only provided by matplotlib on my computer and therefore trying to display in with this mechanism (which uses the browser's OS integration to lookup the font) silently renders a different font instead. I guess(?) a strategy may be to use something like https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face to explicitly specify a local font path instead.
@anntzer Thank you for the review! I agree, the prior implementation will not render the correct font. I updated the PR to load the font using font-face and updated tests. Can you take another look? |
Does this actually render the right font e.g. from a jupyter notebook? From local testing it doesn't seem so? |
I think it would be better to render to make a temporary |
@ambi7 Thank you for working on this! I hope you are not discouraged by the initial feedback. |
Yes, font-face was having issues loading fonts from file when rendering from a jupyter notebook. I took @tacaswell suggestion and rendered the font via a png image. Looks like it is now rendering the right font from a jupyter notebook by using a temporary |
…repr-html-fonts
I like png as well here, but @timhoffm didn't (#18039 (comment)). |
@timhoffm Any additional comments in regards to this implementation? |
I can see the argument for images, that decouple the font rendering from the display. So, this seems the defensive and sane approach. Still I'd like to see HiDPI-support for the rendered images, but that doesn't have to be necessarily part of this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
Cleared @anntzer 's review because it was of the "ask the browser to render it" implementation. |
The implementation has changed to render a png rather than ask the browser to find the font.
Thanks @ambi7! |
PR Summary
Resolves #18039
Invoking in IPython
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).