Skip to content

Commit

Permalink
option to use localization character file to select glyphs
Browse files Browse the repository at this point in the history
  • Loading branch information
phoddie committed Jan 4, 2022
1 parent a618185 commit 34ffde0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tools/mcmanifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,12 @@ export class MakeFile extends FILE {
result.faces.forEach(face => {
const name = face.name + "-" + face.size;

this.line("$(RESOURCES_DIR)", tool.slash, ("-alpha" === face.suffix) ? `${name}.fnt` : `${name}.bf4`, ": ", source,
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");
this.line.apply(this, line);
this.echo(tool, "fontbm ", name);

let characters = face.characters ?? "";
Expand All @@ -760,12 +763,13 @@ export class MakeFile extends FILE {
tool.writeFileBuffer(path, ArrayBuffer.fromString(characters));

path = tool.resourcesPath + tool.slash + name + ".json";
let options = JSON.stringify({kern: face.kern ?? false, monochrome: face.monochrome ?? false});
let options = JSON.stringify({kern: face.kern ?? false, monochrome: face.monochrome ?? false, localization: face.localization ?? false});
former = tool.isDirectoryOrFile(path) ? tool.readFileString(path) : "";
if (former !== options)
tool.writeFileString(path, options);

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 ? "--include-kerning-pairs" : ""} ${face.monochrome ? "--monochrome" : ""} --chars-file "$(RESOURCES_DIR)${tool.slash}${name}.txt"`);
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 ? "--include-kerning-pairs" : ""} ${face.monochrome ? "--monochrome" : ""} --chars-file "$(RESOURCES_DIR)${tool.slash}${name}.txt" ${localization}`);
if ("-alpha" === face.suffix) {
this.line("$(RESOURCES_DIR)", tool.slash, name + "-alpha.bmp", ": ", "$(RESOURCES_DIR)", tool.slash, `${name}.fnt`);
this.line("\t$(PNG2BMP) ", "$(RESOURCES_DIR)", tool.slash, name + ".png", " -a -o $(@D) -r ", tool.rotation, " -t");
Expand Down

0 comments on commit 34ffde0

Please sign in to comment.