Commit graph

138 commits

Author SHA1 Message Date
Adam Kowalski
c6ce5e69e5 fix: use dynamic font probing to preserve ligatures across break opportunities 2026-01-29 09:04:48 -07:00
Adam Kowalski
5d1db4992a chore: extend fix to != and ++ ligatures, match existing test style 2026-01-29 09:04:48 -07:00
Adam Kowalski
d391a3a166 chore: add unit test and improve comment 2026-01-29 09:04:48 -07:00
Adam Kowalski
8c8c41b05b fix: prevent line break splitting |> ligature sequence
The unicode-linebreak crate treats the pipe character '|' as a break opportunity (BA/AL class). This causes ShapeSpan::build to split text like '|>' into separate ShapeWords. When these words are shaped independently, the font shaping engine cannot form ligatures that cross the word boundary.

This patch manually checks for the '|>' sequence during segmentation and skips the break opportunity, ensuring they remain in the same shaping run.

Added a unit test 'ligature_segmentation' to verify that '|>' remains a single word.
2026-01-29 09:04:48 -07:00
Todd York
2729d2d49c Refactor override_fake_italic() 2026-01-16 10:43:22 -07:00
Todd York
a288f1d775 Shape as fake italic if no matching italic font exists 2026-01-16 10:43:22 -07:00
ickshonpe
8cd21a315a The ASCII fast path assumes that the current word has only one attributes span, when it can intersect multiple attribute spans.
This commit adds a check to ensure that all the attribute spans intersecting the word range are compatible before taking the fast path.
Fixes #445
2025-12-22 06:53:47 -07:00
Héctor Ramón Jiménez
d779057d9c Replace magic boolean with new Hinting enum 2025-12-01 13:59:55 -07:00
Héctor Ramón Jiménez
48eda6bd7d Draft metrics hinting support 2025-12-01 13:59:55 -07:00
Jeremy Soller
8a7bc790e5
Round x_advance to nearest monospace width when requested, fixes #237 2025-11-03 15:09:58 -07:00
valadaptive
2610c869f6
Replace rustybuzz with HarfRust (#417)
* Use HarfRust for shaping

* Replace ttf-parser with skrifa entirely

* Fix clippy lints

* Add shape plan cache

* Bump harfrust and skrifa

* Fix no_std build

* Simplify the shape plan cache

* Please the paperclip

* Cache font ID with plan

* Tune shape plan cache for "BiDi Processing" bench
2025-09-08 21:15:27 -06:00
romanstingler
a2f1f4b2a0
refactor: address clippy warnings and improve code quality (#409)
- Fix string formatting with modern interpolation syntax
- Improve Debug implementation with finish_non_exhaustive()
- Fix function placement in shape.rs to avoid items_after_statements warning
- Use more idiomatic Rust patterns (map_or_else, next_back)
- Clean up conditional imports in vi.rs
- Convert multiple methods to `const` functions for optimization and consistency
- Introduce `core_maths` for enhanced no-std compatibility
- Update `Cargo.toml` for the new optional dependency and feature adjustments
2025-08-11 13:58:59 -06:00
romanstingler
de355a1fd9
feat: add ASCII fast path optimization to ShapeWord::build() (#407)
- Skip expensive grapheme iteration for simple ASCII words
- 32% performance improvement for code-like text
- 5-7% improvement for general ASCII content
- No regressions for Unicode text processing
- Conservative ASCII detection maintains correctness
2025-08-04 13:49:52 -06:00
Wren [Undefined]
a03faa654d
Variable font support (#400)
* Variable font support

Here's a pretty naïve solution for variable fonts.

The iterator doesn't use the match keys' weight, but instead tries to
get the requested ideal weight, if the font is variable, otherwise it is
ignored and the actual (non-variable) weight is used. This is because I
didn't implement finding variable weight support for match keys; doing
so would be impossible without parsing TTF files when matching and I
didn't want to add that potentially expensive infrastructure if not
entirely necessary.

This is a breaking change, and I'm open for ideas on how to fix that
if it's an issue.

* cargo fmt

* Add variable font example to rich-text example
2025-07-07 08:50:40 -06:00
Jeremy Soller
bcfb05a390
Revert "Round glyph advance to integer sizes (#384)"
This reverts commit 987ff45ff2.
2025-06-22 13:05:00 -06:00
Taj Pereira
c597f3755b
Update peniko version to 0.4.0 (#387)
* Update peniko version

* Fix no_std build
2025-05-30 04:50:41 +08:00
mahkoh
987ff45ff2
Round glyph advance to integer sizes (#384)
This is in line with [1].

[1]: https://skia.googlesource.com/skia/+/refs/heads/chrome/m136/src/ports/SkTypeface_fontations.cpp#539
2025-05-14 15:00:30 -06:00
Stewart Connor
e828131c92 fix for test.sh 2025-03-31 17:03:51 +11:00
Stewart Connor
53763c157b Merge branch 'refs/heads/main' into stewart-add-kerning-ligatures
# Conflicts:
#	src/attrs.rs
2025-03-31 13:42:12 +11:00
Stewart Connor
08822cac2e add letter spacing 2025-03-28 15:55:47 +00:00
Stewart Connor
71b0680e6f revert the references 2025-03-26 17:06:24 +11:00
Stewart Connor
fb852d3ab5 changes before ref 2025-03-26 14:48:54 +11:00
Stewart Connor
1d7850099f pre-removing copy 2025-03-26 14:31:37 +11:00
Stewart Connor
f5879b3425 add contextual alternatives 2025-03-21 18:24:32 +11:00
Stewart Connor
50373cd6d7 formatting 2025-03-21 18:03:15 +11:00
Stewart Connor
2d67e31bf1 format 2025-03-21 17:56:14 +11:00
Stewart Connor
81ca98d5db more explicit about setting features 2025-03-21 17:12:38 +11:00
Stewart Connor
d071d1a1c3 add kerning ligatures 2025-03-19 17:45:30 +11:00
valadaptive
c7a426280b Use chr_idx for ShapeGlyph range in basic shaping
We want byte indices, not code point indices. Fixes a panic when
selecting the mixed-language text at the bottom of the rich-text example
when the shaping mode is set to "Basic".
2025-03-10 11:23:36 -06:00
valadaptive
db9033ba86 Fix glyph start+end indices in "Basic" shaping
These indices were previously relative to the start of the *run*, when
they should be relative to the start of the *line*.
2025-03-10 11:23:36 -06:00
dsgallups
485497973f chore: updating newfound lints 2025-01-22 17:00:01 -07:00
dsgallups
f05a69a9d9 resolve all lints, update MSRV 2025-01-22 17:00:01 -07:00
Jeremy Soller
1f4065c1c3
Drop ShapePlanCache
The ShapePlanCache was added to improve performance when shaping the same
strings over and over. However, it never had the ability to be trimmed
and when it was moved to FontSystem, this created a permanently growing
allocation. It is recommended to instead use the shape-run-cache feature
which supports trimming if it is desired to have higher performance for
repeated shaping, at the cost of manually specifying when to trim.
2024-11-06 18:59:56 -07:00
dekrain
4fe90bb612 Fix the character index used for getting a glyph attribute in basic shaping 2024-09-23 07:53:29 -06:00
koe
9dc024616b move ShapeBuffer to FontSystem 2024-09-03 15:59:15 -06:00
koe
c65f299e87 fix no_std 2024-09-01 15:00:17 -06:00
koe
b68f4ad5c6 Optimize Buffer::set_rich_text for when the buffer is reconstructed 2024-09-01 15:00:17 -06:00
Jeremy Soller
8bb45d7aca
Shape tabs as spaces, fixes #248 2024-06-12 10:34:19 -06:00
Jeremy Soller
93a7df859a Allow for undefined buffer width and/or height, fixes #70 2024-06-12 09:14:56 -06:00
Jeremy Soller
b288de13ae Allow layout to be calculated without specifying width 2024-06-12 08:00:33 -06:00
Jeremy Soller
3c94352f3f Support expanding tabs 2024-06-10 08:12:42 -06:00
Jeremy Soller
6eb67bb524
Use default metrics for empty lines, fixes #258 2024-06-07 11:27:49 -06:00
Jeremy Soller
21e88ebc45
Move line height calculation to LayoutLine 2024-06-07 10:52:26 -06:00
Jeremy Soller
020701734e Address review 2024-06-06 19:38:40 -06:00
Jeremy Soller
37688747e1 Use line height from attrs 2024-06-06 19:38:40 -06:00
Jeremy Soller
8638ec29bb Add metrics to attributes 2024-06-06 19:38:40 -06:00
Christopher Serr
8582173128 Fix no_std build
This fixes the `no_std` build and also makes sure it's tested properly
in the CI workflow.
2024-02-12 10:37:49 -07:00
Jeremy Soller
0cb6eba6e7
0.11.2: Fix glyph start and end when using shape-run-cache 2024-02-09 15:12:33 -07:00
Jeremy Soller
1eb3233373
Add shape-run-cache feature, that can significantly improve shaping performance 2024-02-08 11:12:41 -07:00
dtzxporter
de587b3f50 Only commit a previous word range if we had an existing visual line.
Fixes #155, and also fixes Word::Wrap when two buffer overflowing words are next to each other.
2024-02-02 12:53:48 -07:00