MCPcopy Create free account
hub / github.com/Code-Bullet/Jump-King / parseLookupTable

Function parseLookupTable

libraries/p5.js:4829–4859  ·  view source on GitHub ↗
(data, start)

Source from the content-addressed store, hash-verified

4827
4828// Parse a LookupTable (present in of GPOS, GSUB, GDEF, BASE, JSTF tables).
4829function parseLookupTable(data, start) {
4830 var p = new parse.Parser(data, start);
4831 var lookupType = p.parseUShort();
4832 var lookupFlag = p.parseUShort();
4833 var useMarkFilteringSet = lookupFlag & 0x10;
4834 var subTableCount = p.parseUShort();
4835 var subTableOffsets = p.parseOffset16List(subTableCount);
4836 var table = {
4837 lookupType: lookupType,
4838 lookupFlag: lookupFlag,
4839 markFilteringSet: useMarkFilteringSet ? p.parseUShort() : -1
4840 };
4841 // LookupType 2, Pair adjustment
4842 if (lookupType === 2) {
4843 var subtables = [];
4844 for (var i = 0; i < subTableCount; i++) {
4845 subtables.push(parsePairPosSubTable(data, start + subTableOffsets[i]));
4846 }
4847 // Return a function which finds the kerning values in the subtables.
4848 table.getKerningValue = function(leftGlyph, rightGlyph) {
4849 for (var i = subtables.length; i--;) {
4850 var value = subtables[i](leftGlyph, rightGlyph);
4851 if (value !== undefined) return value;
4852 }
4853
4854 return 0;
4855 };
4856 }
4857
4858 return table;
4859}
4860
4861// Parse the `GPOS` table which contains, among other things, kerning pairs.
4862// https://www.microsoft.com/typography/OTSPEC/gpos.htm

Callers 1

parseGposTableFunction · 0.85

Calls 1

parsePairPosSubTableFunction · 0.85

Tested by

no test coverage detected