X-Git-Url: https://git.kianting.info/?a=blobdiff_plain;f=src%2Fharfbuzz.ts;fp=src%2Fharfbuzz.ts;h=0000000000000000000000000000000000000000;hb=1ea8dfd99517fdfe98c81aa206ad2615c1113426;hp=c7be4f0b230fb0bf6782a275b84fe84a6ac09f63;hpb=c2cab771be8b40c091556c7df314b6a5abbe366e;p=uann diff --git a/src/harfbuzz.ts b/src/harfbuzz.ts deleted file mode 100644 index c7be4f0..0000000 --- a/src/harfbuzz.ts +++ /dev/null @@ -1,57 +0,0 @@ -var hb = require('harfbuzzjs/hbjs'); -var fs = require('fs'); -// some part of code derived from that by Ebrahim Byagowi, -// under MIT License -export function harfbuzzTest(inputString: string){ - WebAssembly.instantiate(fs.readFileSync(__dirname+"/../3rdparty/harfbuzzjs/hb.wasm")) - .then(function (wsm) { - - hb = hb(wsm.instance); - - - let fontdata = fs.readFileSync("/usr/share/fonts/truetype/freefont/FreeSerif.ttf"); - - //hbjs(fontdata.instance); - - //console.log(a); - - var blob = hb.createBlob(fontdata); // Load the font data into something Harfbuzz can use - var face = hb.createFace(blob, 0); // Select the first font in the file (there's normally only one!) - var font = hb.createFont(face); // Create a Harfbuzz font object from the face - var buffer = hb.createBuffer(); // Make a buffer to hold some text - buffer.addText(inputString); // Fill it with some stuff - buffer.guessSegmentProperties(); // Set script, language and direction - hb.shape(font, buffer); // Shape the text, determining glyph IDs and positions - var output : Array<{g : number, - ax : number, - dx : number, - dy : number}> = buffer.json(); - - // Enumerate the glyphs - console.log("id\tax\tdx\tdy"); - - var xCursor = 0; - var yCursor = 0; - for (var glyph of output) { - var glyphId = glyph.g; - var xAdvance = glyph.ax; - var xDisplacement = glyph.dx; - var yDisplacement = glyph.dy; - - var svgPath = font.glyphToPath(glyphId); - - console.log(glyphId + "\t" + xAdvance + "\t" + xDisplacement + "\t" + yDisplacement); - - // You need to supply this bit - //drawAGlyph(svgPath, xCursor + xDisplacement, yDisplacement); - - // xCursor += xAdvance; - } - - // Release memory - buffer.destroy(); - font.destroy(); - face.destroy(); - blob.destroy(); - }); -} \ No newline at end of file