Repository navigation
Conversation
The managed font reader now handles variable OpenType fonts. The named
instances of a variable font become faces of their own, with family names
as GDI makes them ("Bahnschrift Light Condensed", "Segoe UI Variable
Display Semibold"), so these fonts no longer fall back to their default
instance or, for CFF2, disappear from the font list.
- FontVariations parses fvar, avar, the gvar header and HVAR, normalizes
user coordinates and computes tuple scalars like fontTools'
supportScalar (peak and intermediate regions).
- TrueType outlines: gvar deltas with shared and private point numbers,
packed deltas, interpolation of untouched points (IUP), phantom points
and the offsets of composite components.
- CFF2 outlines: 32-bit INDEX counts, the Top DICT outside an INDEX,
FDSelect format 4, vsindex and blend with the ItemVariationStore.
- Advance widths come from HVAR, or from the phantom points without HVAR.
They are not rounded. MVAR is not applied.
The test fonts are subsets of Source Sans 3 VF (OFL-1.1), renamed to
"VarTest Sans" because "Source" is a Reserved Font Name. Their reference
outlines and advance widths were written with fontTools.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YXvDW91oXpy7RquGHNxgR5
…412) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YXvDW91oXpy7RquGHNxgR5
This branch has not been deployed
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.
Part of #412, step 6 (fonts). This PR is stacked on #470 (CFF outlines). Its base is
feature/cff-outlines, so the diff shows only the variable font work. It will be retargeted once #470 is merged.What changes
ManagedFontProvidernow reads variable OpenType fonts. Each named instance of a variable font becomes a face of its own, named the way GDI names it:This removes the limitation described in #468:
Parsing
FontVariations(new, internal) parses fvar, avar, the gvar header and HVAR. It normalizes user coordinates through avar and computes tuple scalars with the same semantics as fontTools'supportScalar, covering both peak and intermediate regions.CffOutlines: 32-bit INDEX counts, the Top DICT outside an INDEX, FDSelect format 4,vsindexandblendwith the ItemVariationStore.TrueTypeFontgets internalIsVariable,Axes,NamedInstances,NormalizedCoordinatesandWithVariation(double[]).GetAdvanceWidthnow returnsdouble.Not included
STAT, as Windows does.WithVariationis internal.Public API
No public API is removed or changed.
ManagedFontProvidersimply lists more faces than before.Tests
Test fonts are in
tests/CADability.Tests/Files/Fonts/:VarTestSans.ttf(gvar + HVAR),VarTestSans-NoHVAR.ttf(phantom-point advances) andVarTestSans.otf(CFF2).source-sans. They are renamed to "VarTest Sans" because "Source" is a Reserved Font Name.make_variable_test_fonts.pycreates the fonts and writes their reference outlines and advance widths with fontTools.VariableFontTestschecks:Mutation checks that make tests fail:
blendignoring deltas;Beyond the test subsets, the full Source Sans 3 VF fonts (Upright and Italic, TTF and OTF; 2,750 glyphs each at 11 locations) were compared against fontTools with a local harness:
Locally, all 657 tests of CADability.Tests pass (12 skipped, Windows only), and all 88 tests of CADability.ImportTests pass. CADability.Forms builds.
A second commit corrects the documentation of
HasOutlinesandHasCffOutlines, which still said that CFF2 cannot be read.🤖 Generated with Claude Code
https://claude.ai/code/session_01YXvDW91oXpy7RquGHNxgR5