Skip to content

Commit

Permalink
Simplify HB_TAG
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Jul 17, 2020
1 parent 2e73139 commit 75ea80c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/subsetLocalFontWithHarfbuzz.js
Expand Up @@ -5,13 +5,15 @@ const _ = require('lodash');
const pathModule = require('path');
const wawoff2 = require('wawoff2');
const woffTool = require('woff2sfnt-sfnt2woff');
const assert = require('assert');

function HB_TAG(c1, c2, c3, c4) {
function HB_TAG(chunkName) {
assert(chunkName.length === 4);
return (
(c1.charCodeAt(0) << 24) |
(c2.charCodeAt(0) << 16) |
(c3.charCodeAt(0) << 8) |
c4.charCodeAt(0)
(chunkName.charCodeAt(0) << 24) |
(chunkName.charCodeAt(1) << 16) |
(chunkName.charCodeAt(2) << 8) |
chunkName.charCodeAt(3)
);
}

Expand Down Expand Up @@ -64,15 +66,15 @@ module.exports = async (originalFont, targetFormat, text) => {
const inputGlyphs = exports.hb_subset_input_unicode_set(input);
exports.hb_set_del(
exports.hb_subset_input_drop_tables_set(input),
HB_TAG('G', 'S', 'U', 'B')
HB_TAG('GSUB')
);
exports.hb_set_del(
exports.hb_subset_input_drop_tables_set(input),
HB_TAG('G', 'P', 'O', 'S')
HB_TAG('GPOS')
);
exports.hb_set_del(
exports.hb_subset_input_drop_tables_set(input),
HB_TAG('G', 'D', 'E', 'F')
HB_TAG('GDEF')
);

exports.hb_set_union(inputGlyphs, glyphs);
Expand Down

0 comments on commit 75ea80c

Please sign in to comment.