Skip to content
This repository has been archived by the owner on Aug 27, 2023. It is now read-only.

Commit

Permalink
Name table fix again
Browse files Browse the repository at this point in the history
  • Loading branch information
celestialphineas committed Sep 28, 2020
1 parent 4bb0f8a commit ced7274
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/font-build/tables/CFF_.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function getTable(langStr, widthStr, weightStr, verStr, widthFactor) {
weight: `${weightStr}`,
cidRegistry: 'Adobe',
cidOrdering: 'Identity',
cidSupplement: 'Identity',
cidSupplement: 0,
fdArray: {
[fd]: { privates: {
defaultWidthX: Math.round(1000 * widthFactor),
Expand Down
4 changes: 2 additions & 2 deletions src/font-build/tables/OS_2.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function getTable(weightClass, widthClass, xHeight, capHeight) {
"Bopomofo": true, // done
// "Hangul_Compatibility_Jamo": true,
// "Enclosed_CJK_Letters_And_Months": true,
// "CJK_Compatibility": true,
"CJK_Compatibility": true,
// "Hangul_Syllables": true,
"Non_Plane_0": true, // done
"CJK_Unified_Ideographs": true, // done
Expand All @@ -50,7 +50,7 @@ function getTable(weightClass, widthClass, xHeight, capHeight) {
"Halfwidth_And_Fullwidth_Forms": true // done
},
"ulUnicodeRange4": {},
"fsSelection": {},
"fsSelection": { "bold": weightClass === 700 },
"sTypoAscender": 880,
"sTypoDescender": -120,
"sTypoLineGap": 0,
Expand Down
63 changes: 34 additions & 29 deletions src/font-build/tables/name.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const zh_CN = 0x0804, zh_HK = 0x0C04, zh_MO = 0x1404,
zh_SG = 0x1004, zh_TW = 0x0404, jp = 0x0411;
const zh_hans_MAC = 25, zh_hant_MAC = 2, ja_MAC = 1, ro_MAC = 0;
const zh_CN_WIN = 0x0804, zh_HK_WIN = 0x0C04, zh_MO_WIN = 0x1404,
zh_SG_WIN = 0x1004, zh_TW_WIN = 0x0404, ja_WIN = 0x0411;

const UNICODE=0, MACINTOSH=1, ISO=2, WINDOWS=3, CUSTOM=4;

const copyrightNotice = 0, familyName = 1,
subfamilyName = 2, identifier = 3,
Expand All @@ -12,10 +15,11 @@ const copyrightNotice = 0, familyName = 1,
typoFamilyName = 16, typoSubfamilyName = 17,
sampleText = 19;

function record(nameID, nameString, languageID) { return ({
"platformID": 1,
function record(nameID, nameString,
{ languageID = 0x0409, platformID = WINDOWS } = {}) { return ({
"platformID": platformID,
"encodingID": 1,
"languageID": languageID || 0x0409,
"languageID": languageID,
"nameID": nameID,
"nameString": nameString
}); }
Expand All @@ -26,10 +30,11 @@ function record(nameID, nameString, languageID) { return ({
* @param { string } widthStr Font width string
* @param { string } verStr Font version string */
function getTable (langStr, weightStr, widthStr, verStr) {
const postFamilyName = [ 'Regular', 'Bold' ].includes(weightStr) ? '' : ` ${weightStr}`;
const name = [
record(copyrightNotice, 'Glow Sans © 2020 Project Welai'),
record(familyName, `Glow Sans ${langStr} ${widthStr}`),
record(subfamilyName, weightStr),
record(familyName, `Glow Sans ${langStr} ${widthStr}` + postFamilyName),
record(subfamilyName, weightStr === 'Bold' ? 'Bold' : 'Regular'),
record(identifier, `${verStr};WELA;GlowSans${langStr}-${widthStr}-${weightStr}`),
record(fullName, `Glow Sans ${langStr} ${widthStr} ${weightStr}`),
record(versionStr, `Version ${verStr}`),
Expand All @@ -41,31 +46,31 @@ function getTable (langStr, weightStr, widthStr, verStr) {
record(licenseDesc, 'This Font Software is licensed under the SIL Open Font License, Version 1.1. This Font Software is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the SIL Open Font License for the specific language, permissions and limitations governing your use of this Font Software.'),
record(urlLicense, 'http://scripts.sil.org/OFL'),
record(typoFamilyName, `Glow Sans ${langStr}`),
record(typoSubfamilyName, `${widthStr} ${weightStr}`),
record(typoFamilyName, `Glow Sans ${langStr}`),
record(sampleText, '青青子衿,悠悠我心。縱我不往,子寧不嗣音?')
];
switch (langStr) {
case 'SC': [ zh_CN ].forEach((lang) => name.push(
record(familyName, `未来荧黑 ${widthStr}`, lang),
record(subfamilyName, `${weightStr}`, lang),
record(fullName, `未来荧黑 ${widthStr} ${weightStr}`, lang),
record(typoFamilyName, `未来荧黑`, lang),
record(typoSubfamilyName, `${widthStr} ${weightStr}`, lang)
)); break;
case 'TC': [ zh_TW ].forEach((lang) => name.push(
record(familyName, `未来熒黑${widthStr}`, lang),
record(subfamilyName, `${weightStr}`, lang),
record(fullName, `未来熒黑 ${widthStr} ${weightStr}`, lang),
record(typoFamilyName, `未来熒黑`, lang),
record(typoSubfamilyName, `${widthStr} ${weightStr}`, lang)
)); break;
case 'J': [ jp ].forEach((lang) => name.push(
record(familyName, `ヒカリ角ゴ ${widthStr}`, lang),
record(subfamilyName, `${weightStr}`, lang),
record(fullName, `ヒカリ角ゴ ${widthStr} ${weightStr}`, lang),
record(typoFamilyName, `ヒカリ角ゴ`, lang),
record(typoSubfamilyName, `${widthStr} ${weightStr}`, lang)
)); break;
case 'SC': name.push(
record(familyName, `未来荧黑 ${widthStr}` + postFamilyName, { languageID: zh_CN_WIN }),
record(subfamilyName, weightStr === 'Bold' ? 'Bold' : 'Regular', { languageID: zh_CN_WIN }),
record(fullName, `未来荧黑 ${widthStr} ${weightStr}`, { languageID: zh_CN_WIN }),
record(typoFamilyName, `未来荧黑`, { languageID: zh_CN_WIN }),
record(typoSubfamilyName, `${widthStr} ${weightStr}`, { languageID: zh_CN_WIN })
); break;
case 'TC': name.push(
record(familyName, `未来熒黑${widthStr}` + postFamilyName, { languageID: zh_TW_WIN }),
record(subfamilyName, weightStr === 'Bold' ? 'Bold' : 'Regular', { languageID: zh_TW_WIN }),
record(fullName, `未来熒黑 ${widthStr} ${weightStr}`, { languageID: zh_TW_WIN }),
record(typoFamilyName, `未来熒黑`, { languageID: zh_TW_WIN }),
record(typoSubfamilyName, `${widthStr} ${weightStr}`, { languageID: zh_TW_WIN }),
); break;
case 'J': name.push(
record(familyName, `ヒカリ角ゴ ${widthStr}` + postFamilyName, { languageID: ja_WIN }),
record(subfamilyName, weightStr === 'Bold' ? 'Bold' : 'Regular', { languageID: ja_WIN }),
record(fullName, `ヒカリ角ゴ ${widthStr} ${weightStr}`, { languageID: ja_WIN }),
record(typoFamilyName, `ヒカリ角ゴ`, { languageID: ja_WIN }),
record(typoSubfamilyName, `${widthStr} ${weightStr}`, { languageID: ja_WIN })
); break;
default: throw Error(`Unimplemented language for ${langStr}`);
}
return name;
Expand Down

0 comments on commit ced7274

Please sign in to comment.