Add initial support for variable fonts#6771
Conversation
Maybe add |
|
I might be wrong, but I was assuming that |
Optical Size is a totally different concept. Hinting is about pixels, but optical size is about adapting the design for the intended font size. The most widely used typeface with optical sizes is probably Computer Modern (no |
|
I see, thanks! |
Will the user be able to manually select these using the |
|
I don't think I will be working on this in the near future (and I also think it might be better to wait for the proper font rework and then do a proper implementation), so I'll close this in case someone else wants to work on this. |
|
Okay, thank you still for getting the ball rolling and working on the necessary infrastructure on the PDF side! |
This PR is still in-progress and aims to add some initial support for variable fonts. Initial because the aim is not to give the user full control over setting custom variation coordinates (this could be good future work, but probably makes more sense to implement in conjunction with the planned
fontobject). The aim is to automatically select a correct instance based on thewght(font weight),wdth(font stretch), andital/slnt(italic) axes, which I think should over 95%+ of the use cases.It also adds support for embedding CFF2 fonts in PDFs by converting them to a TTF font, which is not the best approach (better would be to convert to CFF), but it should do the job. CFF2 fonts are pretty rare (less than 1% of variable fonts), but based on past issues it seems like some systems do use some CFF2-based Noto fonts, so this is definitely worth fixing.
Fixes #185 (tracking support for specifying variable font axes is probably worth opening a new issue for).
Example:
Result:
test.pdf
TODOs:
wdthandslant/italicaxes.pixglyphbug that makes CFF2 fonts render as black rectangles in PNG export.