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

Improve support for custom fonts #110

Open
bsweeney opened this issue Dec 1, 2023 · 0 comments
Open

Improve support for custom fonts #110

bsweeney opened this issue Dec 1, 2023 · 0 comments
Milestone

Comments

@bsweeney
Copy link
Member

bsweeney commented Dec 1, 2023

Currently, in order to specify a custom font you have to:

  1. specify the path to the font file (using "/" for directory separators) without the file extension
  2. the font-family must be specified without quotes
  3. specify only a single font
  4. the font must be hosted on the same filesystem as the the current working directory

For example, if the DejaVu Sans font file can be found under fonts/DejaVuSans.ttf then the following must be used to select the font:

<svg width="200" height="200"
  xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <style>
    .text {
        font-family: fonts/DejaVuSans;
    }
  </style>
  <text class="text" x="100" y="100">php-svg-lib</text>
</svg>

There are a few reasons for this requirement:

  1. This library has no font manager, meaning that font names are not translated to a font file (as required by the PDF backend). So the font-family value must specify the file.
  2. CSS value lists are generally not supported and so fallback values in the font-family are interpreted as part of the font name (e.g. font-family: DejaVu Sans, sans-serif will cause this library to look for a file named "DejaVu Sans, san-serif.ttf").
  3. CSS strings are not supported, so if the font-family value is quoted then the quotes are interpreted as part of the font name.
@bsweeney bsweeney added this to the 0.6.0 milestone Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant