Open FrankYFTang opened 3 years ago
One obvious use case is formatting in a monospace context, such as a CLI or GitHub source diff.
Two more use cases:
words = text.split(" ")
. Adding Line Break to Intl.Segmenter could improve that. In jsPDF, the text is measured by loading the font files and calculating the text size from the glyph sizes.measureText()
or SVG's getComputedTextLength()
or getBBox()
.I wrote a description of text layout in Flutter Web here: https://gist.github.com/mdebbar/93886d22a4cd40e050d1533d7e0016bf
The section that's relevant to this proposal is 1. Line Breaks. It explains how we do line breaks today, and what issues we still have, and how this proposal can help us.
@rkirsling any opinion about the use case of adding line break into Intl.Segmenter from JSC?
We do our own text layout + rendering in Figma (a WebGL application), so currently the Figma bundle needs to include an external library that implements the Unicode line breaking algorithm. It sits inside our text layout engine where we lay out multi-line text nodes by measuring character widths + spacings using font data and specified text style (size/spacing) properties, determining all allowed line break positions in the text string, and laying as many segments as fit on each line. Exposing the line breaking algorithm in Intl.Segmenter would be really useful to us as we could eliminate this external library dependency and reduce bundle size.
Dear @gibson042 . thank you for expressing the support of adding Line Break to Intl.Segmenter. in the Oct 7 2021 meeting you mention you are aware of some use case, could you help to build up that. Thanks