Skip to content

Commit

Permalink
Merge pull request #9 from HacksawStudios/arm64-compatibility
Browse files Browse the repository at this point in the history
Arm64 compatibility
  • Loading branch information
lbergman authored Dec 19, 2023
2 parents 7233e9f + ec6e2f7 commit c262cd5
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 79 deletions.
Binary file added bin/darwin_arm64/msdfgen.osx
Binary file not shown.
Binary file modified bin/linux/msdfgen.linux
Binary file not shown.
25 changes: 14 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,22 @@ const controlChars = ['\n', '\r', '\t'];

const binaryLookup = {
darwin: 'msdfgen.osx',
darwin_arm64: 'msdfgen.osx',
win32: 'msdfgen.exe',
linux: 'msdfgen.linux'
linux: 'msdfgen.linux',
linux_arm64: 'msdfgen.linux'
};

module.exports = generateBMFont;

function getBinaryDir(){
switch(process.platform) {
case 'win32':
return process.arch === 'x64' ? 'win64' : 'win32';
case 'linux':
return process.arch === 'arm64' ? 'linux_arm64' : 'linux';
case 'darwin':
return 'darwin';
function getBinaryDir() {
switch (process.platform) {
case 'win32':
return process.arch === 'x64' ? 'win64' : 'win32';
case 'linux':
return process.arch === 'arm64' ? 'linux_arm64' : 'linux';
case 'darwin':
return 'darwin';
}
}

Expand Down Expand Up @@ -62,10 +64,11 @@ function generateBMFont (fontPath, opt, callback) {
opt = {};
}

const binName = binaryLookup[process.platform];
const lookupKey = process.arch === "arm64" ?`${process.platform}_${process.arch}` : process.platform;
const binName = binaryLookup[lookupKey];
const binDir = getBinaryDir();

assert.ok(binName, `No msdfgen binary for platform ${process.platform}.`);
assert.ok(binName, `No msdfgen binary for platform ${lookupKey}.`);
assert.ok(fontPath, 'must specify a font path');
assert.ok(typeof fontPath === 'string' || fontPath instanceof Buffer, 'font must be string path or Buffer');
assert.ok(opt.filename || !(fontPath instanceof Buffer), 'must specify filename if font is a Buffer');
Expand Down
81 changes: 29 additions & 52 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,32 @@
"license": "MIT",
"dependencies": {
"arabic-persian-reshaper": "^1.0.1",
"cli-progress": "^3.10.0",
"commander": "^2.19.0",
"handlebars": "^4.7.2",
"cli-progress": "^3.12.0",
"commander": "^2.20.3",
"handlebars": "^4.7.7",
"is-invalid-path": "^1.0.2",
"jimp": "^0.3.5",
"js2xmlparser": "^4.0.0",
"jimp": "^0.3.11",
"js2xmlparser": "^4.0.2",
"map-limit": "0.0.1",
"maxrects-packer": "^2.4.0-alpha.0",
"maxrects-packer": "^2.7.3",
"opentype.js": "^0.11.0",
"update-notifier": "^5.1.0"
},
"devDependencies": {
"cz-conventional-changelog": "^2.1.0",
"load-bmfont": "^1.4.0",
"open": "^6.3.0",
"rimraf": "^2.6.3",
"run-parallel": "^1.1.9",
"serve-handler": "^6.0.2",
"standard-version": "^9.3.2",
"tslint": "^5.14.0",
"typescript": "^3.3.3333",
"xml2js": "^0.4.19"
"load-bmfont": "^1.4.1",
"open": "^6.4.0",
"rimraf": "^2.7.1",
"run-parallel": "^1.2.0",
"serve-handler": "^6.1.5",
"standard-version": "^9.5.0",
"tslint": "^5.20.1",
"typescript": "^3.9.10",
"xml2js": "^0.4.23"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
}
}
}

0 comments on commit c262cd5

Please sign in to comment.