blob: b5fcd5a74e70099ae8173b7954fbc7b1ff72fdb8 [file] [log] [blame] [edit]
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="help" href="https://drafts.csswg.org/css-text-4/#text-autospace-property">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/get-char-advances.js"></script>
<style>
.test {
font-family: Ahem;
font-size: 40px;
}
.first-line::first-line {
font-size: 200%;
}
</style>
<div class="test" expect="1,3">国国XX国</div>
<div class="test" expect="3">国。XX国</div>
<div dir="rtl" class="test" expect="1,3">国国XX国</div>
<div dir="rtl" class="test" expect="3">国。XX国</div>
<div class="test first-line" expect="1,3,6,8">国国XX国<br>国国XX国</div>
<script>
for (const element of document.getElementsByClassName('test')) {
const advances = getCharAdvances(element);
const advances_expect = [...advances];
const expect = element.getAttribute('expect').split(',').map(i => parseInt(i));
for (const i of expect) {
// To make computing the spacing simple, the character before must be the
// same size without the spacing.
advances_expect[i] = advances[i - 1] * 1.125;
}
test(() => {
assert_array_equals(advances, advances_expect);
})
}
</script>