Summary
EPUBPreferences.fontWeight has no visible effect on fonts that ship only a single (Regular) face, such as user-imported fonts declared via fontFamilyDeclarations. WebKit does not appear to synthesize bolding in this situation, so the preference silently does nothing for those fonts.
Environment
- swift-toolkit at develop
8811f0e (also reproduces on 3.10.0 with data-URI-embedded fonts)
- iOS 26.5 simulator (iPhone 17), WKWebView
- Font declared with
CSSFontFamilyDeclaration / CSSFontFace (single face, no weight descriptor, i.e. default 400)
Reproduction
- Register a single-face font with
Configuration.fontFamilyDeclarations and select it via EPUBPreferences.fontFamily.
- Set
EPUBPreferences.fontWeight = 1.5 (mapped to font-weight: 600 by ReadiumCSS.userProperties).
- Compare renders at
fontWeight = 1.0 and 1.5.
Result: the two renders are pixel-identical (we diffed screenshots). With a multi-face system font (Georgia) the preference works, but only by snapping to the real Bold face.
Expected
Either gradual (or at least synthetic) bolding for single-face fonts, or documentation that fontWeight requires a multi-face or variable font.
Notes
- We did not find
font-synthesis overridden in Readium CSS, so this looks like WebKit's own reluctance to synthesize bold for downloaded fonts at weight 600. We only tested 600; higher values may behave differently.
- As a workaround in our reader we layer
-webkit-text-stroke (em-scaled from the weight preference, currentColor) on top of the native font-weight, which gives gradual thickening for any font. If there is interest, this could be an opt-in behavior of the fontWeight preference in Readium CSS.
Happy to contribute a patch if the maintainers have a preferred direction.
Summary
EPUBPreferences.fontWeighthas no visible effect on fonts that ship only a single (Regular) face, such as user-imported fonts declared viafontFamilyDeclarations. WebKit does not appear to synthesize bolding in this situation, so the preference silently does nothing for those fonts.Environment
8811f0e(also reproduces on 3.10.0 with data-URI-embedded fonts)CSSFontFamilyDeclaration/CSSFontFace(single face, no weight descriptor, i.e. default 400)Reproduction
Configuration.fontFamilyDeclarationsand select it viaEPUBPreferences.fontFamily.EPUBPreferences.fontWeight = 1.5(mapped tofont-weight: 600byReadiumCSS.userProperties).fontWeight = 1.0and1.5.Result: the two renders are pixel-identical (we diffed screenshots). With a multi-face system font (Georgia) the preference works, but only by snapping to the real Bold face.
Expected
Either gradual (or at least synthetic) bolding for single-face fonts, or documentation that
fontWeightrequires a multi-face or variable font.Notes
font-synthesisoverridden in Readium CSS, so this looks like WebKit's own reluctance to synthesize bold for downloaded fonts at weight 600. We only tested 600; higher values may behave differently.-webkit-text-stroke(em-scaled from the weight preference,currentColor) on top of the nativefont-weight, which gives gradual thickening for any font. If there is interest, this could be an opt-in behavior of thefontWeightpreference in Readium CSS.Happy to contribute a patch if the maintainers have a preferred direction.