字体操作JavaScript库:Plumin.js
jopen
10年前
Plumin.js 是一个用在浏览器和 Node.js 上对字体进行操作的 JavaScript 库,示例代码:
(function(p) { var font = new p.Font({ familyName: 'Demo', ascender: 800, descender: -100 }), a = new p.Glyph({ name: 'a', unicode: 'a', advanceWidth: 496 }), i = new p.Glyph({ name: 'i', unicode: 'i', advanceWidth: 268 }), o = new p.Glyph({ name: 'o', unicode: 'o', advanceWidth: 536 }), shape; // a contour shape = new p.Path.RegularPolygon({ center: [268, 124], sides: 3, radius: 248 }); shape.rotate(180, [268, 124]); shape.scale(1, 1.4, [268, 0]); a.addContour(shape); // i contour shape = new p.Path.Rectangle({ point: [60, 0], size: [140, 500] }); i.addContour(shape); // o contour shape = new p.Path.Ellipse({ point: [50, 0], size: [436, 510] }); o.addContour(shape); font.addGlyphs([ a, i, o ]); font.updateOTCommands() .addToFonts(); })(plumin.paper);