CANVAS
HTML
To note: Javascript is not running in this browser environment. Our apologies, but this demo has not yet been updated to support progressive enhancement.
There are so, so many things to check here! The following list is not exhaustive:
direction and breakTextOnSpaces attributes to match a font's requirements when that font loads. Check that all fonts do load, and their display matches the HTML display:breakTextOnSpaces value. For western fonts this will lead to as many letters as possible appearing on each line, with words broken in unexpected places. For Arabic and Devangari fonts, this setting will break the displayed text (though the effect is useful for displaying Arabic fonts vertically).breakWordOnHyphens attribute is set to true. Soft hyphens should only appear at the end of a line. Check that the hyphen character can be changed programmatically.letterSpacing and wordSpacing attributes operate as expected. The text should flow as these attributes are adjusted.roll attribute) updates, the text moves with the template.textHandleX attribute should see minimal text movement, but the red dot will now settle on each text unit's left or right edge.textHandleY attribute will cause the text to move upwards/downwards to match the attribute's value. Again, the red dot's positioning will match the attribute's value.lineAdjustment attribute will move the text up/down, but the effect does not leave a significant gap at the top of the template entity's yellow background.lineSpacing attribute alters the spacing between lines as expected. Setting this attribute to 0 should lead to the display of a single line, not to an error.justifyLine attribute:alignment attribute. The text should rotate within the template entity's shape, reflowing to fit within the shape as it rotates.textUnitFlow attribute:alignment attribute to show vertical text - for example for Chinese/Japanese fonts)localAlignment attribute to adjust each text unit's rotation. Have fun playing with the various rotation attributes to see how they interact.layoutTemplate attribute. Text should flow within each template's shape.Known issue: When changing the font, or the layout template, the positioning of the red ball breaks down; however that can be fixed by making a small adjustment to another attribute.
Known issue: letter spacing does not work in Safari browsers.
Touch test: not required.
A special note about fonts
Because fonts load asynchronously, and SC EnhancedLabel entitys currently have a (near-unsolvable) bug where they will measure a font before the font family's various iterations (if specified in CSS @font-family definitions) have downloaded - they only wait for their default font to download, not any additional fonts included (via CSS) in their text string - it makes sense for us to trigger font downloads as soon as possible. And the simplest way to do that is to include text using those fonts in a "hidden" (actually an aria-hidden="true" style="height: 0; overflow: hidden") element in the web page, ahead of the <script> tag that triggers the SC canvas build.
There are, of course, more professional ways for a front-end engineer to manage efficient and timely font downloads ... but this is just a demo and, well, needs must!
Another special note about Chinese and Japanese scripts
As much as we would like to treat every Chinese and Japanese character as its own thing, both writing systems insist that certain punctuation marks cannot be separated from their preceding character over a line break. Browsers know about this, and make sure it happens in normal HTML. SC, however, makes no effort to guess when this should happen.
For this demo, we have manually added word joiner characters - HTML entity ⁠ - immediately before these punctuation marks. A more robust code solution to pre-process canvas text would be required to handle this sort of thing in production environments. Building such a solution into the SC code is not in scope for the project.
An even more special note about Thai scripts
Breaking Thai "words" across lines is a difficult issue - see the W3C Thai Layout Requirements spec for the latest position.
The Thai script is a complex abugida. Spaces are used, but the tendency is to only insert them at natural breath pauses, which means a Thai "word" (as in: a set of characters not separated by spaces) can get exceptionally long.
To break such words across lines, one recommendation is to insert zero-space spaces - HTML entity ​ - in places where this can be done. Browser engines seem to do this internally, but getting that data from the text string doesn't seem possible. For the two Thai fonts above, this has been done manually by copying the raw string into a <p style='width: 10px; font: 16px "Noto Thai Looped Sans"'> element and then counting the characters. Not recommended for production!
ในแผนเดิมรถไฟฟ้าแอร์พอร์ต เรล ลิงก์ สถานีมักกะสันจะเชื่อมต่อกับสถานีเพชรบุรีของรถไฟฟ้ามหานครที่ชั้น ของตัวอาคาร แต่เนื่องจากเมื่อสำรวจเส้นทางแล้ว พบว่าเส้นทางดังกล่าว มีท่อส่งน้ำมันของปตท. ตามแนวทางรถไฟสายตะวันออก ท่อน้ำประปาของการประปานครหลวง และท่อน้ำทิ้งลงคลองแสนแสบของกรุงเทพมหานคร ที่การรถไฟฟ้าขนส่งมวลชนแห่งประเทศไทยรื้อย้ายจากจุดเดิมเพื่อก่อสร้างสถานีเพชรบุรี ขวางอยู่จึงทำให้การขุดเจาะทางเชื่อมเข้าตัวสถานีรถไฟฟ้ามหานครไม่สามารถทำได้