Replies: 3 comments 6 replies
-
There's a lot to unpack here but they are reasonable queries. The short answer is that I don't believe we have a great solution to this in the Rust ecosystem yet, you kind of have to do it yourself. For Prince these tasks are are all handled through the Mercury codebase, in which the bulk of Prince is implemented. As general guidance, Unicode is involved in much of this. Understanding character properties and reading some of the annexes is probably useful. Also the r21a apps can be good for exploring Unicode properties and text https://r12a.github.io/applist
I'll answer slightly out of order. Generally there shouldn't be a need to kern across groups of For each group of All that is to say line packing is a complex problem in its own right. The Unicode Line Breaking Algorithm is probably a good place to start https://www.unicode.org/reports/tr14/
You probably want to read up on the Unicode bidirectional algorithm: https://www.unicode.org/reports/tr9/ There is a crate implementing this: https://crates.io/crates/unicode-bidi
For a particular font there with be a nominal separation between lines described by
Allsorts does not include this. You need to lookup the Unicode script property of each input code point. unicode-script or another similar crate can help here. I'm sorry I'm not sure whether direction is handled before or after this.
Not 100% sure about this, although I did cover a bit of it in the first part about line packing. Maybe @mikeday has some thoughts. |
Beta Was this translation helpful? Give feedback.
-
Wrapping usually requires reshaping, for example if you were to hyphenate "difficult" as "dif-ficult" then you would shape it twice and get different results each time, the first might include an "ffi" ligature while the second would be shaping "dif-" and "ficult" as completely separate chunks as they appear on separate lines. |
Beta Was this translation helpful? Give feedback.
-
The CSS writing modes spec might be useful to look at. While the implementation is left up to you, it might be helpful for framing your thoughts about this kind of thing. For example things can get a bit more complicated as you no longer talk about X and Y, width and height etc. and instead you need to think in terms of the inline axis and block axis, etc. |
Beta Was this translation helpful? Give feedback.
-
The text shaper (
allsorts
) is an integral part of text rendering, but it's only one part. There are other elements needed for a robust, complete system:It's hard to find documentation on next steps online. There's Fonts and Layout for Global Scripts, Text Hates You, Text layout is a loose hierarchy of segmentation, and so on, but I can't clearly see where I should go next after I can render single calls to
Font::shape
onto the screen.For example:
How do I concatenate multiple calls to
Font::shape
? Should I concatenate theVec<Info>
s? What's the best way to do that? Should I kern between them, and if so, how?How should I mix multiple text directions?
(That example is extremely contrived, but still - I want to know!)
Is horizontal text always 1em tall and vertical text always 1em wide?
How do I parse an input string for scripts / directions? There's some crate for this, right? Does
allsorts
include any algorithm for it?How should I wrap text without Tracking the correspondence between input text and output glyphs #31? How do I handle ligatures when wrapping? Split them up, treat them as single units, ..?
Text layout is out of scope for
allsorts
specifically, but I feel like this is still a good place to ask a question like this. Please let me know if there's somewhere else I should go instead!Beta Was this translation helpful? Give feedback.
All reactions