Faux italic when the font does not support it#542
Conversation
3dfb51e to
e162989
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #542 +/- ##
=====================================
Coverage 84% 84%
=====================================
Files 332 332
Lines 24684 24708 +24
Branches 3612 3618 +6
=====================================
+ Hits 20785 20813 +28
+ Misses 3011 3009 -2
+ Partials 888 886 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
JimBobSquarePants
left a comment
There was a problem hiding this comment.
Thanks for this. I’m going to accept this PR with a caveat.
The approach is directionally correct: synthetic italic belongs in Fonts rather than in individual renderers, and the chosen skew is close to browser/Skia behavior. Chromium/Skia use a 1/4 skew for synthetic italic, which is approximately a 14 degree slant, and synthetic italic should not change advance width.
I’ll likely need to adjust this after merging into my local branch because the rendering path has changed there, but the behavior this PR is aiming for is the behavior I want.
|
Thank you, looking forward to seeing the new rendering branch (ImageSharp has among the best code I've seen, so I'm always keen to learn from it!) |
Prerequisites
Description
Some fonts may not provide native italic, and most text rendering engines will fallback to faux-italic (simply slant the text). ImageSharp does not provide that function, which means italic text is simply rendered upright. The italic slant specifications are vague, but the default seems to be 14 degrees (https://www.w3.org/TR/css-fonts-4/).
Disclaimer: this code was written using AI (Copilot with Claude Opus 4.8), and reviewed by me.
This solves the italic part of SixLabors/ImageSharp.Drawing#408 - the weight (bold) may be a bit more complex and will be provided as a separate PR.