Repository navigation
Keep the collection index in fontconfig fallbacks - #3
Merged
Merged
Conversation
fc-list and the ranking against monospace named a font by file alone, so a fallback in a collection was drawn from the file's first font: bold, another family, or a box when that font lacked the character.
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.
What
With fontconfig, a character the family lacks is looked up with
fc-list :charset=Xand ranked byfc-match -s monospace. Both named fonts by file alone, so a fallback inside a collection (.ttc) was drawn from the file's first font. The result was bold text, a font from another family in the same file, or a box when that first font lacked the character.fc-match,fc-listand the ranking now ask for%{index}:%{file}, and one parser (parseFontRefs) reads all three. This finishes the collection-index fix from #2, which covered only the family's four styles.Tests
TestAFontconfigFallbackIsItsFontInACollectionbuilds a.ttcwith bold at index 0 and regular at index 1, then points fontconfig at that directory alone. fontconfig ranks the regular first, but the old code returned index 0 (bold). The test fails without the fix.TestParseFcListFilesis replaced byTestParseFontRefs, because the format the parser reads changed (contract changed). The new test also covers a path containing:and a line without an index.TestFallbackLookupsRankAgainstMonospaceOnceonly follows the new return type; the assertion is unchanged.gofmt,go vet ./...andgo test ./...pass. The font tests also pass with-count=20and-race.go vetpasses on linux, windows and the darwin library packages.