Skip to content

Fix fallback font chain not persistence when specified weight#116

Merged
HelloYeew merged 3 commits into
mainfrom
font-fallback-fix
Jun 22, 2026
Merged

Fix fallback font chain not persistence when specified weight#116
HelloYeew merged 3 commits into
mainfrom
font-fallback-fix

Conversation

@HelloYeew

Copy link
Copy Markdown
Owner

Now if the requested font with that weight is not available it will start looking in fallback chain. This also applied in the icon usage too since our icon usage built on top of font renderer. So if you render mix of normal text and icon (using char.ConvertFromUtf32) with "bold" weight, in the icon part it will finding the "MaterialIcon-Bold" that we don't have since we only have regular, this PR make the fallback more weight-tolerant by make it look for regular weight instead too.

Also since I use mix of icon and text in SpriteText so I add a new extension for IconUsage for make my sanity better in char.ConvertFromUtf32 everywhere.

// before
Text = $"Play {char.ConvertFromUtf32((int)IconUsage.PlayArrow))}
// new
Text = $"Play {IconUsage.PlayArrow.ToGlyph()}

@HelloYeew HelloYeew merged commit 8a0ae17 into main Jun 22, 2026
1 check passed
@HelloYeew HelloYeew deleted the font-fallback-fix branch June 22, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant