Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function showGlyf(charcode) {
let glyf = lang.clone(ttf.getGlyfByCode(charcode));
let canvas = $('#glyf-canvas').get(0);
let ctx = canvas.getContext('2d');
// 调整大小
ctx.clearRect(0, 0, 600, 600);
otfGlyf2Canvas(glyf, ctx, {
stroke: 0,
scale: 600 / ttf.ttf.head.unitsPerEm,
height: ttf.ttf.head.unitsPerEm + ttf.ttf.hhea.descent,
strokeStyle: 'green',
fillStyle: 'green'
});
}
function showGlyf(charcode) {
let tpl = ''
+ '<svg class="glyf">'
+ ' <g>'
+ '<path d="M 0,0" class="path"></path>'
+ '</g>'
+ '</svg>';
let svg = $(tpl);
let glyf = lang.clone(ttf.getGlyfByCode(charcode));
if (glyf.compound) {
return;
}
// 调整大小
let width = glyf.xMax;
let height = glyf.yMax - glyf.yMin;
let scale = 1;
if (ttf.ttf.head.unitsPerEm > 512) {
scale = 512 / ttf.ttf.head.unitsPerEm;
width = width * scale;
height = height * scale;
}
function showGlyf(charcode) {
let glyf = lang.clone(ttf.getGlyfByCode(charcode));
if (glyf.compound) {
glyf.glyfs.forEach(g => {
g.glyf = ttf.getGlyfByIndex(g.glyphIndex);
});
}
let canvas = $('#glyf-canvas').get(0);
let ctx = canvas.getContext('2d');
// 调整大小
let width = glyf.xMax - glyf.xMin;
let height = glyf.yMax - glyf.yMin;
let scale = 1;
if (ttf.ttf.head.unitsPerEm > 512) {
scale = 512 / ttf.ttf.head.unitsPerEm;
width = width * scale;
function ttfmin() {
if (!curttfData) {
return;
}
let text = $('#text').val();
let ttf = new TTF(lang.clone(curttfData));
let indexList = ttf.findGlyf({
unicode: text.split('').map(function (u) {
return u.charCodeAt(0);
})
});
if (indexList.length) {
let glyfList = ttf.getGlyf(indexList);
glyfList.unshift(ttf.getGlyfByIndex(0));
ttf.get().glyf = glyfList;
}
else {
ttf.get().glyf = [ttf.getGlyfByIndex(0)];
}