Variable font support (#400)

* Variable font support

Here's a pretty naïve solution for variable fonts.

The iterator doesn't use the match keys' weight, but instead tries to
get the requested ideal weight, if the font is variable, otherwise it is
ignored and the actual (non-variable) weight is used. This is because I
didn't implement finding variable weight support for match keys; doing
so would be impossible without parsing TTF files when matching and I
didn't want to add that potentially expensive infrastructure if not
entirely necessary.

This is a breaking change, and I'm open for ideas on how to fix that
if it's an issue.

* cargo fmt

* Add variable font example to rich-text example
This commit is contained in:
Wren [Undefined] 2025-07-07 09:50:40 -05:00 committed by GitHub
parent d15011fba5
commit a03faa654d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 119 additions and 34 deletions

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d6f1f6a172d9e588438db9f986fd5cfad7b30f644374080a8a9d4d91e344586f
size 910252

3
fonts/InterVariable.ttf Normal file
View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4989b125924991b90d05b2d16e0e388c48f7d5bb8b30539bbf9c755278d0ccaf
size 879708