Skip to content
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

Issue with Open Sans font in social plugin #5517

Closed
4 tasks done
croesus opened this issue May 15, 2023 · 4 comments
Closed
4 tasks done

Issue with Open Sans font in social plugin #5517

croesus opened this issue May 15, 2023 · 4 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@croesus
Copy link
Contributor

croesus commented May 15, 2023

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

example.zip

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

@squidfunk
Copy link
Owner

Thanks for reporting! The social plugin has been entirely rewritten, now even supporting entirely custom layouts, and doesn't suffer from those problems anymore. However, the community edition does, as the code base and solution predates the one we have now, and the new social plugin is currently solely available to sponsors of the project.

If you wish, you can create a PR with your changes, and we can fix the behavior in the community edition.

@croesus
Copy link
Contributor Author

croesus commented May 15, 2023

Thanks for the quick response. PR submitted.

@squidfunk
Copy link
Owner

Resolved by #5518.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label May 16, 2023
@squidfunk
Copy link
Owner

Released as part of 9.1.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants