* 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
- 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
* Optimize BidiParagraphs with ASCII fast path - Added fast path for ASCII text that avoids BidiInfo allocation - Added some text shaping benchmarks
* refactor: fix clippy warnings and cleanup imports
* 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
Font family know gets used when querying the font.
Not sure if this solution is good, if the old code is even needed.
This works for me, which makes it good enough for me.
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.
Instead of blindly pushing default font to the start of the monospace
fallbacks map. Actually collect codepoint support info for it, and if
it supports all codepoints, skip collecting that info from other
monospace fonts. If it doesn't, push it to the start of the map as
before.
This actually provides a big performance boost, while the sophisticated
monospace fallback process is still done whenever needed.
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
When font fallback involves monospace fonts, and if word has known
scripts, limit the fonts tried for fallback to ones that support at
least one requested script.
Codepoint support info is still collected for these fonts to guide
the fallback order selection process.
A map of per-script monospace font-ids is pre-populated in font system
to acquire lists of wanted font ids efficiently.
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
For the simplest case of " " words, a quick binary search in
`supported` vec will suffice, instead of using `slice::contains()`
for all monospace fonts, where some of them may support thousands of
codepoints.
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
When matching on weights smaller than normal, "equal or smaller"
weight restriction may cause monospace fallback to fail, depending
on font support at such weights for the text to be shaped.
So remove that restriction, and calculate weight differences instead
of offsets.
In case of no exact weight match, and with all other factors being
equal, smaller weights will be picked before bigger ones. So, this
should generally not cause any behavioral changes when matching on
normal weight or bigger.
Should fixpop-os/cosmic-term#104.
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
`Attrs` contains info like color and metadata which are not relevant
to font matching.
So, add a new struct `FontMatchAttrs` which only contains the relevant
info, and use it as a key in `FontSystem`'s `font_matches_cache`.
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>