Preserve synthetic bold for regular-only font fallback#500
Merged
Conversation
This was referenced May 12, 2026
This was referenced May 20, 2026
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.
Preserve synthetic bold for regular-only font fallback
Related Issue
Fixes #462.
Problem
SVG text with
font-weight="bold"can render too light, and in the reported Fabric.js output it appeared clipped or visually incomplete, when the requested font family only has a regular face available. The reporter narrowed the case to Century BT fonts where no bold TTF is installed.Svg.Skia already had synthetic bold support in
SkiaModel.ApplyTypefaceAdjustments: when a shimSKPaintasks for a heavier typeface than Skia resolves, the native Skia paint enablesFakeBoldText.The issue was that
SkiaSvgAssetLoader.FindTypefacesandFindRunTypefaceconverted the resolved native typeface back into the shim typeface using the resolved face weight. If Skia resolved a regular face for a requested bold font, the retained text command later carried only the regular weight. At render timeApplyTypefaceAdjustmentsno longer saw a heavier requested weight, so synthetic bold was not enabled.Changes
FindTypefaces, used for per-span fallback.FindRunTypeface, used for full-run browser-compatible text resolution.Tests
Added
Issue462Testscovering regular-only font resolution with a requested bold shim typeface:FindTypefaces_PreservesRequestedBoldForRegularOnlyResolvedFaceFindRunTypeface_PreservesRequestedBoldForRegularOnlyResolvedFaceThe tests use the existing
SvgUnitTest.GetFontsPathfixture helper withSourceSansPro-Regular.ttfand a custom regular-only typeface provider. They verify that the shim typeface keeps the requested bold weight and that native paint conversion enablesFakeBoldText.Validation
Ran:
Results:
Svg.Skia.csprojRelease build passed with 0 warnings and 0 errors.Notes
The full solution build was not used as the final validation boundary because this local checkout was missing restored assets for many unrelated projects and the local SDK environment lacks .NET Framework 4.6.1 reference assemblies. The changed project and focused regression coverage both pass.