Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for all font-family names #71

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Apr 14, 2024

  1. Add support for all font-family names

    # 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 you could access.
    
    This following commit fixed this by returning a list:
    RazrFalcon/fontdb@8ffb890
    
    There are some tied dependencies here, in particular the version of `fontdb`
    needs to match the one used in `resvg` / `usvg`, or at least be compatible.
    
    The first version of `resvg` and `usvg` that use a version of `fontdb` >= 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 we have the list of fonts out of `fontdb` the actual code change is straightforward.
    
    The only other change introduced is the removal of the `keep_named_groups` option
    in the call to `convert_text` in commit:
    RazrFalcon/resvg@d5e5fcf
    
    # Testing
    
    After building I was able to verify the both of the following succeed:
    
    ```
    ./target/release/agg demo.cast temp.gif --font-family "JetBrainsMono NFM"
    ./target/release/agg demo.cast temp.gif --font-family "JetBrainsMono Nerd Font Mono"
    ```
    
    The latter usually fails with the following:
    
    ```
    Error: no faces matching font families JetBrainsMono Nerd Font Mono
    ```
    MeanderingProgrammer committed Apr 14, 2024
    Configuration menu
    Copy the full SHA
    7873ef6 View commit details
    Browse the repository at this point in the history
  2. Go back to selecting first font-family

    # Details
    
    The real fix for handling fonts with mulitple families is in the
    query logic in `fontdb` which iterates over the list looking for
    a match rather than only looking at the first one.
    
    Within the application can continue selecting the first one in
    the response.
    MeanderingProgrammer committed Apr 14, 2024
    Configuration menu
    Copy the full SHA
    76602ea View commit details
    Browse the repository at this point in the history