From 3efca892351675b70047e168772461c10f8c8535 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sun, 24 Sep 2017 11:49:15 -0700 Subject: [PATCH] Don't call `Font.toArrayBuffer()` in the mesh debugger, as that's really slow --- demo/client/src/mesh-debugger.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/demo/client/src/mesh-debugger.ts b/demo/client/src/mesh-debugger.ts index 4e3ac893..3a955483 100644 --- a/demo/client/src/mesh-debugger.ts +++ b/demo/client/src/mesh-debugger.ts @@ -113,6 +113,7 @@ class MeshDebuggerAppController extends AppController { private fontLoaded(fileData: ArrayBuffer): void { this.file = opentype.parse(fileData); assert(this.file.isSupported(), "The font type is unsupported!"); + this.fileData = fileData; const glyphCount = this.file.numGlyphs; for (let glyphIndex = 1; glyphIndex < glyphCount; glyphIndex++) { @@ -147,14 +148,14 @@ class MeshDebuggerAppController extends AppController { let promise: Promise; - if (this.file instanceof opentype.Font) { + if (this.file instanceof opentype.Font && this.fileData != null) { if (opentypeGlyph == null) { const glyphIndex = parseInt(this.fontPathSelect.selectedOptions[0].value); opentypeGlyph = this.file.glyphs.get(glyphIndex); } const glyph = new MeshDebuggerGlyph(opentypeGlyph); - const glyphStorage = new GlyphStorage(this.file.toArrayBuffer(), [glyph], this.file); + const glyphStorage = new GlyphStorage(this.fileData, [glyph], this.file); promise = glyphStorage.partition(); } else if (this.file instanceof SVGLoader) { promise = this.file.partition(this.fontPathSelect.selectedIndex); @@ -172,6 +173,7 @@ class MeshDebuggerAppController extends AppController { private file: Font | SVGLoader | null; private fileType: FileType; + private fileData: ArrayBuffer | null; meshes: PathfinderMeshData | null;