Commit graph

66 commits

Author SHA1 Message Date
Dov Reshef
8db03fe3cf Add image render tests
Add tests that will match rendered words/paragraphs against reference
images.

Use env var `GENERATE_IMAGES` to write the initial reference images to
the repository.
2023-09-27 11:57:18 +03:00
Huang-Huang Bao
331710a16f
Use self_cell for creating self-referential struct
Remove indigenous unsafe self-referential implemention which has a lesser chance to be audited.
2023-09-19 02:16:23 +08:00
Jeremy Soller
33706262f6
Update all dependencies 2023-09-18 08:57:01 -06:00
Huang-Huang Bao
32c4fd2a0f
Set MSRV to 1.65
The MSRV was scanned by cargo-msrv, the result shows src/buffer.rs uses let - else statements which requires rust 1.65.0.
This also reformat the Cargo.toml.
2023-09-15 19:52:53 +08:00
Imbris
91674d5a49 Fix #134 and include a test for it.
Try to ensure that using "the width computed during an unconstrained
layout" as the width constraint during a relayout produces the same
layout. This is useful for certain UI layout algorithms.

See https://github.com/pop-os/cosmic-text/issues/134

* Instead of computing the LayoutLine width from the positioned and
  aligned glyphs, we pass through width computed during line wrapping
  (unless justified alignment is used, in this case we use the old
  approach because the use case for measuring the width isn't really
  applicable to justified text since that will just expand to the
  provided width). For the produced width to later give the same
  wrapping results when passed in as the `line_width` it needs to use
  the same exact float arithmatic that was used to compute the width
  that is compared against `line_width` when making line wrapping
  choices. Passing this width through as the LayoutLine width is the
  most covenient option without making more major changse to the API.
  Nevertheless, I am imagining that if we get a dedicated measurement
  method (i.e. that doesn't do the final positioning and alignment of
  glyphs and which caches `Vec<VisualLine>`), then this width can just
  be exposed there instead of preservering it in LayoutLine.
* Incidentally, this fixes
  https://github.com/pop-os/cosmic-text/issues/169.
* Switch substraction from `fit_x` to checking whether potential
  addition to the current line width would exceed the `line_width`. This
  avoids the float error being dependent on the provided `line_width`
  value.
* When eliminating trailing space from the line width, we avoid
  backtracking with subtraction (which would not give the same exact
  value due to float error) and instead save the previous width and use
  that.
* If the previous word did not exceed the line_width, we now include a
  single blank word even if it would cross the width limit since its
  width won't be counted. This is necessary to get the same wrapping
  behavior when re-using the measured width (which doesn't count a
  single trailing blank word). Note, this whitespace logic may be
  reworked anyway if <https://github.com/pop-os/cosmic-text/issues/155>
  is addressed.
* Change tests to use `opt-level=1` to keep test runtime down.
* Add `fonts` folder for fonts used in tests.
* Fix an issue where a non-breaking whitespace was assumed to be the
  start of a section of spaces which included characters that weren't
  even whitespace.
* Add some TODOs about incongruencies between `is_whitespace`,
  justification, and line breaks.
2023-08-25 21:00:46 -04:00
Jeremy Soller
665d3d86b9
Merge pull request #174 from urlordjames/fontconfig_default
enable fontconfig feature by default
2023-08-23 14:10:22 -06:00
urlordjames
0adbd45654 enable fontconfig feature by default 2023-08-23 11:11:51 -04:00
urlordjames
ace8560493 enable std feature with fontconfig feature 2023-08-23 10:54:48 -04:00
John Nunley
99d3d71a0f Add benchmarks to accurately gauge improvements
Signed-off-by: John Nunley <dev@notgull.net>
2023-08-16 14:09:55 -07:00
genusistimelord
bd4b6cea3b
Add feature to allow fontdb to get fontconfig features for systems that dont auto have this support 2023-08-16 15:14:55 -04:00
grovesNL
14d0ceb81b Move hashbrown behind no_std feature 2023-08-09 10:19:24 -02:30
John Nunley
faa1ceafda Unify the no_std and std impls of FontSystem 2023-07-24 08:51:19 -07:00
John Nunley
e65bcbc4d3
Change to a feature 2023-07-22 08:24:28 -07:00
Jeremy Soller
7d50d17369
0.9.0 2023-07-06 07:37:03 -06:00
Jeremy Soller
3640b5e1ef
Update rustybuzz to 0.8.0 2023-06-12 11:13:51 -06:00
Jeremy Soller
bb176df59e
Merge pull request #128 from tigregalis/fontdb-0-14
bump `fontdb` to 0.14.1
2023-06-08 12:43:13 -06:00
bjorn3
95e36249d5 Remove the dependency on ouroboros
This reduces compilation time by removing a dependency on syn and other
dependencies of ouroboros_macros. In addition it saves a lot of unused
codegened methods.

On my laptop (2 core + HT) this reduces compilation time by ~20%. On a
many core system this doesn't help much though as the critical path path
consists of both ttf-parser -> rustybuzz and swash. Further gains will
likely need to be made by reducing compilation time for these crates.

Benchmark 1: cargo build
  Time (mean ± σ):     25.150 s ±  0.167 s    [User: 84.414 s, System: 7.335 s]
  Range (min … max):   24.909 s … 25.444 s    10 runs

Benchmark 1: cargo build
  Time (mean ± σ):     19.819 s ±  0.226 s    [User: 67.754 s, System: 5.592 s]
  Range (min … max):   19.492 s … 20.140 s    10 runs

The code is based on an expansion of the ouroboros macro, cleaned up to
remove all unused methods and inline most functions that are only called
once.
2023-06-08 18:00:42 +02:00
tigregalis
9c4fd35d8e bump fontdb to 0.14.1 2023-05-12 11:11:13 +08:00
Christopher Serr
a8546df7b3 Fix WebAssembly support
There was a problem in the upstream `sys-locale` crate where it assumed
that every WebAssembly target can use `wasm-bindgen` just fine. This
however is not the case, as `wasm-bindgen` and the ecosystem around it
are specifically to target the web. In reality there however are at
least the following 4 "targets" (with possibly more in the future):
 - WebAssembly on the web
 - Freestanding WebAssembly
 - WebAssembly with WASI
 - WebAssembly with Emscripten

These are all supported properly through `sys-locale` 0.3.0 now. However
because "WebAssembly on the web" unfortunately is not its own target and
instead uses `wasm32-unknown-unknown`, just like freestanding
WebAssembly, the only way to differentiate between them is through a
feature. This is the best practice and is done throughout the ecosystem.
Here the feature `wasm-web` is introduced that properly forwards it to
`sys-locale` and possibly other crates in the future.
2023-04-04 17:22:00 +02:00
Jeremy Soller
3224daa66f
0.8.0 2023-04-03 08:27:28 -06:00
Edgar Geier
bff5aaaea3
Make FontSystem not self-referencing 2023-03-12 10:23:54 +01:00
Edgar Geier
7e6368a4fc
Bump rustybuzz version to 0.7 2023-03-03 13:20:32 +01:00
Edgar Geier
2c1d564d62
Update fontdb dependency to version 0.13 2023-03-03 13:07:49 +01:00
Jeremy Soller
eca804c732
Revert "Make FontSystem not self-referencing and update fontdb and rustybuzz" 2023-03-02 18:16:57 -07:00
Edgar Geier
20234f8d11
Bump rustybuzz version to 0.7 2023-03-03 00:53:00 +01:00
Edgar Geier
f8bc71af0a
Update fontdb dependency to version 0.13 2023-03-03 00:53:00 +01:00
Edgar Geier
506a4194be
Make FontSystem not self-referencing 2023-03-03 00:53:00 +01:00
Jeremy Soller
0d7308b775
0.7.0 2023-02-07 12:28:48 -07:00
Andrew Wheeler
8614a7a398 Updated RangeMap to Add Clear(). 2022-12-30 08:33:00 -07:00
Jeremy Soller
cf9bf26d49
0.6.0 2022-12-20 09:03:39 -07:00
Jeremy Soller
0e302e540a
0.5.6 2022-12-20 08:58:17 -07:00
Jeremy Soller
82d5fc02a5
0.5.5 2022-12-16 13:51:05 -07:00
Jeremy Soller
21e0078d25
cargo upgrade 2022-12-14 09:21:42 -07:00
Jeremy Soller
d54af47d9d
0.5.4 2022-12-14 09:19:20 -07:00
Jeremy Soller
cdf36db03d
0.5.3 2022-12-13 09:23:50 -07:00
Jeremy Soller
6660a1d95b
0.5.2 2022-12-08 11:33:53 -07:00
Jeremy Soller
69e41a558c
0.5.1 2022-12-08 10:32:10 -07:00
Jasper Bekkers
e6df88f698
Add cargo-deny to the CI of this crate (#45) 2022-11-21 04:40:06 -07:00
Jeremy Soller
425f741982
0.5.0 2022-11-15 12:27:23 -07:00
Jeremy Soller
ee54e7626b
Vi-style editor and other editor improvements (#40)
* WIP VI wrapper for editor

* WIP: block cursor

* Create Edit trait, run CI on all feature options

* Add prints describing build steps to ci.sh

* Custom rendering for Vi editor

* Clippy fixes

* More clippy fixes

* Show clippy results in CI

* Fix for Redox

* Fix clippy lint

* Add vi feature to enable vi-style editor

* Add escape to libcosmic text box
2022-11-15 12:26:59 -07:00
Andrew Wheeler(Genusis)
271ca5cf7a
Converted attr range to use RangeMap BTree (#41)
* Converted attr range to use RangeMap BTree

* Change get_span() to use First index instead of range.

* update doc comment
2022-11-14 11:05:34 -07:00
Jeremy Soller
1663bfc96c
Add SyntaxEditor abstraction using optional synect feature 2022-11-09 10:09:42 -07:00
Jeremy Soller
f0b6afdf69
0.4.1 2022-11-08 13:25:21 -07:00
Jeremy Soller
268805ba0c no_std support 2022-11-08 13:24:14 -07:00
Hugo Osvaldo Barrera
ae25b6c1b9 Add links to repo and docs in Cargo.toml
This will add a link to the repository in docs.rs, and both links to
crates.io.
2022-11-04 12:46:57 -06:00
Jeremy Soller
093a6081bc
0.4.0 2022-11-04 10:39:00 -06:00
Ian Douglas Scott
0d3fb1dd9d Use ouroboros in FontSystem to avoid lifetime bound
Perhaps not quite what ouroboros is expected to be used for, but it's
not too bad, and avoiding the lifetime bound can be a huge help.
2022-11-04 10:37:32 -06:00
Jeremy Soller
b0ec548a5e
0.3.0 2022-10-31 11:40:01 -06:00
Jeremy Soller
4e2e41470b
0.2.2 2022-10-27 18:29:41 -06:00
Jeremy Soller
52be09ec17
0.2.1 2022-10-27 15:00:23 -06:00