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.
Description
An
@font-faceblock with a supportedsrcbut nofont-familydescriptor reachesStyle::get_font_family_raw()during stylesheet parsing.Stylestores specified declarations in_props, andget_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-familyandsrcfor an@font-facerule to participate in font matching: https://www.w3.org/TR/css-fonts-3/#font-face-ruleReproduction
When the URL resolves to a supported TrueType font,
_parse_font_face()accepts its source, then reads the missing family descriptor atsrc/Css/Style.php::get_font_family_raw()before callingFontMetrics::registerFont().This is based on static inspection of the stylesheet and font-registration call path. I did not run a rendering test.
CONTRIBUTING.mdrequires a unit test for code contributions; no code patch or test is included here.