Skip to content

Proper line breaking for Khmer, Thai, Lao, and Burmese (Myanmar) #14

Open

Description

@chearon

These scripts don't separate words with spaces, and require a dictionary. In line breaking, iterate scripts as well as everything else. If the script is one of these, switch to a specialized break iterator.

This library can break all 4, but need to look into efficiency. Should probably use a trie.

Wikipedia says the first 3 are related through the Khmer writing system:

But Burmese is not:


Sort of related: Vietnam borders Cambodia and Laos, Vietnamese people today use a variant of Latin. I may need to tweak font selection at some point in order to properly select a Vietnamese font for the entire run instead of having a mix of a Latin and Vietnamese font, since I don't think Latin fonts necessarily support all of Vietnamese.

Activity

  1. seanghay commented on Apr 25, 2025

    @seanghay

    @chearon I think it's possible to use icu-segmenter (compiled to wasm) for line breaking. icu-segmenter supports these languages.

  2. chearon commented on Apr 26, 2025

    @chearon
    OwnerAuthor

    So it does. If it's not too difficult I may just use that as a reference and write it in JS or Zig so it's easier to integrate into the existing build system. I'm also interested in some of the machine learning-based breaking I've seen around. Might help keeping the .wasm size down.

  3. seanghay commented on Apr 26, 2025

    @seanghay

    @chearon worth checking: https://github.com/unicode-org/icu4x/tree/main/ffi/npm this is wasm port of icu4x which includes icu-segmenter as well.

  4. seanghay commented on May 2, 2025

    @seanghay

    I've made a project called Sone: https://github.com/seanghay/sone with support Khmer text wrapping and justification. Learnt a lot building it.

  5. chearon commented on May 2, 2025

    @chearon
    OwnerAuthor

    Nice work and welcome to the club! It didn't occur to me to use Intl.Segmenter. I'll have to see if it performs the same as what I have now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions