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

Function parseHmtxTable

libraries/p5.js:5013–5028  ·  view source on GitHub ↗
(data, start, numMetrics, numGlyphs, glyphs)

Source from the content-addressed store, hash-verified

5011// Parse the `hmtx` table, which contains the horizontal metrics for all glyphs.
5012// This function augments the glyph array, adding the advanceWidth and leftSideBearing to each glyph.
5013function parseHmtxTable(data, start, numMetrics, numGlyphs, glyphs) {
5014 var advanceWidth;
5015 var leftSideBearing;
5016 var p = new parse.Parser(data, start);
5017 for (var i = 0; i < numGlyphs; i += 1) {
5018 // If the font is monospaced, only one entry is needed. This last entry applies to all subsequent glyphs.
5019 if (i < numMetrics) {
5020 advanceWidth = p.parseUShort();
5021 leftSideBearing = p.parseShort();
5022 }
5023
5024 var glyph = glyphs.get(i);
5025 glyph.advanceWidth = advanceWidth;
5026 glyph.leftSideBearing = leftSideBearing;
5027 }
5028}
5029
5030function makeHmtxTable(glyphs) {
5031 var t = new table.Table('hmtx', []);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected