Closed ronkok closed 5 years ago
This wraps up my nomnoml
work. Thank you for creating a tool that is so useful and easy to use. I hope you can soon place a Download SVG button onto the nomnoml.com page.
I'll stand by for your review.
Cool. Thank you.
This PR aims to improve SVG node sizing when possible, by improving the accuracy of the SVG
measureText
method. The functionrenderSvg(code, canvas)
now has an optional parametercanvas
.The pre-existing
measureText
heuristic is still in place and it is the default method.measureText
will instead use a CanvasRenderingContext2D to measure the text in a particular node only if three conditions are met:renderSvg
is called from a browser, not from node.js.renderSvg()
.Helvetica and Arial are font-metric identical. Ditto Times and Times New Roman. They can be safely measured without worry that a user-agent will not have a matching system font.