feat: add font resolve support and builder api #118
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #101 #115
The idea is to add a new
ResvgBuilder
type, which does all the pre-resvg resolving stuff. Behind the scene it uses the xml reader whichresvg
uses and find all text nodes, try to gather font information of them (by using a naive ancestor-inheritance logic) and output all fonts needed via a new apitexts_to_resolve()
.Users could use this new api to get whatever font they have which satisfies the given font key, and call
resolve_font(buffer)
to feed the font buffer to the builder.Later on, builder will uses these fonts to construct the
font_db::Database
instance so that the texts will not be eliminated by resvg/usvg.Some drawbacks:
usvg
is also not perfect, the impl in this PR is worse.monospace
and you want to render it by providing aubuntu mono
font, it would just fail.