seg-break-transformation-016

Thai with ZWSP before line break

WeasyPrint

This browser

Flags
script
Assertion
If the character immediately before or immediately after the segment break is the zero-width space character (U+200B), then the break is removed, leaving behind the zero-width space.

Source

 1 <!DOCTYPE html>
 2 <html lang="en"><head>
 3 <meta charset="utf-8">
 4 <title>Thai with ZWSP before line break</title>
 5 <link href="mailto:ishida@w3.org" rel="author" title="Richard Ishida">
 6 <link href="https://drafts.csswg.org/css-text-3/#line-break-transform" rel="help">
 7 <meta content="If the character immediately before or immediately after the segment break is the zero-width space character (U+200B), then the break is removed, leaving behind the zero-width space." name="assert">
 8 <style type="text/css">
 9 /* the CSS below is not part of the test */
10 .test span { font-size: 24px; font-family: sans-serif; background-color: #2AA5F7; color: white; }
11 .ref span { font-size: 24px; font-family: sans-serif; background-color: #270CEF; color: white; }
12 </style>
13 <script src="/resources/testharness.js"></script>
14 <script src="/resources/testharnessreport.js"></script>
15 </head>
16 <body>
17 <div id="log"></div>
18 <div class="test" id="test1"><span>ภาษา&#x200B;
19 ไทย</span></div>
20 <div class="test" id="test2"><span>ภาษา&#x200B;   
21 ไทย</span></div>
22 <div class="test" id="test3"><span>ภาษา&#x200B;
23         ไทย</span></div>
24 <div class="test" id="test4"><span>ภาษา&#x200B;   
25      ไทย</span></div>
26 <div class="test" id="test5"><span>ภาษา&#x200B;
27 
28 
29 ไทย</span></div>
30 <div class="test" id="test6"><span>ภาษา&#x200B;  
31    
32    
33    ไทย</span></div>
34 <div class="ref" id="ref"><span>ภาษาไทย</span></div>
35 <script>
36 test(function() {
37 assert_equals(document.getElementById('test1').firstChild.offsetWidth, document.getElementById('ref').firstChild.offsetWidth);
38 }, "linebreak only");
39 var matches = document.getElementById('test1').firstChild.textContent.match(/\u200B/g)
40 test(function() {
41 assert_equals(matches.length, 1);
42 }, "zwsp retained 1");
43 test(function() {
44 assert_equals(document.getElementById('test2').firstChild.offsetWidth, document.getElementById('ref').firstChild.offsetWidth);
45 }, "spaces linebreak");
46 var matches = document.getElementById('test2').firstChild.textContent.match(/\u200B/g)
47 test(function() {
48 assert_equals(matches.length, 1);
49 }, "zwsp retained 2");
50 test(function() {
51 assert_equals(document.getElementById('test3').firstChild.offsetWidth, document.getElementById('ref').firstChild.offsetWidth);
52 }, "linebreak spaces");
53 var matches = document.getElementById('test3').firstChild.textContent.match(/\u200B/g)
54 test(function() {
55 assert_equals(matches.length, 1);
56 }, "zwsp retained 3");
57 test(function() {
58 assert_equals(document.getElementById('test4').firstChild.offsetWidth, document.getElementById('ref').firstChild.offsetWidth);
59 }, "spaces linebreak spaces");
60 var matches = document.getElementById('test4').firstChild.textContent.match(/\u200B/g)
61 test(function() {
62 assert_equals(matches.length, 1);
63 }, "zwsp retained 4");
64 test(function() {
65 assert_equals(document.getElementById('test5').firstChild.offsetWidth, document.getElementById('ref').firstChild.offsetWidth);
66 }, "multiple linebreaks");
67 var matches = document.getElementById('test5').firstChild.textContent.match(/\u200B/g)
68 test(function() {
69 assert_equals(matches.length, 1);
70 }, "zwsp retained 5");
71 test(function() {
72 assert_equals(document.getElementById('test6').firstChild.offsetWidth, document.getElementById('ref').firstChild.offsetWidth);
73 }, "multiple linebreaks + spaces");
74 var matches = document.getElementById('test6').firstChild.textContent.match(/\u200B/g)
75 test(function() {
76 assert_equals(matches.length, 1);
77 }, "zwsp retained 6");
78 </script>
79 <!-- Notes:
80 The assertion will fail if a normal space is produced for any line in the test paragraph.
81 -->
82 
83 
84 
85 
86 </body></html>