Skip to content

Remove font-kit and pathfinder as dependencies#735

Open
pbdeuchler wants to merge 9 commits intoplotters-rs:masterfrom
pbdeuchler:pbd/remove-pathfinder-geometry
Open

Remove font-kit and pathfinder as dependencies#735
pbdeuchler wants to merge 9 commits intoplotters-rs:masterfrom
pbdeuchler:pbd/remove-pathfinder-geometry

Conversation

@pbdeuchler
Copy link
Copy Markdown
Contributor

The servo organization no longer maintains font-kit or pathfinder and has only been doing ad hoc PR fixes for failing builds. However as Rust continues to change things in the simd std lib crate pathfinder continues to break builds and it has been communicated that we should not rely on releases happening in the future.

This PR aims to completely remove font-kit and pathfinder dependencies in favor of the maintained fontique and swash crates. It uses fontique to discover system fonts and build an internal cache of available fonts, and swash for rendering.

Tradeoffs

We do lose subpixel AA rendering with this PR, however the introduction of swash will allow us to improve typographic quality with a future PR (which I already have in progress) that removes ttf-parser in favor of a 100% swash rendering backend, which would also mean improved support for ligatures and non-Latin fonts. swash also does slightly more allocations and is slightly less performant than pathfinder, but the perf difference here is extremely small and I doubt anyone will notice in real world usage.

Breaking Changes

I changed the error type in ttf.rs since the underlying types no longer apply, this could break some public API consumers

This PR will also up the MSRV to 1.88 and introduces memmap2 as a transitive dependency of fontique.

This is my first foray into the plotters internals, and my first time messing around with fonts/rasterization... I utilized my good friend Claude to guide me but let me know if there's anything that's missing or needs fixing here.

Comment thread plotters/src/style/font/ttf.rs Fixed
@pbdeuchler
Copy link
Copy Markdown
Contributor Author

fontique requires libfontconfig-dev to be installed on build, which is a bit unfortunate but I've added that to the github workflows

@pbdeuchler
Copy link
Copy Markdown
Contributor Author

@philocalyst @AaronErhardt let me know your thoughts on this, and if this is something you all are interested in. Would love to get plotters building on nightly without worry again. Thank you!

@philocalyst
Copy link
Copy Markdown

Thanks so much for tagging me! Still not a maintainer so I don't see as much of these as I wish to -- when it comes to Rust and the font stack there's a lot of movement still going on. I believe for rendering the main swash maintainer has actually been hired by the google fonts team -- so I think we should be using harfrust instead.

@pbdeuchler
Copy link
Copy Markdown
Contributor Author

man the rust ecosystem drives me absolutely nuts sometimes... that sounds fine to me, i'll take a look at that and get back to you

@philocalyst
Copy link
Copy Markdown

Thanks so much! I'll do another review when that's swapped, sorry for the duplicate work :(

Tests are definitely appreciated, good work there from my skim.

@pbdeuchler
Copy link
Copy Markdown
Contributor Author

pbdeuchler commented Apr 29, 2026

No worries. The more I look into this I wonder if there's a better approach. How do you feel about me refactoring things so that font lookup happens at the draw() call, and I can make the choice to not use system fonts a programmatic option. Then we can just create one font rendering path and remove the ab_glyph dependency/feature.

I'm pretty sure I can make this a backwards compatible change as well so we can just deprecate the existing feature/register function without removing it.

@philocalyst
Copy link
Copy Markdown

philocalyst commented Apr 29, 2026 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants