-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1778910 - Hook up rendering support for canvas2d fontVariantCaps,…
… and add WPT reftests. r=gfx-reviewers,lsalzman The behavior in some of these cases is open to debate, as the spec is quite unclear; see whatwg/html#8103. What I've implemented here gives the same rendering result as Chrome for these tests, so hopefully we can get this clarified in the spec as well. Differential Revision: https://phabricator.services.mozilla.com/D182567 UltraBlame original commit: def0a0be81f9f1d6b63720a27b69b34ebe15b4e2
- Loading branch information
Showing
10 changed files
with
214 additions
and
2 deletions.
There are no files selected for viewing
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
17 changes: 17 additions & 0 deletions
17
.../web-platform/tests/html/canvas/element/drawing-text-to-the-canvas/fontVariantCaps-1.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,17 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML Canvas Test: the 'fontVariantCaps' property</title> | ||
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fontvariantcaps"> | ||
<link rel="match" href="reference/fontVariantCaps-1-ref.html"> | ||
<meta name="assert" content="text rendering respects the fontVariantCaps property"> | ||
|
||
<canvas id="c"></canvas> | ||
|
||
<script> | ||
let ctx = c.getContext("2d"); | ||
ctx.font = "32px serif"; | ||
ctx.fontVariantCaps = "small-caps"; | ||
// This should render the same as font = "small-caps 32px serif". | ||
ctx.fillText("Hello World", 20, 100); | ||
</script> |
16 changes: 16 additions & 0 deletions
16
.../web-platform/tests/html/canvas/element/drawing-text-to-the-canvas/fontVariantCaps-2.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,16 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML Canvas Test: the 'fontVariantCaps' property</title> | ||
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fontvariantcaps"> | ||
<link rel="mismatch" href="reference/fontVariantCaps-2-ref.html"> | ||
<meta name="assert" content="text rendering respects the fontVariantCaps property"> | ||
|
||
<canvas id="c"></canvas> | ||
|
||
<script> | ||
let ctx = c.getContext("2d"); | ||
ctx.font = "small-caps 32px serif"; | ||
// "mismatch" test, to verify that small-caps does change the rendering. | ||
ctx.fillText("Hello World", 20, 100); | ||
</script> |
18 changes: 18 additions & 0 deletions
18
.../web-platform/tests/html/canvas/element/drawing-text-to-the-canvas/fontVariantCaps-3.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,18 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML Canvas Test: the 'fontVariantCaps' property</title> | ||
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fontvariantcaps"> | ||
<link rel="match" href="reference/fontVariantCaps-3-ref.html"> | ||
<meta name="assert" content="text rendering respects the fontVariantCaps property"> | ||
|
||
<canvas id="c"></canvas> | ||
|
||
<script> | ||
let ctx = c.getContext("2d"); | ||
ctx.font = "32px serif"; | ||
ctx.fontVariantCaps = "all-small-caps"; | ||
// This should render the same as using font = "small-caps 32px serif" | ||
// with all the underlying text in lowercase. | ||
ctx.fillText("Hello World", 20, 100); | ||
</script> |
18 changes: 18 additions & 0 deletions
18
.../web-platform/tests/html/canvas/element/drawing-text-to-the-canvas/fontVariantCaps-4.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,18 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML Canvas Test: the 'fontVariantCaps' property</title> | ||
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fontvariantcaps"> | ||
<link rel="match" href="reference/fontVariantCaps-3-ref.html"> | ||
<meta name="assert" content="text rendering respects the fontVariantCaps property"> | ||
|
||
<canvas id="c"></canvas> | ||
|
||
<script> | ||
let ctx = c.getContext("2d"); | ||
ctx.font = "small-caps 32px serif"; | ||
// fontVariantCaps overrides the small-caps setting from the font attribute | ||
// (spec unclear, cf. https://github.com/whatwg/html/issues/8103) | ||
ctx.fontVariantCaps = "all-small-caps"; | ||
ctx.fillText("Hello World", 20, 100); | ||
</script> |
18 changes: 18 additions & 0 deletions
18
.../web-platform/tests/html/canvas/element/drawing-text-to-the-canvas/fontVariantCaps-5.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,18 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML Canvas Test: the 'fontVariantCaps' property</title> | ||
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fontvariantcaps"> | ||
<link rel="match" href="reference/fontVariantCaps-1-ref.html"> | ||
<meta name="assert" content="text rendering respects the fontVariantCaps property"> | ||
|
||
<canvas id="c"></canvas> | ||
|
||
<script> | ||
let ctx = c.getContext("2d"); | ||
ctx.font = "small-caps 32px serif"; | ||
// fontVariantCaps 'normal' does not override the setting from the font attribute. | ||
// (spec unclear, cf. https://github.com/whatwg/html/issues/8103) | ||
ctx.fontVariantCaps = "normal"; | ||
ctx.fillText("Hello World", 20, 100); | ||
</script> |
18 changes: 18 additions & 0 deletions
18
.../web-platform/tests/html/canvas/element/drawing-text-to-the-canvas/fontVariantCaps-6.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,18 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML Canvas Test: the 'fontVariantCaps' property</title> | ||
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fontvariantcaps"> | ||
<link rel="match" href="reference/fontVariantCaps-2-ref.html"> | ||
<meta name="assert" content="text rendering respects the fontVariantCaps property"> | ||
|
||
<canvas id="c"></canvas> | ||
|
||
<script> | ||
let ctx = c.getContext("2d"); | ||
// fontVariantCaps is reset when the font attribute is set. | ||
// (spec unclear, cf. https://github.com/whatwg/html/issues/8103) | ||
ctx.fontVariantCaps = "all-small-caps"; | ||
ctx.font = "32px serif"; | ||
ctx.fillText("Hello World", 20, 100); | ||
</script> |
12 changes: 12 additions & 0 deletions
12
...tests/html/canvas/element/drawing-text-to-the-canvas/reference/fontVariantCaps-1-ref.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,12 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML Canvas reference</title> | ||
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com"> | ||
|
||
<canvas id="c"></canvas> | ||
|
||
<script> | ||
let ctx = c.getContext("2d"); | ||
ctx.font = "small-caps 32px serif"; | ||
ctx.fillText("Hello World", 20, 100); | ||
</script> |
12 changes: 12 additions & 0 deletions
12
...tests/html/canvas/element/drawing-text-to-the-canvas/reference/fontVariantCaps-2-ref.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,12 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML Canvas reference</title> | ||
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com"> | ||
|
||
<canvas id="c"></canvas> | ||
|
||
<script> | ||
let ctx = c.getContext("2d"); | ||
ctx.font = "32px serif"; | ||
ctx.fillText("Hello World", 20, 100); | ||
</script> |
12 changes: 12 additions & 0 deletions
12
...tests/html/canvas/element/drawing-text-to-the-canvas/reference/fontVariantCaps-3-ref.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,12 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML Canvas reference</title> | ||
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com"> | ||
|
||
<canvas id="c"></canvas> | ||
|
||
<script> | ||
let ctx = c.getContext("2d"); | ||
ctx.font = "small-caps 32px serif"; | ||
ctx.fillText("hello world", 20, 100); | ||
</script> |