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

前端 未结 2 795
臣服心动
臣服心动 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 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 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 . 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 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.)

提交回复
热议问题