OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <title>Test that alignment-baseline is unaffected by zoom level</title> |
| 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <svg width="250" height="140" viewBox="0 0 250 140" |
| 6 xmlns="http://www.w3.org/2000/svg" version="1.1"> |
| 7 <style> |
| 8 text { |
| 9 font-family: ahem; |
| 10 font-size: 20px; |
| 11 } |
| 12 </style> |
| 13 <text x="15" y="40">before<tspan>inter</tspan>after</text> |
| 14 <script> |
| 15 var alignmentBaselineValues = ["baseline", "before-edge", "text-before-edge"
, "middle", |
| 16 "central", "after-edge", "text-after-edge", |
| 17 "ideograpic", "alphabetic", "hanging", "mathe
matical"]; |
| 18 var expectedHeights = { |
| 19 "baseline" : 20, |
| 20 "before-edge": 36, |
| 21 "text-before-edge": 36, |
| 22 "middle": 28, |
| 23 "central": 26, |
| 24 "after-edge": 24, |
| 25 "text-after-edge": 24, |
| 26 "ideograpic": 20, |
| 27 "alphabetic": 20, |
| 28 "hanging": 32, |
| 29 "mathematical": 28 |
| 30 }; |
| 31 |
| 32 var zoomLevels = [1, 4, 16]; |
| 33 var html = document.documentElement; |
| 34 alignmentBaselineValues.forEach(function (alignmentBaselineValue) { |
| 35 document.querySelector('tspan').setAttribute('alignment-baseline', align
mentBaselineValue); |
| 36 zoomLevels.forEach(function (zoom) { |
| 37 html.style.zoom = zoom; |
| 38 var bounds = document.querySelector('text').getBoundingClientRect(); |
| 39 test(function () { |
| 40 assert_approx_equals(bounds.height, expectedHeights[alignmentBas
elineValue], 1); |
| 41 }, "Text bounds height at zoom " + zoom + " with alignment-baseline=
" + alignmentBaselineValue); |
| 42 }); |
| 43 }); |
| 44 html.style.zoom = 1; |
| 45 </script> |
| 46 </svg> |
| 47 <p>This test requires the Ahem font</p> |
OLD | NEW |