Implement parley_core::ShapedText#679
Conversation
b413454 to
41e0700
Compare
Why are the fields of |
41e0700 to
8203d81
Compare
The API gives full read access. I'm not sure about mutable access, as there are quite a few invariants that need to be upheld. There's a lot of cross-referencing; e.g., runs contain ranges tiling Of course if a user has mutable access and breaks something, that's mostly fine as it's their own fault, but I'm not sure mutation is strongly needed. Parley currently only mutates advances in-place, but it's hacky. E.g. if a layout is justified, the advances are changed, and relayout requires a pass to unjustify first. As the original values are now lost, it's doing the same calculations in reverse; this kind of thing is going to drift because of compounding rounding errors after enough passes. If (I think having a bit of a closer look at what exactly the API exposes would be good, after this PR lands we've mostly arrived at the targeted seam between |
13a1cf7 to
99881e5
Compare
This moves run processing from `parley` to `parley_core`, and lets `parley_core` own the shaped results. `parley_core` now fully owns shaping. `parley` replaces its cluster/glyph/etc. stores in `LayoutData` with `ShapedText`, and keeping its run data (though dropping some fields) to store some run data `parley_core` is not aware of. There's one escape hatch that we should try to get rid of soon: because `parley` was mutating shaped data in-place for justification and letter spacing and such, `parley_core` exposes `#[doc(hidden)]` mutable access to two `ShapedText` fields to keep `parley` happy. That won't work anymore once we get reshaping across breaks. (For justification, that also meant we have a hack that has to unjustify in-place...)
0c5b94e to
f94e80e
Compare
| /// A normalized font coordinate. | ||
| /// | ||
| /// This is a 16-bit fixed-point number with a 14-bit fractional part. For font coordinates, its | ||
| /// useful values are in the range -1.0..=1.0. | ||
| #[repr(transparent)] | ||
| #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] | ||
| pub struct NormalizedCoord(i16); |
There was a problem hiding this comment.
This prevents exposing font_types::F2Dot14, but perhaps we should add bytemuck support so users can easily cast slices.
There was a problem hiding this comment.
I think this type makes sense, but it ought to live in parlance (we have also previously just used plain i16 for this).
There was a problem hiding this comment.
This moves shaped run processing from
parleytoparley_core, and letsparley_coreown the shaped results inShapedText.parley_corenow fully owns shaping.parleystoresShapedTextin itsLayoutData, dropping its cluster/glyph/etc. vecs. It keeps some run data as a parallel vector toShapedText::runs, storing some data thatparley_coreis not aware of.A large part of the diff (
process_clusters) was moved verbatim to core.ShapedContext::push_runis mostly blocks moved out of the oldfn push_runthat was inparley/src/layout/data.rs.There's one escape hatch that we should try to get rid of: because
parleywas mutating shaped data in-place for justification and letter spacing and such,parley_coreexposes#[doc(hidden)]mutable access to twoShapedTextfields to keepparleyhappy. This in-place mutation isn't really great in itself, e.g., for justification,parleyalready has a hack to "unjustify" in-place... but with reshaping I suspect it's untenable.Benches close to neutral on my machine