Code Monkey home page Code Monkey logo

Comments (11)

deeplook avatar deeplook commented on July 18, 2024

I don't think there was a lot of test effort regarding fonts. The way reportlab works (from my ancient knowledge about it) regarding PDF output is that the "standard 14 Postscript" fonts are included/available into every PDF file, while any other needs to be declared and embedded manually, e.g. as TrueType or Type-1. Verdana is not one of the 14 standard ones, see: http://www.enfocus.com/manuals/ReferenceGuide/PP/10/enUS/en-us/concept/c_aa1140975.html

from svglib.

claudep avatar claudep commented on July 18, 2024

To embed fonts in PDF, we'll have to obtain the font system path. It looks like Python doesn't offer a simple way to get OS-independent system font files. The best implementation I found until now is matplotlib font_manager (https://matplotlib.org/api/font_manager_api.html). Requiring matplotlib is a bit of a heavy dependency, but we might optionally depend on it for better font support?

from svglib.

claudep avatar claudep commented on July 18, 2024

See #107 for a similar issue with a Chinese font.

from svglib.

deeplook avatar deeplook commented on July 18, 2024

Better font support would certainly be a nice-to-have essential feature. But I'd rather include some existing code from elsewhere doing font search than add a dependency on something as huge as matplotlib. The easiest to start with would be to ask the svglib user to provide a list of directories to find fonts in.

from svglib.

claudep avatar claudep commented on July 18, 2024

Agreed. My patch above is a first step to better support the standard PDF fonts. Then we can gradually improve support for other fonts.

from svglib.

claudep avatar claudep commented on July 18, 2024

Would be great if you could test again the result with the more recent svglib code.

from svglib.

htgoebel avatar htgoebel commented on July 18, 2024

On my system, at least "Verdana" is no longer "Helvetica". (Curiously it is DejaVuSans, Verdana is not installed on my system).
The text in Dingbats is now gives:

Unable to find a suitable font for 'Dingbats'

from svglib.

claudep avatar claudep commented on July 18, 2024

If the font is not installed on your system and Fontconfig is available, the used font will be indeed the Fontconfig default, which is DejaVuSans on many Linux systems. WOUld you suggest some other behavior?

Unable to find a suitable font for 'Dingbats'

Note that the font name in the standard fonts is ZapfDingbats. Do you have a Dingbats font installed on your system?

from svglib.

BorysekOndrej avatar BorysekOndrej commented on July 18, 2024

It's been nice surprise for me to see new features around font support. There seems to be a bug with font's like Open Sans, which have space in their name. In method convertFontFamily they are being split into two by the method split_attr_list.
I'm not sure what the standards says about such font names and I currently don't have time to research that and potentially fix it. So just reporting. Sorry for that.

Attaching example svg:

<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400">
<style> text { font-family: 'Open Sans'; font-size: 30px; } </style>
<text x="10%" y="50%" >Lorem</text>
</svg>

and print out of font_names just after initialization.
['"Open', 'Sans"']

from svglib.

claudep avatar claudep commented on July 18, 2024

Thanks for reporting, fixed in f439a3f

from svglib.

claudep avatar claudep commented on July 18, 2024

Font support has improved a lot since this issue was reported. I'm closing this issue, suggesting that specific font bugs to be created as separate issues with detailed reproducing instructions.

from svglib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.