linebender / skribo

A Rust library for low-level text layout.
Apache License 2.0
327 stars 35 forks source link

Variable shaper #41

Open simoncozens opened 2 years ago

simoncozens commented 2 years ago

So a lot of the changes here are just rustfmt doing its thing, but this PR also:

khaledhosny commented 2 years ago
  • Makes the direction/script/language optional in layout_fragment, allowing the user to set explicit values if they want them but using Harfbuzz's guess_segment_properties for a decent default fallback.

This is really bad and should not be happen in production code. hb_buffer_guess_segment_properties() can easily be wrong and the user will be none the wiser. For example it guesses the direction from the script, so an sequence of digits from an RTL script will be set to RTL even though it should almost always be LTR.

khaledhosny commented 2 years ago

(I wish HarfBuzz never made hb_buffer_guess_segment_properties() public and kept it only for the command line test utilities).

simoncozens commented 2 years ago

Thanks, I'll work on these. I think an architectural question to resolve is whether we see the variation location as an attribute of the FontRef or of the TextStyle. I can see arguments for each. I put them in the FontRef so that they would be available to access when you have a Vec<LayoutFragment> (i.e. when you're breaking the text into lines after shaping). But there's also an argument that a LayoutFragment should know its TextStyle, and if we add that property, it would be much neater to put the variation location into TextStyle too.