33 Commits

Author SHA1 Message Date
Laurenz
3d2ee54848 Refactor and comment ♻ 2021-04-07 01:08:07 +02:00
Laurenz
de20a21a58 Reshaping with unsafe-to-break
Co-Authored-By: Martin <mhaug@live.de>
2021-04-05 22:32:09 +02:00
Laurenz
9014e83478 Fix multi-page paragraph bugs 🐞 2021-04-03 21:12:32 +02:00
Laurenz
d74c9378b8 New paragraph layout 🚀
The previous paragraph layout algorithm had a couple of flaws:
- It always produced line break opportunities between runs although on
  the textual level there might have been none.
- It didn't handle trailing spacing correctly in some cases.
- It wouldn't have been easily adaptable to Knuth-Plass style optimal
  line breaking because it was fundamentally structured first-fit
  run-by-run.

The new paragraph layout algorithm fixes these flaws. It proceeds
roughly in the following stages:
1. Collect all text in the paragraph.
2. Compute BiDi embedding levels.
3. Shape all runs, layout all children and store the resulting items in
   a reusable (possibly even cacheable) `ParLayout`.
3. Iterate over all line breaks in the concatenated text.
4. Construct lightweight `LineLayout` objects for full lines instead of
   runs. These mostly borrow from the `ParLayout` and only reshape the
   first and last run if necessary. The design allows to use Harfbuzz's
   UNSAFE_TO_BREAK mechanism to make reshaping more efficient. The size
   of a `LineLayout` can be measured without building the line's frame.
5. Build only the selected line's frames and stack them.
2021-04-03 21:09:17 +02:00
Laurenz
8245b7b736 Baseline alignment ⏏ 2021-03-30 21:43:12 +02:00
Laurenz
c00cca3677 Refactor ♻ 2021-03-30 16:19:16 +02:00
Laurenz
79948c0c5e BiDi reordering 🔃
Co-Authored-By: Martin <mhaug@live.de>
2021-03-30 14:31:50 +02:00
Laurenz
c393eccd36 Fix space/newline trimming 🐞
Co-Authored-By: Martin <mhaug@live.de>
2021-03-30 14:31:46 +02:00
Laurenz
652986fd58 Fix double leading 🐞 2021-03-30 14:31:39 +02:00
Laurenz
88da325c7d Fixed par layouter directions 🗜 2021-03-29 15:02:15 +02:00
Laurenz
309b8f20a8 Line break iterating run shaper 🌵
Co-Authored-By: Martin <mhaug@live.de>
2021-03-29 15:02:15 +02:00
Laurenz
8c27dc1010 Write spaces and linebreaks into text runs ✒ 2021-03-29 15:02:15 +02:00
Laurenz
57ca9628c1 Better space coalescing logic 🌧
This creates a smaller state machine helper type for softness coalescing, which does not own the resulting nodes. While this creates a bit more duplication in stack and par builder, it makes it a lot easier to integrate additional logic into the paragraph builder.

Furthermore:
- Line breaks are now "hard", that is, not coalesced with each other.
- Text nodes with equal style are now merged allowing for example `f{}i` to form a ligature.
2021-03-27 21:52:39 +01:00
Laurenz
76fc4cca62 Refactor alignments & directions 📐
- Adds lang function
- Refactors execution context
- Adds StackChild and ParChild enums
2021-03-25 21:32:33 +01:00
Laurenz
898728f260 Square, circle and ellipse 🔵 2021-03-20 20:19:30 +01:00
Laurenz
264a7dedd4 Scheduled maintenance 🔨
- New naming scheme
  - TextNode instead of NodeText
  - CallExpr instead of ExprCall
  - ...
- Less glob imports
- Removes Value::Args variant
- Removes prelude
- Renames Layouted to Fragment
- Moves font into env
- Moves shaping into layout
- Moves frame into separate module
2021-03-19 17:57:31 +01:00
Laurenz
584a43277d Rename ChildAlign to LayoutAligns ✏ 2021-03-12 14:12:30 +01:00
Laurenz
c1b1dbcc09 Better expansion behaviour 🐪
This makes expansion behaviour inheritable by placing it into the area and passing it down during layouting instead of computing some approximation of what we want during execution.
2021-03-11 10:48:29 +01:00
Laurenz
bbb9ed07ff Better line spacing calculations ↕
- Only add line spacing between lines. Previously, line spacing was added below
  every line, making `#box[word]` higher than just `word`.
- Compute box height of text as `ascender - descender` so that the full word is
  contained in the box.
2021-03-10 10:20:01 +01:00
Laurenz
b2b8d37ce0 Rename run to line and add some explanatory comments ✏
The name run was a relict of the time where a line consisted of a set of runs with same alignment. While these runs still exist conceptually, they are all stored flatly together in what was now renamed from `run`  to `line`.
2021-03-09 17:25:25 +01:00
Laurenz
84ba547c7c If expressions 🔀 2021-01-20 21:33:13 +01:00
Laurenz
272a4c2289 Unbounded pages 🌌 2021-01-13 23:19:44 +01:00
Laurenz
2e77b1c836 Better value representations, type function 🌐 2021-01-04 21:29:15 +01:00
Laurenz
aae67bd572 Move and rename many things 🚛 2021-01-03 00:12:09 +01:00
Laurenz
91e5120693 BoxAlign and Flow aliases ✏ 2020-10-13 13:51:58 +02:00
Laurenz
8680fcd490 Rename geometric eval and apply to resolve ✏ 2020-10-13 13:24:33 +02:00
Laurenz
1a70cb6a33 Naming and grammar ✔ 2020-10-12 18:01:22 +02:00
Laurenz
5243878d81 Less vecs in layouting 2020-10-12 17:29:01 +02:00
Laurenz
38157b0e0c Synchronous layout 🪀 2020-10-12 17:10:01 +02:00
Laurenz
a2a68106c0 Evaluation benchmark 🔋 2020-10-11 23:18:00 +02:00
Laurenz
1b3eb42003 Refactor paragraph layout 📰 2020-10-11 22:41:21 +02:00
Laurenz
f04ad0ffa5 Rename LayoutItem to Layouted ✏ 2020-10-11 13:08:27 +02:00
Laurenz
92c01da360 Switch back to custom geometry types, unified with layout primitives 🏞 2020-10-10 22:19:36 +02:00