Tobias Hunger
9a881f9a90
Clippy 0 2 3 ( #1203 )
...
* janitor: Fix clippy error in textlayout.rs
This one is almost certainly a bug.
* janitor: clippy fixes in inline_expressions.rs
Clippy claims the original code was slower and less clean, so let's
change this.
2022-05-02 13:23:35 +02:00
Simon Hausmann
cb2a555c90
mcu: fall back to breaking text anywhere if we can't find with given break opportunities
...
cc #843
2022-04-14 10:58:04 +02:00
Simon Hausmann
cd932d8cf9
MCU: fix text being cut in the printer demo sometimes being cut off ( #1083 )
...
* MCU: fix text being cut in the printer demo sometimes being cut off
When a text element is rendered at exactly the width it reports,
then last letter would be cut off.
* Adjust elision test
2022-03-21 18:47:35 +01:00
Simon Hausmann
cfe2bc1329
Fix comment
2022-03-10 10:51:32 +01:00
Simon Hausmann
20597a0296
Simplify line layout callback signature
...
The last argumen is unused
2022-03-10 10:51:32 +01:00
Simon Hausmann
4e18291290
Rename linebreak_ascii to linebreak_simple
...
It's not just strict ascii
2022-03-10 10:51:32 +01:00
Simon Hausmann
7cf5a6a197
Simplify line layout API
...
Use a struct for all the parameters
2022-03-10 10:51:32 +01:00
Simon Hausmann
5e9a3b8ed1
Remove unnecessary refcell/vec
2022-03-10 10:51:32 +01:00
Simon Hausmann
1d1b13e4d6
Clean up line break "abstraction"
...
Use unicode-linebreak's enum directly and ony use a custom enum in the fake
module.
2022-03-10 10:51:32 +01:00
Simon Hausmann
7ba8ea156b
Fix up small TODO comments
2022-03-10 10:51:32 +01:00
Simon Hausmann
51e0d17092
Add a test for elision
2022-03-10 10:51:32 +01:00
Simon Hausmann
33ae882506
Avoid shaping text twice per line when drawing paragraphs
...
Track the glyph range in the TextLine and use that to access the glyph buffer,
instead of calling shape_text() again.
2022-03-10 10:51:32 +01:00
Simon Hausmann
247847cb54
Avoid unnecessary glyph buffer re-allocations
...
Store the result of all text shaping calls in one glyph buffer when laying out a
a paragraph of text.
This paves the way of avoiding unnecessary shape_text calls when processing lines.
2022-03-10 10:51:32 +01:00
Simon Hausmann
35f245687a
Make it possible to build the text layout without unicode linebreak tables
2022-03-10 10:51:32 +01:00
Simon Hausmann
187294c00e
Simplify glyph interface in TextShaper
...
* Impose no bounds on the associated Glyph type
* Report the byte offset only in shape_text - it doesn't belong into an aritrary glyph
* Move querying the advance into the TextShaper, where the MCU implementation can deal with missing glyphs
without storing fallback values in the Glyph type
2022-03-10 10:51:32 +01:00
Simon Hausmann
87431eea95
Make it possible to build without unicode-script
2022-03-10 10:51:32 +01:00
Simon Hausmann
38e26f25ef
Basic elision support
...
TODO:
* alignment for rtl/ltr
* elide only last line for multi-line
2022-03-10 10:51:32 +01:00
Simon Hausmann
8d4c645346
Change the paragraph text layout callback to take glyphs
...
This is needed in the future to avoid duplication shaping and
implementation of features like elision or letter spacing in a shared code.
2022-03-10 10:51:32 +01:00
Simon Hausmann
ff2b38eefb
Minor clean up in paragraph layout
...
Encapsulate the entire loop body in the process_line helper
2022-03-10 10:51:32 +01:00
Simon Hausmann
a947ec1441
Simplify glyph interface
...
The textlayout module does not need to impose the exact glyph struct layout.
This paves the way for glyph based rendering.
2022-03-10 10:51:32 +01:00
Simon Hausmann
42a0f605ad
Add an paragraph layout helper function to the corelib textlayout
...
The objective is to use this in the MCU backend and replace layout_text_lines() in the GL backend in the future.
2022-03-10 10:51:32 +01:00
Simon Hausmann
6748563dc6
Fix non-wrapped text with multiple break opportunities
2022-03-10 10:51:32 +01:00
Simon Hausmann
62d633a572
Add convenience function for measuring paragraph sizes
2022-03-10 10:51:32 +01:00
Simon Hausmann
72186cd891
Make the available width an option
2022-03-10 10:51:32 +01:00
Simon Hausmann
1a73460a6a
Add basic text layout module for use with the MCU
...
This is based on the unicode line breaking algorithm (uses crate for
that), which also supports forced line breaks. The shaping is generic,
so on the MCU side we can do without at first.
2022-03-10 10:51:32 +01:00