Files
NapCatQQ/.pnpm-store/v3/files/4a/eedb9446c6a8dad9b6fd3a4e940a717c167df69ee89657353ab497cec2e3d12dff10f3fc10e079b5df2eda20edc4d19299603410c7ef57c2e607b58bb1db9b
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

43 lines
921 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file glyf转换svg,复合字形轮廓需要ttfObject支持
* @author mengke01(kekee000@gmail.com)
*
* thanks to:
* ynakajima/ttf.js
* https://github.com/ynakajima/ttf.js
*/
import contours2svg from './contours2svg';
import transformGlyfContours from './transformGlyfContours';
/**
* glyf转换svg
*
* @param {Object} glyf 解析后的glyf结构
* @param {Object} ttf ttf对象
* @return {string} svg文本
*/
export default function glyf2svg(glyf, ttf) {
if (!glyf) {
return '';
}
const pathArray = [];
if (!glyf.compound) {
if (glyf.contours && glyf.contours.length) {
pathArray.push(contours2svg(glyf.contours));
}
}
else {
const contours = transformGlyfContours(glyf, ttf);
if (contours && contours.length) {
pathArray.push(contours2svg(contours));
}
}
return pathArray.join(' ');
}