Skip to content

@font-face without font-family reads an unset style property #3777

Description

@dajiaohuang

Description

An @font-face block with a supported src but no font-family descriptor reaches Style::get_font_family_raw() during stylesheet parsing. Style stores specified declarations in _props, and get_font_family_raw() indexes _props["font_family"] directly without checking whether it was declared. This emits an undefined array key warning (and passes an empty family into font registration) instead of ignoring the invalid face.

CSS Fonts requires both font-family and src for an @font-face rule to participate in font matching: https://www.w3.org/TR/css-fonts-3/#font-face-rule

Reproduction

@font-face {
  src: url("font.ttf");
}

When the URL resolves to a supported TrueType font, _parse_font_face() accepts its source, then reads the missing family descriptor at src/Css/Style.php::get_font_family_raw() before calling FontMetrics::registerFont().

This is based on static inspection of the stylesheet and font-registration call path. I did not run a rendering test. CONTRIBUTING.md requires a unit test for code contributions; no code patch or test is included here.

Activity

added this to the 3.1.7 milestone on Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions