Plumin.jsJavaScript 字体操作库

联合创作 · 2023-09-22

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);
浏览 3
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报