tc39 / proposal-intl-segmenter-v2

Version 2 of Intl Segmenter. Adding line break support.
https://tc39.github.io/proposal-intl-segmenter-v2/
MIT License
12 stars 4 forks source link

Use case of Line Break #1

Open FrankYFTang opened 3 years ago

FrankYFTang commented 3 years ago

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

gibson042 commented 2 years ago

One obvious use case is formatting in a monospace context, such as a CLI or GitHub source diff.

HackbrettXXX commented 2 years ago

Two more use cases:

mdebbar commented 2 years ago

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.

FrankYFTang commented 2 years ago

@rkirsling any opinion about the use case of adding line break into Intl.Segmenter from JSC?

lbud commented 2 years ago

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.

bathos commented 2 years ago

Happy to see this API is being revisited! My use case is among those already listed — “...monospace context, such as a CLI...” (@gibson042) — but figured it wouldn’t hurt to make it clear that there’s more than one of us :)