RazrFalcon / rustybuzz

A complete harfbuzz's shaping algorithm port to Rust
MIT License
498 stars 34 forks source link

There's no way to specify a segment when adding text to a buffer #64

Closed floppyhammer closed 1 year ago

floppyhammer commented 1 year ago

From hb_buffer_add_utf8 in harfbuzz, it says:

The safest approach is to add all of the text available (even if your text contains a mix of scripts, directions, languages and fonts), then use item_offset and item_length to indicate which characters you want shaped (which must all have the same script, direction, language and font), so that HarfBuzz has access to any context.

I couldn't figure out how to set item_offset and item_length in rustybuzz. The closest thing I get is UnicodeBuffer::push_str, which doesn't accept any arguments. Am I missing something?

RazrFalcon commented 1 year ago

If you want to shape just part of the string - then you can slice it manually. If you need pre/post-context - then this is not implemented yet. Or rather not available in the public api.

floppyhammer commented 1 year ago

@RazrFalcon Thanks for the reply. It seems that manually slicing the string with the assistance of a bidi algorithm library is enough to get things done. I'm closing this.