plotters
plotters copied to clipboard
Add `ab_glyph` font backend
I've been using plotters in a situation where caring about system fonts is unimportant, and having font-kit in my dependency tree has been causing me unnecessary problems. This PR introduces a feature gated font rendering backend based on https://github.com/alexheretic/ab-glyph, which doesn't have those problems for me.
I am willing to restructure or completely rewrite this code as necessary to get some form of this feature merged- I can't say I'm certain this is the best API for it. I can also, and probably should also, add documentation and tests for it. Lemme know what you think is best and I'll do it.
Hi there, sorry for a long delay. This is very helpful, and I just rebased the code. Just wondering if you are still interested in working on this PR, if yes I can send a PR to you for the rebase, otherwise I am going to work on my branch to finish this.
Please check https://github.com/plotters-rs/plotters/tree/ab_glyph_font_backend for the rebase
Thanks for the contribution and please don't mind the delay!
Yes! I'm absolutely still interested in working on this.
Thanks a lot for working on this! I am using plotters in my home automation system which runs on a Pi. Without font-kit cross-compiling will be a breeze!
I just did a clean interactive rebase against master, after staring at the changes and your own rebased branch. Gonna do some testing to make sure it still works, then the next thing to do will be redesigning the API. There's some internal stuff that definitely needs fixing, as this code relies on unwinding to break out of a callback on failure.
I have a branch here which fixes the vertical alignment of glyphs.
I have a branch here which fixes the vertical alignment of glyphs.
Cool. I've tested it in my case and it looks like it works, so I'll go ahead and pull your branch here.
I gave up on trying to refactor things to avoid the panic reliance, and just added a buffer instead. As of now, this branch is functional enough to merge. It works where I've been using it (just as it has for... a while).
All that's left to do is fix the tests I guess I broke, and maybe bikeshed the register_fonts API if anyone cares to.
I've now added support for passing a FontStyle to register_font, and I believe CI should pass this now.
I've renamed the ab_glyph_ feature to ab_glyph, using the dep: syntax available in Cargo.toml since Rust 1.60 (which postdates this PR being opened, lol).
Woops, those Clippy warnings tipped me off to my having forgotten to do the ab_glyph_ -> ab_glyph feature rename in one file.
I had also forgotten I'd git stashed the changes to the project I depend on this in so it wasn't using a path dependency for local testing. Fixed now.
I just tried this out it works perfect on my side. And this makes us away from libfontconfig dependency which has frequently asked by many people.
It would be nice if you have the clippy warning fixed. Besides that everything looks good to me.
Thanks for the awesome work!
Thanks!