-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Context
No response
Bug description
Google's Open Sans font package contains several font variations in subdirectories. The code picks the last one that ends in "-Regular.ttf" which returns an arbitrary variation based on the order the OS returns files.
Open_Sans
├── OFL.txt
├── OpenSans-Italic-VariableFont_wdth,wght.ttf
├── OpenSans-VariableFont_wdth,wght.ttf
├── README.txt
└── static
├── OpenSans
│ ├── OpenSans-Bold.ttf
│ ├── OpenSans-BoldItalic.ttf
│ ├── OpenSans-ExtraBold.ttf
│ ├── OpenSans-ExtraBoldItalic.ttf
│ ├── OpenSans-Italic.ttf
│ ├── OpenSans-Light.ttf
│ ├── OpenSans-LightItalic.ttf
│ ├── OpenSans-Medium.ttf
│ ├── OpenSans-MediumItalic.ttf
│ ├── OpenSans-Regular.ttf
│ ├── OpenSans-SemiBold.ttf
│ └── OpenSans-SemiBoldItalic.ttf
├── OpenSans_Condensed
│ ├── OpenSans_Condensed-Bold.ttf
│ ├── OpenSans_Condensed-BoldItalic.ttf
│ ├── OpenSans_Condensed-ExtraBold.ttf
│ ├── OpenSans_Condensed-ExtraBoldItalic.ttf
│ ├── OpenSans_Condensed-Italic.ttf
│ ├── OpenSans_Condensed-Light.ttf
│ ├── OpenSans_Condensed-LightItalic.ttf
│ ├── OpenSans_Condensed-Medium.ttf
│ ├── OpenSans_Condensed-MediumItalic.ttf
│ ├── OpenSans_Condensed-Regular.ttf
│ ├── OpenSans_Condensed-SemiBold.ttf
│ └── OpenSans_Condensed-SemiBoldItalic.ttf
└── OpenSans_SemiCondensed
├── OpenSans_SemiCondensed-Bold.ttf
├── OpenSans_SemiCondensed-BoldItalic.ttf
├── OpenSans_SemiCondensed-ExtraBold.ttf
├── OpenSans_SemiCondensed-ExtraBoldItalic.ttf
├── OpenSans_SemiCondensed-Italic.ttf
├── OpenSans_SemiCondensed-Light.ttf
├── OpenSans_SemiCondensed-LightItalic.ttf
├── OpenSans_SemiCondensed-Medium.ttf
├── OpenSans_SemiCondensed-MediumItalic.ttf
├── OpenSans_SemiCondensed-Regular.ttf
├── OpenSans_SemiCondensed-SemiBold.ttf
└── OpenSans_SemiCondensed-SemiBoldItalic.ttf
I've implemented a change to the social plugin that specifically matches the -Regular.ttf version in this fork. It uses os.walk() rather than glob() to find the files. Either would probably be fine but I'd implemented it before your fix for the Inter font (#5420 - see related links).
It sounds like work is in progress on the social plugin, so please let me know if you would like me to submit a PR for this or just pick it up yourself.
Related links
Reproduction
Steps to reproduce
If you add
print(f"{match.group(1)} - {font[match.group(1)]}")
on line 465 of plugin.py then run mkdocs build you get the output
...
Regular - .cache/plugin/social/static/OpenSans_Condensed/OpenSans_Condensed-Regular.ttf
...
Regular - .cache/plugin/social/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Regular.ttf
...
Regular - .cache/plugin/social/static/OpenSans/OpenSans-Regular.ttf
...
It's an accident of file ordering that the last one is the one we want, and shouldn't be relied upon.
Browser
No response
Before submitting
- I have read and followed the bug reporting guidelines.
- I have attached links to the documentation, and possibly related issues and discussions.
- I assure that I have removed all customizations before submitting this bug report.
- I have attached a .zip file with a minimal reproduction.