-
Notifications
You must be signed in to change notification settings - Fork 323
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
Use native font stack / remove vendored open-sans + lato fonts #285
Use native font stack / remove vendored open-sans + lato fonts #285
Conversation
See https://pydata-sphinx-theme--285.org.readthedocs.build/en/285/ for a preview cc @pradyunsg @choldgraf @hoetmaaiers If we want this, I should still remove the vendored Lato fonts. |
\o/ I like it. Thanks for getting to this @jorisvandenbossche! Turns out, preparing for a dependency resolver, triaging a flurry of issues thanks to a beta, while also moving to a new country for a new job... means that you don't have much free time. I wish me-but-two-weeks-back was smarter and more pro-active about things. :) |
I am also fine with use a native font stack 👍 |
Updated to remove the vendored fonts. One thing I noticed which I couldn't figure out yet is that the text doesn't seem to be centered anymore vertically. For example, in the navbar, on master: versus on this branch: One can also notice it for the admonition titles (with this PR): |
The issue I mentioned above about alignment being a bit "off" seems to be a general Firefox+Linux issue (I see the same issue on GitHub as well ..), see eg chakra-ui/chakra-ui#2314 or primer/css#1209 for some discussion about it. |
One of the suggestions in that thread is to use "Helvetica Neue" instead of "Helvetica", so that Firefox doesn't use the wrong fallback for "Helvetica". On Firefox+Linux, that makes things look better indeed, and Chrome+Linux, that doesn't seem to make a difference (so that's good). @choldgraf could you do a check that the demo docs with the latest commit also look OK for you? |
They look good to me 👍 |
Is this ready to merge? |
So much beautiful red! I dropped the quick note about quoting spaced font-family names, and potentially storing the fallback chain in its own variable, but otherwise LGTM. |
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.
❤️
@bollwyvl thanks for the feedback! There is one item remaining, which is the outdated documentation. Currently, we say that you can create a custom layout.html template file to override the fonts blocks:
Now, the
but you might still need to override the template if you want to include/download a custom font? |
LGTM! After this lands, we may be able to bump some performance thresholds, as loading n x [family, weight, style] files certainly wasn't free. This could be handled over #294 which adjusts some other audit-related things. |
For example if you want to add back Lato from a url? You could add
in the fonts block of the template? |
Although it seems that eg numpy does that inside the CSS: https://github.com/numpy/numpy/blob/2ea7ebdc4294868ec982ad6310d0daf6477fabfc/doc/source/_static/numpy.css#L1 (not sure which method is preferred, EDIT: although |
ahh, yes, always docs-about-docs-about-docs...
Generally, fonts a site maintainer grabs off GF or whatever come as a bundle, and they'd want to download and unpack that into However, fonts (as we've learned) are special, and a maintainer may wish to preload them, etc. which cannot be specified in CSS directly. I don't see a big win to doing that on the |
Well, GF, or worse some of the "free fontz now" sites, are a rather large privacy leak. I don't think we'd want to recommend hot-linking to any resource, from a best practices point of view. |
OK, not really sure what I should put in our docs now .. ;) Is it someting like:
? |
Started this sub-PR, but might be losing steam this evening 💤 Feel free to merge/copy/update as you see fit if i don't finish up! |
Thanks @bollwyvl ! I merged the PR to included it here. Further, I did an attempt to update the customization section about how to change the default font (based on your updates and on what we discussed above). Could you take a look at that? |
|
Update: forgot to git add the css/js ... 🤦 |
I did see it thrashing a tad, but was only touching docs so I didn't do anything 😊 . So question: while i was updating that, i talked about new icons... is there a compelling reason to not update to the latest fontawesome? the adobe icon was removed (in accordance with their brand stuff) and some unicode ranges got fixed. Also if a release is pending, the other JS deps? This could be a separate PR, of course, but the fonts at least seem germane to this topic. |
Let's keep updating other things for another PR, I would say (but don't hesitate to open one ;)) |
both better performance, and better script/glyph coverage than custom fonts, | ||
and is recommended in most cases. | ||
|
||
The default body and header fonts can be changed as follows: |
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.
@bollwyvl if you could take a quick look at this section (the text below here), that would be great
docs/user_guide/customizing.rst
Outdated
- If the font you want to specify in the section above is not generally available | ||
by default, you will additionally need to ensure the font is loaded. | ||
For example, you could download and vendor the font in the ``_static`` directory | ||
of your sphinx site, and then update the base template to load the font resources: |
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.
Capitalize sphinx? I don't know.
{% endblock %} | ||
<link rel="stylesheet" href="{{ pathto('_static/vendor/lato_latin-ext/1.44.1/index.css', 1) }}"> | ||
|
||
{% endblock %} |
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.
Perhaps concretely add:
To reduce the `Flash of Unstyled Content`, you may wish to explore various options for
`preloading content <https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content>`__,
specifically the binary font files. This ensure the files will be loaded before waiting for the CSS to be
parsed, but should be used with care.
and then in the code block
<link rel="preload" href="{{ pathto('_static/vendor/lato_latin-ext/1.44.1/files/lato-latin-ext-100-italic.woff2', 1) }}" as="font" type="font/woff2" crossorigin>
The updates look good: I added a few small comments... the preload example can be dropped, but the MDN link is probably good to work in. |
Once @bollwyvl is happy then I am happy to merge! I agree we should scope this PR cleanly and discuss other vendoring options as well 👍 let's get this merged! 🚀 |
Thanks @bollwyvl, I added your suggested text |
Hooray!
|
Closes #247