Closed
Description
Contribution guidelines
- I've read the contribution guidelines and wholeheartedly agree
I've found a bug and checked that ...
- ... the problem doesn't occur with the
mkdocs
orreadthedocs
themes... the problem persists when all overrides are removed, i.e.custom_dir
,extra_javascript
andextra_css
... the documentation does not mention anything about my problem... there are no open or closed issues that are related to my problem
Description
utf-8
encoding is missing missing (imho).
I think the trouble is missing encoding in ImageFont.truetype(self.font.get(700), 36, encoding="utf-8")
, however, I couldn't to fix this.
Your source link.
Expected behaviour
Correct social card =)
Actual behaviour
Russian title and description looks like squares.
Steps to reproduce
- Write
title = 'Привет мир!'
(Hello world in translation) and/ordescription = 'Привет мир!
- build
- https://cards-dev.twitter.com/validator
Package versions
Build with Github action.
I have the fork of insiders. There was last build with your hash commit (96e9a28f989abc498bc6f5ced4d0d061908c95ff
commit link)
Configuration
# Configuration
theme:
# Default values, taken from mkdocs_theme.yml
language: en
# Plugins
plugins:
- social
System information
I think, doesn't matter.
Metadata
Metadata
Assignees
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
squidfunk commentedon Oct 11, 2021
Thanks for reporting. I think the problem lies in the font that's being downloaded. Google Fonts may need to be told to download the set including the Cyrillic charset. I'll investigate asap.
squidfunk commentedon Oct 11, 2021
The problem is not what you were suspecting, but that Google Fonts provides multiple fonts for different Unicode ranges. For
Roboto
, the following ranges are available:We could, in theory, pick another font, as we're currently just picking
latin
resulting in the problem you're seeing. We can#t just pickcyrillic
, because then we can't render ASCII characters, as those are not part of the font. I'll make up my mind and see how we can gravitate towards a solution, but it's definitely a tricky one 😉squidfunk commentedon Oct 11, 2021
Okay, so it's definitely possible:
What we have to do is download the font families so they include all characters, not parse them from CSS. Unfortunately, I can't find any hint of where to programmatically download fonts, but they seem all to be hosted here:
https://github.com/google/fonts
Zilborg commentedon Oct 11, 2021
Now it's working.

I've added script to github action. But it's kludge)
squidfunk commentedon Oct 11, 2021
Perfect, I'll adjust the plugin that it uses this logic. Thanks for investigating!
squidfunk commentedon Oct 17, 2021
Fixed in
351dd162c
. Thanks again, your efforts were a huge help!The social plugin will now download the fonts from
https://fonts.google.com/download
and extract them to the.cache
folder, which ensures that the entire supported character set is available. All fonts are kept, not only the regular and bold weights. This will later allow specifying alternative font weights for different parts of the social card if desired. In the future, the social card will have more configuration options, and this is an important step in that direction 😊Furthermore, if a font doesn't include a bold variant, the social plugin will now fall back to the regular weight.
squidfunk commentedon Oct 17, 2021
Released as part of 7.3.4+insiders-3.1.4