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

Rendering 'italic' or 'oblique' text misses fonts with 'Oblique' subfamily #235

Closed
Tontyna opened this issue Jul 8, 2024 · 3 comments · Fixed by #236
Closed

Rendering 'italic' or 'oblique' text misses fonts with 'Oblique' subfamily #235

Tontyna opened this issue Jul 8, 2024 · 3 comments · Fixed by #236

Comments

@Tontyna
Copy link
Contributor

Tontyna commented Jul 8, 2024

When TextRenderer.prepareRenderParams() sees a fontStyle of italic or oblique the FontRegistry only looks for a TrueTypeFontFile where isItalic() is True, i.e. whre the subfamily is 'Italic'.

So cursive fonts like DejaVuSans-Oblique.ttf or DejaVuSans-BoldOblique.ttf are not detected and the text is rendered 'normal'.

The spec says, that 'italic' should fall back to an 'oblique' font and 'oblique' should fall back to an 'italic' one.
Not talking about creating an artficially cursive simulation,

I think a TrueTypeFontFile->isOblique() function should be introduced and FontRegistry.findMatchingFont() should look for the fallback. Of course, its bool $italic parameter has to be adapted accordingly.

@Tontyna
Copy link
Contributor Author

Tontyna commented Jul 8, 2024

And TrueTypeFontFile->getWeight() should check for $this->subfamily === 'Bold Oblique', too.

@meyfa
Copy link
Owner

meyfa commented Jul 8, 2024

I suppose you are referring to the following part of the CSS specification: https://www.w3.org/TR/css-fonts-4/#font-style-prop

The implementation you describe sounds reasonable to me. Would you like to send a pull request with those changes? :)

@Tontyna
Copy link
Contributor Author

Tontyna commented Jul 9, 2024

PR in preparation ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants