Skip to content

Commit

Permalink
characterFiles for fontbm phoddie/node-red-mcu#123
Browse files Browse the repository at this point in the history
  • Loading branch information
phoddie committed Mar 14, 2024
1 parent 5373fcc commit a6a71b2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tools/mcmanifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,16 +935,24 @@ otadata, data, ota, , ${OTADATA_SIZE},`;
result.faces.forEach(face => {
const name = face.name + "-" + face.size;

const characterFiles = (("string" === typeof face.characterFiles) ? [face.characterFiles] : (face.characterFiles ?? []));
characterFiles.forEach((file, i) => {
characterFiles[i] = tool.resolveFilePath(file);
if (!characterFiles[i])
throw new Error(`characterFile "${file}" not found`);
});

let line = Array.of("$(RESOURCES_DIR)", tool.slash, ("-alpha" === face.suffix) ? `${name}.fnt` : `${name}.bf4`, ": ", source,
" ", "$(RESOURCES_DIR)", tool.slash, name + ".txt",
" ", "$(RESOURCES_DIR)", tool.slash, name + ".json");
if (face.localization)
line.push(" ", "$(RESOURCES_DIR)", tool.slash, "locals.mhi");
characterFiles.forEach(file => line.push(" ", file));
this.line.apply(this, line);
this.echo(tool, "fontbm ", name);

let characters = face.characters ?? "";
let blocks = ("string" === typeof face.blocks) ? [face.blocks] : (face.blocks ?? (characters ? [] : ["Basic Latin"]));
const blocks = ("string" === typeof face.blocks) ? [face.blocks] : (face.blocks ?? (characters ? [] : ["Basic Latin"]));
blocks.forEach(block => {
const info = UncodeRanges.find(info => info.category === block);
if (!info)
Expand All @@ -967,8 +975,10 @@ otadata, data, ota, , ${OTADATA_SIZE},`;
if (former !== options)
tool.writeFileString(path, options);

const localization = face.localization ? `--chars-file "$(RESOURCES_DIR)${tool.slash}locals.txt"` : "";
this.line(`\t$(FONTBM) --font-file ${source} --font-size ${face.size} --output "$(RESOURCES_DIR)${tool.slash}${name}" --texture-crop-width --texture-crop-height --texture-name-suffix none --data-format bin ${face.kern ? "--kerning-pairs regular" : ""} ${face.monochrome ? "--monochrome" : ""} --chars-file "$(RESOURCES_DIR)${tool.slash}${name}.txt" ${localization}`);
characterFiles.push(`$(RESOURCES_DIR)${tool.slash}${name}.txt`);
if (face.localization)
characterFiles.push(`$(RESOURCES_DIR)${tool.slash}${tool.localsName}.txt`);
this.line(`\t$(FONTBM) --font-file ${source} --font-size ${face.size} --output "$(RESOURCES_DIR)${tool.slash}${name}" --texture-crop-width --texture-crop-height --texture-name-suffix none --data-format bin ${face.kern ? "--kerning-pairs regular" : ""} ${face.monochrome ? "--monochrome" : ""} ${characterFiles.map(file => "--chars-file \"" + file + "\"").join(" ")}`);
if ("-alpha" === face.suffix) {
this.line("$(RESOURCES_DIR)", tool.slash, name + "-alpha.bmp", ": ", "$(RESOURCES_DIR)", tool.slash, `${name}.fnt`);
this.line("\tpng2bmp ", "$(RESOURCES_DIR)", tool.slash, name + ".png", ` -a -o $(@D) ${face.monochrome ? "-m" : ""} -r `, tool.rotation, " -t");
Expand Down

0 comments on commit a6a71b2

Please sign in to comment.