Commit f64b9b43 authored by yiyix's avatar yiyix Committed by Commit Bot

Add new fontBoundingBoxAscent/Descent test

Add new fontBoundingBoxAscent/Descent test with Ahem font. Firefox and
Chrome follow different table to calculate the fontBoundingboxAscent and
descent. Ahem is one the font that has the same information across
the tables. In this cl, I add a new test using Ahem font, so that the
test can work for all browsers.

Bug:1129621

Change-Id: I8ef0d7c5788e79f215d763e8494c3db8941b95d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416261Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Reviewed-by: default avatarAaron Krajeski <aaronhk@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Yi Xu <yiyix@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809379}
parent a9350a26
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>Canvas test: 2d.text.measure.fontBoundingBox.ahem</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
<style>
@font-face {
font-family: Ahem;
src: url("/fonts/Ahem.ttf");
}
</style>
<body class="show_output">
<h1>2d.text.measure.fontBoundingBox.ahem</h1>
<p class="desc">Testing fontBoundingBox for font ahem</p>
<span style="font-family: Ahem; position: absolute; visibility: hidden">A</span>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<ul id="d"></ul>
<script>
var t = async_test("Testing fontBoundingBox for font ahem");
_addTest(function(canvas, ctx) {
deferTest();
var f = new FontFace("Ahem", "/fonts/Ahem.ttf");
document.fonts.add(f);
document.fonts.ready.then(() => {
step_timeout(t.step_func_done(function () {
ctx.font = '50px Ahem';
ctx.direction = 'ltr';
ctx.align = 'left'
_assertSame(ctx.measureText('A').fontBoundingBoxAscent, 40, "ctx.measureText('A').fontBoundingBoxAscent", "40");
_assertSame(ctx.measureText('A').fontBoundingBoxDescent, 10, "ctx.measureText('A').fontBoundingBoxDescent", "10");
_assertSame(ctx.measureText('ABCD').fontBoundingBoxAscent, 40, "ctx.measureText('ABCD').fontBoundingBoxAscent", "40");
_assertSame(ctx.measureText('ABCD').fontBoundingBoxDescent, 10, "ctx.measureText('ABCD').fontBoundingBoxDescent", "10");
}), 500);
});
});
</script>
...@@ -665,6 +665,29 @@ ...@@ -665,6 +665,29 @@
}), 500); }), 500);
}); });
- name: 2d.text.measure.fontBoundingBox.ahem
desc: Testing fontBoundingBox for font ahem
testing:
- 2d.text.measure.fontBoundingBox
fonts:
- Ahem
code: |
deferTest();
var f = new FontFace("Ahem", "/fonts/Ahem.ttf");
document.fonts.add(f);
document.fonts.ready.then(() => {
step_timeout(t.step_func_done(function () {
ctx.font = '50px Ahem';
ctx.direction = 'ltr';
ctx.align = 'left'
@assert ctx.measureText('A').fontBoundingBoxAscent === 40;
@assert ctx.measureText('A').fontBoundingBoxDescent === 10;
@assert ctx.measureText('ABCD').fontBoundingBoxAscent === 40;
@assert ctx.measureText('ABCD').fontBoundingBoxDescent === 10;
}), 500);
});
- name: 2d.text.measure.emHeights - name: 2d.text.measure.emHeights
desc: Testing emHeights desc: Testing emHeights
testing: testing:
......
...@@ -732,6 +732,7 @@ MISSING DEPENDENCY: webxr/resources/webxr_util.js ...@@ -732,6 +732,7 @@ MISSING DEPENDENCY: webxr/resources/webxr_util.js
AHEM SYSTEM FONT: acid/acid3/test.html AHEM SYSTEM FONT: acid/acid3/test.html
AHEM SYSTEM FONT: resource-timing/resources/all_resource_types.htm AHEM SYSTEM FONT: resource-timing/resources/all_resource_types.htm
AHEM SYSTEM FONT: resource-timing/resources/iframe-reload-TAO.sub.html AHEM SYSTEM FONT: resource-timing/resources/iframe-reload-TAO.sub.html
AHEM SYSTEM FONT: html/canvas/element/drawing-text-to-the-canvas/2d.text.measure.fontBoundingBox.ahem.html
# TODO: The following should be deleted along with the Ahem web font cleanup # TODO: The following should be deleted along with the Ahem web font cleanup
# PR (https://github.com/web-platform-tests/wpt/pull/18702) # PR (https://github.com/web-platform-tests/wpt/pull/18702)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment