-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Social plugin: crash when all fonts are prefixed with variant #6928
Comments
Thanks for reporting. I can reproduce the problem. It does not work with the community edition, because the font management implementation is very basic. We've already made font management more resilient in Insiders as part of the latest rewrite, but there still seems to be a problem with this particular font: it seems to have another level of variants. If you run this on Insiders, you get the following files that the plugin has trouble resolving correctly:
The plugin tries to resolve layers:
...
# Page description
- size: { width: 832, height: 64 }
offset: { x: 64, y: 512 }
typography:
content: *page_description
align: start
color: *color
line:
amount: 2
height: 1.5
font:
family: *font_family
style: Regular
# style: "{{ layout.font_variant }} Regular" Now, the author would be able to set the variant in plugins:
- social:
cards_layout_options:
font_variant: 7pt This should fix the problem. Please understand that this fix will only be part of Insiders and not of the community edition, because the entire layout system has been rewritten and backporting this fix is quite impossible without releasing the entire code base right now. If you or somebody else wants to craft a PR to fix this in the community edition, we're happy to consider merging it. However, the code base of the social plugin is going to be entirely replaced in the near future when the funding goal is hit, so I'm not sure it's worth the effort. |
A simple mitigation is to use another font for generating social cards – social cards by default use the default font you specify via plugins:
- social:
cards_layout_options:
font_family: Roboto |
.cache/plugin/social/static/
Oh, and thanks for the excellent issue and reproduction! One can easily see that a lot of time went into this – this made isolating the problem and finding a fix straight forward 🚀 |
Thanks for explaining. Still glad it should result in handling an extra edge case in Insiders. I did find that mitigation myself after reporting the bug - using it currently. The custom layouts feature is pretty damn cool, I might need to look at sponsoring 👀
|
No problem, thanks! Great guide to put it together and the zipping tool is pretty handy. |
Fixed in plugins:
- social:
cards_layout_options:
font_variant: 7pt Since
The layouts that we ship with Material for MkDocs will now correctly pick plugins:
- social:
cards_layout_options:
font_variant: 10pt SemiCondensed Additionally, resilience was improved in that if the font variant/style cannot be found, the font will not only try to look for This is still not perfect, but I think we should've considerably improved the font handling logic, making it more resilient and hopefully easier to work with. I'm really looking forward to hitting the funding goals to release all of this work into the larger community We still need to add documentation for this. |
Documentation added in 8addc95. We will improve the social card guide in the future and better explain how custom layouts can be built, also adding tutorials and other resources, but for the time being this feature is documented. Inspecting the default layouts is a great idea to learn how to build custom layouts. |
Released as part of 9.5.15+insiders-4.53.3. |
Context
I'm writing a personal blog with the Blog plugin and I'm trying to generate socials cards with the socials plugin.
Running
mkdocs-material[imaging]==9.5.14
with imaging dependencies installed.Bug description
I get the following traceback when trying to build social cards using the Nunito Sans Google font:
The custom font I am using is called Nunito Sans, specified in
mkdocs.yml
like so:Building the socials cards works with the default font, and with another custom font (Lato). I think it has something do with how this particular font is downloaded. Rather than having unpacked
.tff
files under.cache/plugin/social
, most of them are instead stored in.cache/plugin/social/static/
. See below for the difference in the cache file tree:Therefore the selection of the "Regular" key isn't working because the only two files at the top level are:
NunitoSans-Italic-VariableFont_YTLC,opsz,wdth,wght.tff
NunitoSans-VariableFont_YTLC,opsz,wdth,wght.tff
I'm no expert in fonts but it seems to be a difference in the way static and variable fonts are handled that's causing this bug.
Strongly linked to #5517 and also #5201. There must be a difference in the way Nunito Sans and Open Sans are configured - maybe you have some insights @croesus as the author of the fix to #5517?
Related links
Reproduction
9.5.14-socials-breaks-with-font.zip
Steps to reproduce
Using the makefile on Linux...
make all
(installs imaging dependencies and requirements into a virtual environment- info
from the plugins inmkdocs.yml
source .venv/bin/activate
make docs
Browser
No response
Before submitting
The text was updated successfully, but these errors were encountered: