wader / ansisvg

Convert ANSI to SVG
MIT License
89 stars 9 forks source link

fix: viewBox attr when using pixel units #50

Closed patrislav1 closed 6 months ago

patrislav1 commented 6 months ago

fixes SVG output for tools that rely on viewBox, such as asciidoctor

fixes #49

From SVG documentation it appears that viewBox only supports pixel units, so I just add it when we use pixels

wader commented 6 months ago

Played around with viewBox and read the spec a bit but not sure i got much wiser :) reading https://www.w3.org/TR/SVG11/coords.html#Introduction it sounds like it might be possible to use something else then px but i can't get it to work, also says "The supported length unit identifiers are: em, ex, px, pt, pc, cm, mm, in, and percentages." 😬

Anyways, change looks good and we can improve on non-pixels if possible later

patrislav1 commented 6 months ago

Played around with viewBox and read the spec a bit but not sure i got much wiser :) reading https://www.w3.org/TR/SVG11/coords.html#Introduction it sounds like it might be possible to use something else then px but i can't get it to work, also says "The supported length unit identifiers are: em, ex, px, pt, pc, cm, mm, in, and percentages." 😬

I'm not entirely sure about the relation between viewport and viewbox but IIUC then the latter maps the former to some kind of display region which can only be given in pixels. (The spec looks kind of vague in this regard, and how it's implemented by renderers is another question :exploding_head: )