Skip to content

Commit

Permalink
Update supported font format specifiers
Browse files Browse the repository at this point in the history
While we do support variations, our format specifier support was not
updated yet. Move all of that to FontCustomPlatformData and add a WPT
test to cover common supported format specifiers.

Test: external/wpt/css/css-fonts/format-specifiers-variations.html
Bug: 804466
Change-Id: I06d7af65cf74e13cec49dc279efb8ffc2b56dda9
Reviewed-on: https://chromium-review.googlesource.com/926007
Reviewed-by: Koji Ishii <kojii@chromium.org>
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537799}
  • Loading branch information
drott authored and chromium-wpt-export-bot committed Feb 20, 2018
1 parent d936893 commit 8f7ab64
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions css/css-fonts/format-specifiers-variations.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!DOCTYPE HTML>
<html>
<head>
<title>CSS Test: Supported format specifiers should load</title>
<link rel="help" href="https://drafts.csswg.org/css-fonts-4/#src-desc"/>
<meta name="assert" content="Supported format specifiers should load"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
setup({
explicit_done: true
});

var formatSpecifiers = [
"woff",
"truetype",
"opentype",
"woff2",
"woff-variations",
"truetype-variations",
"opentype-variations",
"woff2-variations"
];

var defaultAhemSrc = 'url("../../fonts/Ahem.ttf") format("INSERT_FORMAT")';

function runTestOnFormatSpecifiers(formats, expectFail) {
for (var i = 0; i < formats.length; ++i) {
promise_test((testDetails) => {
var familyName = "load_ahem_" + i;
var ahemSrcFormat = defaultAhemSrc.replace("INSERT_FORMAT", testDetails.properties.format);
var fontFace = new FontFace(familyName, ahemSrcFormat);
if (!expectFail) {
return fontFace.load();
} else {
return promise_rejects(testDetails, "NetworkError", fontFace.load());
}
}, (expectFail ? "Do not load" : "Load") + " Ahem with format " + formats[i], {
"format": formats[i]
});
}
}

runTestOnFormatSpecifiers(formatSpecifiers, false);
runTestOnFormatSpecifiers(formatSpecifiers.map(x => "xyz" + x), true);
runTestOnFormatSpecifiers(formatSpecifiers.map(x => x + "xyz"), true);
runTestOnFormatSpecifiers(formatSpecifiers.map(x => x.slice(0, -2)), true);
runTestOnFormatSpecifiers(formatSpecifiers.map(x => x.slice(2)), true);
runTestOnFormatSpecifiers(formatSpecifiers.map(x => x.slice(0, x.length / 3) + x.slice(x.length / 3 + 1)), true);

done();
</script>
</body>
</html>

0 comments on commit 8f7ab64

Please sign in to comment.