Repository navigation
cobalt: Restore Cobalt 25 synthetic bold for fallback fonts - #13714
Merged
Merged
Conversation
Contributor
|
Contributor
🤖 Gemini Suggested Commit Message💡 Pro Tips for a Better Commit Message:
|
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the font synthesis logic in font_cache_starboard.cc to mirror the standard Blink behavior, ensuring that synthetic bold and italic styles are applied when fallback typefaces do not meet the requested weight or style. The review feedback correctly identifies an issue where using the > operator instead of >= prevents synthetic bold from being applied when the requested weight is exactly 200 units heavier than the typeface (such as requesting Semi-Bold 600 with a Regular 400 fallback). Updating this operator to >= will resolve this issue.
FontCache::PlatformFallbackFontForCharacter on Starboard only enabled
synthetic bold when FontDescription::IsSyntheticBold() was set, which is
not the case for an ordinary CSS `font-weight: bold`. Text that resolves
via character fallback to a Regular-only face (e.g. CJK via
NotoSansCJK-Regular) was therefore never emboldened, a regression from
Cobalt 25.
Restore the Cobalt 25 rule (text_shaper.cc ShouldEmbolden):
- Blink: synthesize bold when the requested weight is bold
(isFontWeightBold(), i.e. >= kBoldThreshold; Cobalt 25 used `> 500`
on a 100-step weight enum, which is equivalent) and the typeface is
not bold (SkTypeface::isBold()).
- SkTypeface_Cobalt: drop SkFont embolden for typefaces that do not
synthesize bold, so `disable_synthetic_bolding` in fonts.xml (e.g.
NotoColorEmoji, DroidSansFallback) is honored again. It was parsed
but unused in Cobalt 27.
Italic synthesis is unchanged (Cobalt 25 did not synthesize italic).
Bug: 577839103
TAG=agy
CONV=aa9a1512-4172-4d51-a830-f0632fee17fa
andrewsavage1
force-pushed
the
fix-cjk-synthetic-bold
branch
from
October 29, 2026 14:35
1ee2ae6 to
b4ed645
Compare
jellefoks
approved these changes
Oct 30, 2026
jellefoks
left a comment
Member
There was a problem hiding this comment.
Nice fix! Just a couple of small comments, otherwise LGTM.
Add SkFontMgr_cobalt unit tests verifying that SkFont::setEmbolden widens glyphs of a Regular typeface but is ignored for Bold typefaces and for typefaces marked disable_synthetic_bolding in fonts.xml. Add FontCache tests for synthetic bold on character fallback. Remove the now-unused SkTypeface_Cobalt::synthesizes_bold() getter. Bug: 577839103
andrewsavage1
enabled auto-merge (squash)
November 2, 2026 15:18
cobalt-github-releaser-bot
pushed a commit
that referenced
this pull request
Nov 2, 2026
…allback fonts Refer to original PR: #13714 `FontCache::PlatformFallbackFontForCharacter` on Starboard only enabled synthetic bold when `FontDescription::IsSyntheticBold()` was set. That flag is not set for an ordinary CSS `font-weight: bold`, so text that resolves via character fallback to a Regular-only face (e.g. CJK via `NotoSansCJK-Regular`, weight 400) was never emboldened. This is a regression from Cobalt 25. This restores the Cobalt 25 rule from `cobalt/renderer/rasterizer/skia/text_shaper.cc` (`ShouldEmbolden`): ```cpp if (font_provider->style().weight > 500) // 100-step weight enum return typeface->synthesizes_bold(); // !isBold() && !disable_synthetic_bolding ``` - **Blink** (`font_cache_starboard.cc`): synthesize bold when `isFontWeightBold(weight)` (Blink's `kBoldThreshold` = 600, equivalent to C25's `> 500` on its 100-step enum) and `!typeface->isBold()` (same Skia check C25 used). - **SkTypeface_Cobalt**: override `onFilterRec` to drop `kEmbolden_Flag` when `!synthesizes_bold_`, so the `disable_synthetic_bolding` fonts.xml attribute (NotoColorEmoji, DroidSansFallback) is honored again. It was parsed but unused in Cobalt 27. - Italic synthesis is unchanged (C25 did not synthesize italic). ### Testing RDK (`evergreen-arm-hardfp-rdk_qa`), page rendering the ETC Localization strings at weight 400 vs 700 and comparing inked pixels via canvas: | Locale | Before | After | After, CJK marked `disable_synthetic_bolding` | |---|---|---|---| | zh-TW 開朗 | 1.000 | 1.589 | 1.000 | | ko 밝음 | 1.000 | 1.620 | 1.000 | | zh 欢快 | 1.000 | 1.633 | 1.000 | | zh-HK 樂觀 | 1.000 | 1.610 | 1.000 | | en Bright | 1.479 | 1.479 | 1.479 | Bug: 577839103 TAG=agy CONV=aa9a1512-4172-4d51-a830-f0632fee17fa (cherry picked from commit 2ddebfe)
This was referenced Nov 2, 2026
cobalt-github-releaser-bot
pushed a commit
that referenced
this pull request
Nov 3, 2026
…allback fonts Refer to original PR: #13714 `FontCache::PlatformFallbackFontForCharacter` on Starboard only enabled synthetic bold when `FontDescription::IsSyntheticBold()` was set. That flag is not set for an ordinary CSS `font-weight: bold`, so text that resolves via character fallback to a Regular-only face (e.g. CJK via `NotoSansCJK-Regular`, weight 400) was never emboldened. This is a regression from Cobalt 25. This restores the Cobalt 25 rule from `cobalt/renderer/rasterizer/skia/text_shaper.cc` (`ShouldEmbolden`): ```cpp if (font_provider->style().weight > 500) // 100-step weight enum return typeface->synthesizes_bold(); // !isBold() && !disable_synthetic_bolding ``` - **Blink** (`font_cache_starboard.cc`): synthesize bold when `isFontWeightBold(weight)` (Blink's `kBoldThreshold` = 600, equivalent to C25's `> 500` on its 100-step enum) and `!typeface->isBold()` (same Skia check C25 used). - **SkTypeface_Cobalt**: override `onFilterRec` to drop `kEmbolden_Flag` when `!synthesizes_bold_`, so the `disable_synthetic_bolding` fonts.xml attribute (NotoColorEmoji, DroidSansFallback) is honored again. It was parsed but unused in Cobalt 27. - Italic synthesis is unchanged (C25 did not synthesize italic). ### Testing RDK (`evergreen-arm-hardfp-rdk_qa`), page rendering the ETC Localization strings at weight 400 vs 700 and comparing inked pixels via canvas: | Locale | Before | After | After, CJK marked `disable_synthetic_bolding` | |---|---|---|---| | zh-TW 開朗 | 1.000 | 1.589 | 1.000 | | ko 밝음 | 1.000 | 1.620 | 1.000 | | zh 欢快 | 1.000 | 1.633 | 1.000 | | zh-HK 樂觀 | 1.000 | 1.610 | 1.000 | | en Bright | 1.479 | 1.479 | 1.479 | Bug: 577839103 TAG=agy CONV=aa9a1512-4172-4d51-a830-f0632fee17fa (cherry picked from commit 2ddebfe)
briantting
pushed a commit
that referenced
this pull request
Nov 3, 2026
…allback fonts Refer to original PR: #13714 `FontCache::PlatformFallbackFontForCharacter` on Starboard only enabled synthetic bold when `FontDescription::IsSyntheticBold()` was set. That flag is not set for an ordinary CSS `font-weight: bold`, so text that resolves via character fallback to a Regular-only face (e.g. CJK via `NotoSansCJK-Regular`, weight 400) was never emboldened. This is a regression from Cobalt 25. This restores the Cobalt 25 rule from `cobalt/renderer/rasterizer/skia/text_shaper.cc` (`ShouldEmbolden`): ```cpp if (font_provider->style().weight > 500) // 100-step weight enum return typeface->synthesizes_bold(); // !isBold() && !disable_synthetic_bolding ``` - **Blink** (`font_cache_starboard.cc`): synthesize bold when `isFontWeightBold(weight)` (Blink's `kBoldThreshold` = 600, equivalent to C25's `> 500` on its 100-step enum) and `!typeface->isBold()` (same Skia check C25 used). - **SkTypeface_Cobalt**: override `onFilterRec` to drop `kEmbolden_Flag` when `!synthesizes_bold_`, so the `disable_synthetic_bolding` fonts.xml attribute (NotoColorEmoji, DroidSansFallback) is honored again. It was parsed but unused in Cobalt 27. - Italic synthesis is unchanged (C25 did not synthesize italic). ### Testing RDK (`evergreen-arm-hardfp-rdk_qa`), page rendering the ETC Localization strings at weight 400 vs 700 and comparing inked pixels via canvas: | Locale | Before | After | After, CJK marked `disable_synthetic_bolding` | |---|---|---|---| | zh-TW 開朗 | 1.000 | 1.589 | 1.000 | | ko 밝음 | 1.000 | 1.620 | 1.000 | | zh 欢快 | 1.000 | 1.633 | 1.000 | | zh-HK 樂觀 | 1.000 | 1.610 | 1.000 | | en Bright | 1.479 | 1.479 | 1.479 | Bug: 577839103 TAG=agy CONV=aa9a1512-4172-4d51-a830-f0632fee17fa (cherry picked from commit 2ddebfe)
andrewsavage1
added a commit
that referenced
this pull request
Nov 24, 2026
…allback fonts (#13714) (#14234) Refer to original PR: #13714 `FontCache::PlatformFallbackFontForCharacter` on Starboard only enabled synthetic bold when `FontDescription::IsSyntheticBold()` was set. That flag is not set for an ordinary CSS `font-weight: bold`, so text that resolves via character fallback to a Regular-only face (e.g. CJK via `NotoSansCJK-Regular`, weight 400) was never emboldened. This is a regression from Cobalt 25. This restores the Cobalt 25 rule from `cobalt/renderer/rasterizer/skia/text_shaper.cc` (`ShouldEmbolden`): ```cpp if (font_provider->style().weight > 500) // 100-step weight enum return typeface->synthesizes_bold(); // !isBold() && !disable_synthetic_bolding ``` - **Blink** (`font_cache_starboard.cc`): synthesize bold when `isFontWeightBold(weight)` (Blink's `kBoldThreshold` = 600, equivalent to C25's `> 500` on its 100-step enum) and `!typeface->isBold()` (same Skia check C25 used). - **SkTypeface_Cobalt**: override `onFilterRec` to drop `kEmbolden_Flag` when `!synthesizes_bold_`, so the `disable_synthetic_bolding` fonts.xml attribute (NotoColorEmoji, DroidSansFallback) is honored again. It was parsed but unused in Cobalt 27. - Italic synthesis is unchanged (C25 did not synthesize italic). ### Testing RDK (`evergreen-arm-hardfp-rdk_qa`), page rendering the ETC Localization strings at weight 400 vs 700 and comparing inked pixels via canvas: | Locale | Before | After | After, CJK marked `disable_synthetic_bolding` | |---|---|---|---| | zh-TW 開朗 | 1.000 | 1.589 | 1.000 | | ko 밝음 | 1.000 | 1.620 | 1.000 | | zh 欢快 | 1.000 | 1.633 | 1.000 | | zh-HK 樂觀 | 1.000 | 1.610 | 1.000 | | en Bright | 1.479 | 1.479 | 1.479 | Bug: 577839103 TAG=agy CONV=aa9a1512-4172-4d51-a830-f0632fee17fa (cherry picked from commit 2ddebfe) --- Manual cherry-pick to staging. The first commit is the bot-style CONFLICTED cherry-pick, and the second resolves the conflicts against current staging: Conflicts in SkTypeface_cobalt.{h,cc} were signature drift only: staging's Skia uses the SkSpan-based onCharsToGlyphs. Kept staging's SkSpan onCharsToGlyphs declaration/definition and added the PR's onFilterRec override (plus SkScalerContext.h include), and dropped the unused synthesizes_bold() accessor as the PR does. In SkFontMgr_cobalt_unittest.cc, replaced the removed pointer/count SkFont::getBounds overload with the single-glyph getBounds(glyph, paint) form available on staging. When squash-merging, keep this description as the commit message so the 'Refer to original PR' and 'cherry picked from' lines stay in staging's history.
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.
FontCache::PlatformFallbackFontForCharacteron Starboard only enabled synthetic bold whenFontDescription::IsSyntheticBold()was set. That flag is not set for an ordinary CSSfont-weight: bold, so text that resolves via character fallback to a Regular-only face (e.g. CJK viaNotoSansCJK-Regular, weight 400) was never emboldened. This is a regression from Cobalt 25.This restores the Cobalt 25 rule from
cobalt/renderer/rasterizer/skia/text_shaper.cc(ShouldEmbolden):font_cache_starboard.cc): synthesize bold whenisFontWeightBold(weight)(Blink'skBoldThreshold= 600, equivalent to C25's> 500on its 100-step enum) and!typeface->isBold()(same Skia check C25 used).onFilterRecto dropkEmbolden_Flagwhen!synthesizes_bold_, so thedisable_synthetic_boldingfonts.xml attribute (NotoColorEmoji, DroidSansFallback) is honored again. It was parsed but unused in Cobalt 27.Testing
RDK (
evergreen-arm-hardfp-rdk_qa), page rendering the ETC Localization strings at weight 400 vs 700 and comparing inked pixels via canvas:disable_synthetic_boldingBug: 577839103
TAG=agy
CONV=aa9a1512-4172-4d51-a830-f0632fee17fa