optimize
This commit is contained in:
parent
12a4f1edb1
commit
7ebf31cbb3
1 changed files with 13 additions and 20 deletions
|
@ -12,9 +12,6 @@ export function createNamingDictFromArgv(argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function assignFontNames(font, naming, isQuasiProportional) {
|
export function assignFontNames(font, naming, isQuasiProportional) {
|
||||||
// Clear existing names
|
|
||||||
font.name.records.length = 0;
|
|
||||||
|
|
||||||
// Preferred names
|
// Preferred names
|
||||||
const family = naming.family.trim();
|
const family = naming.family.trim();
|
||||||
const style = getStyle(naming.weight, naming.width, naming.slope);
|
const style = getStyle(naming.weight, naming.width, naming.slope);
|
||||||
|
@ -145,23 +142,19 @@ function getStyleLinkedStyles(weight, width, slope) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function nameFont(font, nameID, str) {
|
function nameFont(font, nameID, str) {
|
||||||
// Mac Roman
|
nameFontImpl(font.name.records, 1, 0, 0, nameID, Buffer.from(str, "utf-8")); // Mac Roman
|
||||||
font.name.records.push({
|
nameFontImpl(font.name.records, 3, 1, 1033, nameID, str); // Windows Unicode English
|
||||||
platformID: 1,
|
}
|
||||||
encodingID: 0,
|
function nameFontImpl(records, platformID, encodingID, languageID, nameID, value) {
|
||||||
languageID: 0,
|
for (let record of records) {
|
||||||
nameID,
|
if (record.platformID !== platformID) continue;
|
||||||
value: Buffer.from(str, "utf-8")
|
if (record.encodingID !== encodingID) continue;
|
||||||
});
|
if (record.languageID !== languageID) continue;
|
||||||
|
if (record.nameID !== nameID) continue;
|
||||||
// Windows Unicode English
|
record.value = value;
|
||||||
font.name.records.push({
|
return;
|
||||||
platformID: 3,
|
}
|
||||||
encodingID: 1,
|
records.push({ platformID, encodingID, languageID, nameID, value });
|
||||||
languageID: 1033,
|
|
||||||
nameID,
|
|
||||||
value: str
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isRBIZ(weight, slope) {
|
function isRBIZ(weight, slope) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue