Initial work of ESM transformation

This commit is contained in:
be5invis 2022-07-16 19:26:49 -07:00
parent 2472c9cff2
commit b8205a63aa
303 changed files with 1959 additions and 2450 deletions

View file

@ -1,19 +0,0 @@
const UnicodeDataIndex = require("@unicode/unicode-14.0.0");
const BlockData = [
[[0xe0a0, 0xe0df], "Private Use Area — Powerline"],
[[0xee00, 0xee3f], "Private Use Area — Progress Bar"],
// Missing ranges in UnicodeDataIndex
[[0x1fa70, 0x1faff], "Symbols and Pictographs Extended-A "],
[[0x1fb00, 0x1fbff], "Symbols for Legacy Computing"]
];
for (const id of UnicodeDataIndex.Block) {
if (!id || /Private_Use_Area/.test(id) || /undefined/.test(id)) continue;
const rg = require(`@unicode/unicode-14.0.0/Block/${id}/ranges`);
BlockData.push([[rg[0].begin, rg[0].end - 1], id.replace(/_/g, " ")]);
}
BlockData.sort((a, b) => a[0][0] - b[0][0]);
exports.BlockData = BlockData;

View file

@ -0,0 +1,15 @@
import UnicodeDataIndex from "@unicode/unicode-14.0.0";
const BlockData = [
[[0xe0a0, 0xe0df], "Private Use Area — Powerline"],
[[0xee00, 0xee3f], "Private Use Area — Progress Bar"],
// Missing ranges in UnicodeDataIndex
[[0x1fa70, 0x1faff], "Symbols and Pictographs Extended-A "],
[[0x1fb00, 0x1fbff], "Symbols for Legacy Computing"]
];
for (const id of UnicodeDataIndex.Block) {
if (!id || /Private_Use_Area/.test(id) || /undefined/.test(id))
continue;
BlockData.push([[rg[0].begin, rg[0].end - 1], id.replace(/_/g, " ")]);
}
BlockData.sort((a, b) => a[0][0] - b[0][0]);
export { BlockData };

View file

@ -1,16 +1,29 @@
const { BlockData } = require("./block-data");
const ucdNames = require("@unicode/unicode-14.0.0/Names");
const ugc = require("@unicode/unicode-14.0.0/General_Category");
// eslint-disable-next-line complexity
exports.gatherCoverageData = function (covUpright, covItalic, covOblique) {
import { BlockData } from "./block-data.mjs";
import ucdNames from "@unicode/unicode-14.0.0/Names";
import ugc from "@unicode/unicode-14.0.0/General_Category";
function findFirstLastChar(lchBlockStart, lchBlockEnd, cov) {
let lchFirst = 0,
lchLast = 0;
for (const [lchFont] of cov) {
if (lchFont < 0x20 || lchFont < lchBlockStart || lchFont > lchBlockEnd) continue;
if (!lchFirst || lchFont < lchFirst) lchFirst = lchFont;
if (!lchLast || lchFont > lchLast) lchLast = lchFont;
}
if (!lchFirst || !lchLast) return [0, 0];
if (lchBlockEnd - lchBlockStart <= 0x100 && lchBlockStart > 0xff) {
lchFirst = lchBlockStart;
lchLast = lchBlockEnd;
}
const lchStart = (lchFirst >>> 4) << 4;
const lchEnd = ((lchLast >>> 4) << 4) + 0x10;
return [lchStart, lchEnd];
}
export const gatherCoverageData = function (covUpright, covItalic, covOblique) {
const result = [];
for (const [[lchBlockStart, lchBlockEnd], block] of BlockData) {
let blockResults = [];
const [lchStart, lchEnd] = findFirstLastChar(lchBlockStart, lchBlockEnd, covUpright);
if (!lchStart || !lchEnd) continue;
for (let lch = lchStart; lch < lchEnd; lch++) {
const chName = ucdNames.get(lch);
const gc = ugc.get(lch);
@ -42,7 +55,6 @@ exports.gatherCoverageData = function (covUpright, covItalic, covOblique) {
});
}
}
if (blockResults.length) {
result.push({
name: block,
@ -52,21 +64,3 @@ exports.gatherCoverageData = function (covUpright, covItalic, covOblique) {
}
return result;
};
function findFirstLastChar(lchBlockStart, lchBlockEnd, cov) {
let lchFirst = 0,
lchLast = 0;
for (const [lchFont] of cov) {
if (lchFont < 0x20 || lchFont < lchBlockStart || lchFont > lchBlockEnd) continue;
if (!lchFirst || lchFont < lchFirst) lchFirst = lchFont;
if (!lchLast || lchFont > lchLast) lchLast = lchFont;
}
if (!lchFirst || !lchLast) return [0, 0];
if (lchBlockEnd - lchBlockStart <= 0x100 && lchBlockStart > 0xff) {
lchFirst = lchBlockStart;
lchLast = lchBlockEnd;
}
const lchStart = (lchFirst >>> 4) << 4;
const lchEnd = ((lchLast >>> 4) << 4) + 0x10;
return [lchStart, lchEnd];
}