-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<meta charset="utf-8"> | ||
<script src="./sob/sob-html.js"></script> | ||
<script src="./bit-font.js"></script> | ||
<a href="./index.html"><< back</a> | ||
<p>upload a json file exported from <a href="https://www.pentacom.jp/pentacom/bitfontmaker2/">Bit Font Maker 2</a> (using the <img style="vertical-align : middle" src="https://www.pentacom.jp/pentacom/bitfontmaker2/img/menu_data.gif"> "<code>Data Import/Export</code>" button)</p> | ||
<input type="file" id="json-file"> | ||
<hr> | ||
<button onclick="bitFontIntoImage()">Bit Font Maker json -> image</button> | ||
<hr> | ||
<div id="dest"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//a.files[0].arrayBuffer().then(x => { | ||
// let tc = new TextDecoder("utf-8"); | ||
// console.log(tc.decode(x)); | ||
//}) | ||
const getFileBuffer = () => document.getElementById("json-file").files[0]; | ||
const isNumeric = (n) => !isNaN(n); | ||
const dec2bin = (dec) => (dec >>> 0).toString(2); | ||
|
||
const bitFontIntoImage = () => getFileBuffer().text().then((text) => { | ||
const json = JSON.parse(text); | ||
for (const charCode in json) { | ||
if (!isNumeric(charCode)) { | ||
continue; | ||
} | ||
const char = String.fromCharCode(charCode); | ||
console.log(`"${charCode}" ${char}`); | ||
const frameData = json[charCode]; | ||
let debugView = ""; | ||
for (const line of frameData) { | ||
const bits = dec2bin(line); | ||
debugView += bits.padStart(16, "0").split("").reverse().join("") + "\n"; | ||
} | ||
console.log(debugView.replaceAll("0", " ").replaceAll("1", "■")); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters