diagrams / SVGFonts

Fonts from the SVG-Font format
http://hackage.haskell.org/package/SVGFonts
Other
20 stars 12 forks source link

Failed to open a font converted using FontForge #24

Closed jonathan-laurent closed 6 years ago

jonathan-laurent commented 6 years ago

I tried to load a font that I had converted to SVG format using FontForge and got the following error:

Prelude.head: empty list

I am using the latest version of SVGFonts. You can find attached:

Thanks for your help!

tkvogt commented 6 years ago

Looking where head is used (in only two places), my conclusion is that the font has no kerning but it is the standard option is to use kerning. Then this bug occurs. Until it is fixed try HADV instead of KERN: textSVG' $ TextOpts t lin INSIDE_H HADV False 1 1

jonathan-laurent commented 6 years ago

Thanks for your quick reply. I tried HADV but this results in the same error.

byorgey commented 6 years ago

@tkvogt are you talking about this line https://github.com/diagrams/SVGFonts/blob/6efb50a84e8f986b80c25bf731770218fbf40f75/src/Graphics/SVGFonts/ReadFont.hs#L253 ? That can't cause this error, because it checks for not (null s0) before calling head s0.

The other place head is used seems to be https://github.com/diagrams/SVGFonts/blob/6efb50a84e8f986b80c25bf731770218fbf40f75/src/Graphics/SVGFonts/ReadFont.hs#L97 , but I don't know what that code is doing.

tkvogt commented 6 years ago

I just played around with cmutt.svg, and found that changing the third line from <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> to just <svg xmlns:xlink="http://www.w3.org/1999/xlink"> makes the error go away. So obviously some tags like <font> don't have the right namespace and are discarded. The easiest way to fix this would be IMHO an error message like "No font tag found by SVGFonts, delete the namespace in the tag of the font file: xmlns="http://www.w3.org/2000/svg" Or does someone know a more elegant solution?

tkvogt commented 6 years ago

Fixed. The library can now handle svg namespace or no namespace.

jonathan-laurent commented 6 years ago

Thanks!