Skip to content

Commit

Permalink
Text/multiline (#134)
Browse files Browse the repository at this point in the history
Replaces #103 (which used dwrite and direct2d crates instead of raw_d2d).

Line breaking algorithm is naive. Iterates down text, checking width of each possible break.

    implement new methods for multiline in `TextLayout'
        update_width
        line_text
        line_metric
        line_count
        and fix d2d width to include trailing whitespace

    update hit testing
        account for multiline
        if out of bounds top or bottom in y axis, will hit test closest line to boundary
        all hit testing includes trailing whitespace

    lots of tests
        basic multiline and hit testing for d2d and cairo and web
        new test harness (using wasm-pack) for web


* [cairo] refactor text to own module

* [web] refactor text to own module

* [svg] text own module, [all] fmt, some clippy

* [all] clippy

* [all] clippy

* [d2d] refactor text in own module

* [d2d, piet] clippy warnings

* cargo fmt

* [text] add docstring to module

* [d2d] fix pub use issue

* [text] update TextLayout trait for linebreaking, (nullrender)

* [text] line break methods use &self

* [text] remove comments

* [text] update method signatures

* [text] update line methods to return Option

* [text] add width to constructor

* [wip, piet] update LineMetrics, Clone for TextLayout, fix pic examples

* [piet] update LineMetrics fields

* [all] TextLayout: Clone bound

* [d2d] stub multiline text methods, text layout update

* [svg, web, cairo] stub multiline trait methods, fix new_text_layout (fix errors for CI)

* [cairo] pass tests with new new_text_layout

* [all] cargo fmt

* [cairo] forgot grapheme test

* [cairo] fmt grapheme test

* [d2d] fix tests for new new_text_layout

* [text] update multiline LineMetric api

* [text] cum width to width for LineMetrics

* [text] update line_metric to return value

* [text] fix docstring

* [d2d] line metrics module

* [d2d] wire linemetrics to textlayout api

* [d2d] update_width for textlayout

* [d2d] note on &mut in api?

* [text] update docstrings for linemetric

* [d2d, text] update_width takes &mut self

* [d2d] comment for future testing for multiline hittest

* [cairo] line metrics first pass

* [cairo] text layout notes, guess for baseline

* [cairo] notes on trailing whitespace, vertical measures

* [cairo] use fontextents for height and baseline

* [text] remove width field from LineMetric

* [cairo] move linemetrics to own module

* [cairo] count trailing whitespace

* [cairo] fix linemetrics implementation

* [cairo] multiline tests and bugfix

* [d2d] fix test

* [cairo] impl line metrics for TextLayout

* [cairo] more leeway on line metrics tests

* [cairo] even more leeway on line metrics tests (cum height)

* [cairo] futz with test widths, try to get osx tests to pass

* [cairo osx] change font to try to get tests to pass

* [cairo] implement hittesttextposition using line metrics and width

* [cairo] notes

* [cairo] tests for httextposition, fix http and lines impl

* [cairo] http test for osx try again

* [cairo] separate multiline http test for osx

* [cairo] try macos test again

* [cairo] refactor hittestpoint and graphemes to prep for y component

* [cairo] clean test warning

* [cairo] implement y axis on hit test point

* [cairo] test for htp multiline, fix bugs in htp and http

* [cairo] htp macos test

* [cairo] comments and debug cleanup

* [cairo] get width as iterator

* [cairo] clean comments, dbg

* [text] update TextLayout docs

* [web] linemetric module, and build textlayout with

* [web] impl line metric and width trait methods

* [web] hit testing with multilines

* [web] fix some comments

* [web] move tests to text module from example, use wasm-pack test framework

* [web] multiline hit test tests

* [web] readme notes on running tests

* [d2d] bugs, hit testing

- hit testing tests
- fix bug in hit testing `trailing` bool
- in `width`, use width with trailing whitespace
- note that when y is past boundary for hit testing point, x still
affects the text position

* [cairo] hit testing does not hide trailing whitespace

* [web] hit testing does not hide trailing whitespace

* [cairo] hit testing for x even if y out of bounds

* [web] hit testing for x even if y out of bounds

* [text] when y above bounding box, x still hit tested on first line

* [cairo] test hard break in `lines`

* [web, cairo] fix web test warnings, make lines ard break test linux only
  • Loading branch information
hwchen committed Apr 9, 2020
1 parent 569baa2 commit dff29a3
Show file tree
Hide file tree
Showing 18 changed files with 2,997 additions and 752 deletions.
1 change: 1 addition & 0 deletions piet-cairo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ categories = ["rendering::graphics-api"]
[dependencies]
piet = { version = "0.0.11", path = "../piet" }
unicode-segmentation = "1.3.0"
xi-unicode = "0.2.0"

[dependencies.cairo-rs]
version = "0.8.1"
Expand Down
Loading

0 comments on commit dff29a3

Please sign in to comment.