-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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/+/2416261 Reviewed-by: Fernando Serboncini <fserb@chromium.org> Reviewed-by: Aaron Krajeski <aaronhk@chromium.org> Reviewed-by: Koji Ishii <kojii@chromium.org> Commit-Queue: Yi Xu <yiyix@chromium.org> Cr-Commit-Position: refs/heads/master@{#809379}
- Loading branch information
1 parent
3cabe51
commit 82e6948
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
html/canvas/element/drawing-text-to-the-canvas/2d.text.measure.fontBoundingBox.ahem.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters