Skip to content

fontWeight preference has no effect on single-face fonts #239

Description

@atani

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

  1. Register a single-face font with Configuration.fontFamilyDeclarations and select it via EPUBPreferences.fontFamily.
  2. Set EPUBPreferences.fontWeight = 1.5 (mapped to font-weight: 600 by ReadiumCSS.userProperties).
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions