修正字体不存在时引发的错误

pull/411/MERGE
ChenX 5 years ago
parent 08065e227b
commit 8ce6c2638e

@ -4,7 +4,7 @@ import { Font, ShapePath } from "three"
export class FontExt extends Font
{
generateShapes(text, size)
generateShapes(text: string, size: number)
{
if (size === undefined) size = 100;
let shapes = [];
@ -16,7 +16,7 @@ export class FontExt extends Font
return shapes;
}
}
function createPaths(text: string, size, data)
function createPaths(text: string, size: number, data: any)
{
let scale = size / data.resolution;
let line_height = (data.boundingBox.yMax - data.boundingBox.yMin + data.underlineThickness) * scale;
@ -39,13 +39,16 @@ function createPaths(text: string, size, data)
else
{
let ret = createPath(char, scale, offsetX, offsetY, data);
offsetX += ret.offsetX;
paths.push(ret.path);
if (ret)
{
offsetX += ret.offsetX;
paths.push(ret.path);
}
}
}
return paths;
}
function createPath(char, scale, offsetX, offsetY, data)
function createPath(char: string, scale: number, offsetX: number, offsetY: number, data: any)
{
let glyph = data.glyphs[char] || data.glyphs['?'];
@ -53,7 +56,7 @@ function createPath(char, scale, offsetX, offsetY, data)
let path = new ShapePath();
let x, y, cpx, cpy, cpx1, cpy1, cpx2, cpy2;
let x: number, y: number, cpx: number, cpy: number, cpx1: number, cpy1: number, cpx2: number, cpy2: number;
if (glyph.o)
{

Loading…
Cancel
Save