haikuwebkit/LayoutTests/fast/text/font-erroneous-monospace-ex...

16 lines
327 B
HTML
Raw Permalink Normal View History

Fonts lie about being monospaced https://bugs.webkit.org/show_bug.cgi?id=162546 <rdar://problem/28494654> Reviewed by Darin Adler. Source/WebCore: When a font reports itself to be monospace, we use this as a signal that we can perform width computations by assuming all characters have the same width as the space character. However, some fonts erroneously claim to be monospaced. We can't know this ahead of time without measuring a bunch of characters at font load time, which would be too slow, so even though the optimization would be nice there is no practical way to do it correctly. Firefox and Chrome both do not use this signal, so therefore they both correctly render these fonts. We should ignore this bit in the font as well. Also, CJK fonts generally do not have this bit set (because they usually have at least one character which is not fullwidth) so this isn't a concern there. Our Page Load Test shows this is not a performance regression. Tests: fast/text/font-erroneous-monospace.html fast/text/font-monospaced-lie.html * rendering/RenderText.cpp: (WebCore::RenderText::widthFromCache const): LayoutTests: Add two tests for fonts which claim to be monospaced but actually aren't. * fast/text/font-erroneous-monospace-expected.html: Added. * fast/text/font-erroneous-monospace.html: Added. * fast/text/font-monospaced-lie-expected.txt: Added. * fast/text/font-monospaced-lie.html: Added. * fast/text/line-break-after-question-mark-expected.txt: * fast/text/line-break-after-question-mark.html: * fast/text/resources/Ahem-fixed-pitch.ttf: Added. * fast/text/resources/AhemErroneousMonospace.ttf: Added. Canonical link: https://commits.webkit.org/228593@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266118 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-25 16:03:00 +00:00
<!DOCTYPE html>
<html>
<head>
<style>
@font-face {
font-family: "WebFontAhem";
src: url("../../resources/Ahem.ttf") format("truetype");
}
</style>
</head>
<body>
The test passes if there is no red shown below.
<div><span style="font: 50px 'WebFontAhem'; -webkit-font-smoothing: none;">aaaa</span></div>
</body>
</html>