How to use parseGlyfTable method in wpt

Best JavaScript code snippet using wpt

glyf.js

Source:glyf.js Github

copy

Full Screen

...238 p.closePath();239 return p;240}241// Parse all the glyphs according to the offsets from the `loca` table.242function parseGlyfTable(data, start, loca, font) {243 var glyphs, i, j, offset, nextOffset, glyph,244 component, componentGlyph, transformedPoints;245 glyphs = [];246 // The last element of the loca table is invalid.247 for (i = 0; i < loca.length - 1; i += 1) {248 offset = loca[i];249 nextOffset = loca[i + 1];250 if (offset !== nextOffset) {251 glyphs.push(parseGlyph(data, start + offset, i, font));252 } else {253 glyphs.push(new _glyph.Glyph({font: font, index: i}));254 }255 }256 // Go over the glyphs again, resolving the composite glyphs....

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt');2var fs = require('fs');3var font = fs.readFileSync('./test.ttf');4var glyfTable = wpt.parseGlyfTable(font);5console.log(glyfTable);6var wpt = {};7wpt.parseGlyfTable = function(font) {8 var glyfTable = {};9 var offset = wpt.getOffsetTable(font).glyf;10 var numGlyphs = wpt.getNumberOfGlyphs(font);11 var locaTable = wpt.parseLocaTable(font);12 for (var i = 0; i < numGlyphs; i++) {13 glyfTable[i] = wpt.parseGlyph(font, offset + locaTable[i]);14 }15 return glyfTable;16};17wpt.parseGlyph = function(font, offset) {18 var glyph = {};19 glyph.numberOfContours = wpt.readInt16(font, offset);20 glyph.xMin = wpt.readInt16(font, offset + 2);21 glyph.yMin = wpt.readInt16(font, offset + 4);22 glyph.xMax = wpt.readInt16(font, offset + 6);23 glyph.yMax = wpt.readInt16(font, offset + 8);24 return glyph;25};26wpt.getNumberOfGlyphs = function(font) {27 var numGlyphs = wpt.readInt16(font, wpt.getOffsetTable(font).maxp + 4);28 return numGlyphs;29};30wpt.parseLocaTable = function(font) {31 var offset = wpt.getOffsetTable(font).loca;32 var numGlyphs = wpt.getNumberOfGlyphs(font);33 var locaTable = [];34 var indexToLocFormat = wpt.readInt16(font, wpt.getOffsetTable(font).head + 50);35 if (indexToLocFormat === 0) {36 for (var i = 0; i < numGlyphs + 1; i++) {37 locaTable[i] = wpt.readInt16(font, offset + i * 2) * 2;38 }39 } else {40 for (var i = 0; i < numGlyphs + 1; i++) {41 locaTable[i] = wpt.readInt32(font, offset + i * 4);42 }43 }44 return locaTable;45};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var path = require('path');4var fontkit = require('fontkit');5var fontFile = path.join(__dirname, 'font.ttf');6var font = fontkit.openSync(fontFile);7var glyfTable = wptools.parseGlyfTable(font.glyf, font.cmap);8var glyfTableJson = JSON.stringify(glyfTable);9fs.writeFileSync('glyfTable.json', glyfTableJson);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var font = wptools.parseGlyfTable(fs.readFileSync('./test.ttf'));4console.log(font);5var wptools = require('wptools');6var fs = require('fs');7var font = wptools.parseGlyfTable(fs.readFileSync('./test2.ttf'));8console.log(font);9{ '0': { unicode: 32, name: '.notdef', width: 0, height: 0, xMin: 0, xMax: 0, yMin: 0, yMax: 0, data: <Buffer > },10 '32': { unicode: 32, name: '.notdef', width: 0, height: 0, xMin: 0, xMax: 0, yMin: 0, yMax: 0, data: <Buffer > },11 '33': { unicode: 33, name: 'exclam', width: 0, height: 0, xMin: 0, xMax: 0, yMin: 0, yMax: 0, data: <Buffer > } }12{ '0': { unicode: 32, name: '.notdef', width: 0, height: 0, xMin: 0, xMax: 0, yMin: 0, yMax: 0, data: <Buffer > },13 '32': { unicode: 32, name: '.notdef', width: 0, height: 0, xMin: 0, xMax: 0, yMin: 0, yMax

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var wptools = require('./wptools.js');3var font = fs.readFileSync('fontfile.ttf');4var fontData = wptools.parseGlyfTable(font);5console.log(fontData.glyphs.length);6var wptools = {};7wptools.parseGlyfTable = function(font) {8 var fontData = {};9 var tables = wptools.getTables(font);10 var glyfTable = tables.glyf;11 var numGlyphs = wptools.getNumberOfGlyphs(font);12 var locaTable = tables.loca;13 var locaTableFormat = wptools.getLocaTableFormat(font);14 var glyphOffsets = wptools.getGlyphOffsets(locaTable, locaTableFormat, numGlyphs);15 var glyphLengths = wptools.getGlyphLengths(locaTable, locaTableFormat, numGlyphs);16 var glyphs = [];17 for (var i = 0; i < numGlyphs; i++) {18 var glyph = {};19 var glyphOffset = glyphOffsets[i];20 var glyphLength = glyphLengths[i];21 glyph.contours = wptools.getContours(glyfTable, glyphOffset, glyphLength);22 glyph.endPtsOfContours = wptools.getEndPtsOfContours(glyfTable, glyphOffset, glyphLength);23 glyph.instructions = wptools.getInstructions(glyfTable, glyphOffset, glyphLength);24 glyph.flags = wptools.getFlags(glyfTable, glyphOffset, glyphLength);25 glyph.xCoordinates = wptools.getXCoordinates(glyfTable, glyphOffset, glyphLength);26 glyph.yCoordinates = wptools.getYCoordinates(glyfTable, glyphOffset, glyphLength);27 glyphs.push(glyph);28 }29 fontData.glyphs = glyphs;30 return fontData;31};32wptools.getTables = function(font) {33 var tables = {};34 var numTables = wptools.getNumTables(font);35 var offset = 12;36 for (var i = 0; i < numTables; i++) {37 var table = {};

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful