Repository navigation
Fonts: fractional sizes, variable font axes, OpenType features and letter spacing - #712
Merged
Merged
Conversation
botoddly
marked this pull request as draft
November 10, 2026 15:08
… scaled fonts only rescale the letter spacing
…nd guard released fonts and out-of-range scales
stanoddly
marked this pull request as ready for review
November 10, 2026 15:22
stanoddly
marked this pull request as draft
November 10, 2026 15:22
botoddly
marked this pull request as ready for review
November 10, 2026 15:51
|
📦 Development package |
|
✅ Development package validation passed on all platforms. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #709.
IFontSystem.Loadtakes afloatsize and three new optional settings:FontVariation(tag, value)sets any axis, such as weight 200 or 600 from one file. Values clamp to the axis's range. An axis the font lacks throws.FontFeature(tag, value = 1), such astnumfor tabular figures orligawith 0 to turn ligatures off.The settings are part of the font's cache key, because SDL_ttf keeps them per
TTF_Font. A label gets them by taking a font loaded with them. Lists that differ only in order, or in an overridden tag, load the sameFont.Fontreports each setting, andFont.Sizeis now afloat. A scaled font fromFont.GetScaled(#711) is aTTF_CopyFont, which keeps the variations, features and spacing since XDL 3.4.20-12. Pixely only multiplies the copy's letter spacing by the scale.main's scaled-font tests skipped without an outline font, and now run on Cantarell.They come from XDL's additions to SDL_ttf (stanoddly/XDL#29, with
TTF_CopyFontcopying them since stanoddly/XDL#30), bound in XdlSharp (stanoddly/XdlSharp#4, #5). This PR pins XdlSharp 3.4.20.4, which carries XDL 3.4.20-12.StubFontSystemchecks the same arguments but not against a font file, and none of them changes its metrics.Docs:
docs/fonts.mdcovers each setting with examples, anddocs/testing.md,AGENTS.mdand aDECISIONS.mdentry are updated.Tests
FontSystemTestsuses Cantarell VF 0.301 (OFL, notice intests/Pixely.Tests/THIRD-PARTY-NOTICES.md). Its figures are proportional and it has a weight axis from 100 to 800.14.67 px measures narrower than 15 px.
With
tnum, "1111.11" and "8888.88" measure the same. Without it they differ.Weight 200 and 600 from one file:
TTF_GetFontWeightreports each, and 600 covers more pixels when rendered.Letter spacing of 2 px widens "Hello" by 10 px, and -0.5 px narrows it.
Errors: an unknown axis, variations on a bitmap font, a fractional bitmap size, invalid sizes, spacing, tags and values.
Caching: settings, normalized lists and release.
A scaled font keeps weight 600 and
tnum, and its spacing doubles at a scale of 2. This test fails on XDL 3.4.20-11, where it gets weight 400 instead of 600.Scaled fonts at a fractional loaded size, such as 14.67 px:
GetScaled(1)returns the loaded font, a scaled font releases with it, and sizes below 1 px share the 1 px face.Scaled-font fixes from the review
These also cover behavior from #711:
GetScaledthrowsObjectDisposedExceptionfor a released font, where it read freed memory before. It also rejects a scaled size above 65535 px.Disposecloses nothing, and keeps a font loaded again since in the cache.Locally,
Pixely.Tests,Pixely.Testing.TestsandPixely.Ui.Testspass against a local pack with XDL 3.4.20-12'slibXDL3_ttf.so. CI needs XdlSharp 3.4.20.4 on nuget.org, so this PR stays a draft until it is listed.