Add support for all font-family names #71
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.
Thanks for the awesome work on this application, makes recording demos much easier!
Let me know if there's any more info I can provide or testing to do.
Problem
While using this tool to generate recordings I noticed an odd behavior in how I had to specify font-family name.
For some reason the name I had to specify was another option that pops up in
fc-list
(typically the last one), which would end up not matching the value in FontBook on MacOS. This made determining the correct name of the font more difficult.For example the following would work:
--font-family "JetBrainsMono NFM"
But the more usual name for the font would fail:
--font-family "JetBrainsMono Nerd Font Mono"
Solution
The problem is caused by the old version of
fontdb
being used. Prior 0.11.0 the library would choose the first valid value for the font family and that is all it would look at in the call toquery
.The following commit fixed this by processing a list of font-families: RazrFalcon/fontdb@8ffb890
There are some tied dependencies here, in particular the version of
fontdb
needs to match the one used inresvg
/usvg
, or at least be compatible.The first version of
resvg
andusvg
that use a version offontdb
>= 0.11.0 is the very next version 0.29.0. And 0.29.0 depends on 0.12.0. So this seems like a good upgrade path.Once
fontdb
is able to query the font no real change is needed other than handling a slightly different return type.The only other change introduced is the removal of the
keep_named_groups
option in the call toconvert_text
in commit:RazrFalcon/resvg@d5e5fcf
Testing
After building I was able to verify the both of the following succeed:
The latter usually fails with the following:
Side Effect
Since this implementation returns the first font family in the output of
fontdb.query
verbose logging is no longer guaranteed to write the exact font family name provided as input. The first font family as written in the fontdb docs states: "Where the first family is always English US, unless it's missing from the font".For instance both of these commands:
Output:
This can be changed back by modifying the implementation of
find_font_family
to return the inputname
ifface_info.families
is not empty rather than returning the first value in that list.