Get Font Glyphs as Vectors, manipulate and product SVG or Bitmap

前端 未结 2 792
臣服心动
臣服心动 2021-01-13 13:16

I have an application that needs to apply some transformations to text (including non-affine transformations). Does anyone know of a toolkit (or group of tools) that would l

相关标签:
2条回答
  • 2021-01-13 13:50

    While Batik is a good answer, it will convert only TrueType fonts to SVG Fonts. If you have OpenType fonts, and they more and more dominate now, you can use FontForge to get an SVG Font for these. Another advantage of using OpenType is that the produced SVG uses not only quadratic but also cubic Beziers in the path which is more effective.

    0 讨论(0)
  • 2021-01-13 14:06

    You could use the Batik TTF to SVG Font converter. The SVG font format uses the same path data format that the SVG <path> element uses.

    For example, this is the output from converting Gentium Basic Regular using the above tool. With the right coordinate system, you can just grab out the path data, transform it however you like, and then draw it with a <path>. Note though that the glyph coordinate system in SVG fonts is actually inverted, with the (0,0) at the bottom left corner of the glyph cell box, compared to the regular SVG canvas which has (0,0) at the top left corner. So don't forget to flip the glyph, e.g. by putting transform="scale(1,-1)" on the <path> you use to render the glyph.

    Once you have the SVG document that renders the glyphs as shapes you can convert it to a bitmap using your favourite tool. (Batik can do that too.)

    0 讨论(0)
提交回复
热议问题