Skip to content

Commit 89369d1

Browse files
committed
Fix repository url and clean up files
1 parent be9371e commit 89369d1

4 files changed

Lines changed: 69 additions & 40 deletions

File tree

.prettierignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,21 @@
11
{
22
"name": "fallback-font",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "A font that maps every character to one glyph.",
55
"scripts": {
6-
"build": "node ./scripts/build.js",
7-
"eslint": "eslint --fix .",
8-
"prettier": "prettier -w ."
6+
"build": "node ./scripts/build.js"
97
},
108
"repository": {
119
"type": "git",
12-
"url": "git+https://github.com/jwr12135/fallback-font.git"
10+
"url": "git+https://github.com/jwr1/fallback-font.git"
1311
},
1412
"keywords": [
1513
"font"
1614
],
17-
"author": "jwr12135",
15+
"author": "jwr1",
1816
"license": "MIT",
1917
"bugs": {
20-
"url": "https://github.com/jwr12135/fallback-font/issues"
18+
"url": "https://github.com/jwr1/fallback-font/issues"
2119
},
22-
"homepage": "https://github.com/jwr12135/fallback-font#readme",
23-
"devDependencies": {
24-
"@airbnb-config/eslint-base": "^1.0.1",
25-
"@airbnb-config/prettier": "^1.0.2",
26-
"eslint": "^7.30.0",
27-
"prettier": "^2.3.2"
28-
},
29-
"eslintConfig": {
30-
"extends": "./node_modules/@airbnb-config/eslint-base",
31-
"ignorePatterns": "woff2",
32-
"rules": {
33-
"no-bitwise": "off"
34-
}
35-
},
36-
"prettier": "@airbnb-config/prettier"
20+
"homepage": "https://github.com/jwr1/fallback-font#readme"
3721
}

scripts/build.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
const { exec } = require('child_process');
22
const { mkdirSync, rmSync, existsSync } = require('fs');
3-
const { Path, genFont } = require('./gen-font');
3+
const { Path, genFont } = require('./font');
44

55
function generateFonts() {
6+
console.log('Building fonts...');
67
genFont({
78
name: 'Fallback Outline',
89
version: '1.0',
@@ -49,5 +50,6 @@ mkdirSync('./dist');
4950
if (existsSync('./woff2/woff2_compress')) {
5051
generateFonts();
5152
} else {
53+
console.log('Compiling woff2...');
5254
exec('cd woff2 && make clean all', generateFonts);
5355
}
Lines changed: 60 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ function inRange(v, min, max) {
2525
*/
2626
function checkRange(name, type, v, min, max) {
2727
if (!inRange(v, min, max))
28-
throw Error(`${type} "${name}" has value ${v} which is not in range of ${min} to ${max}`);
28+
throw Error(
29+
`${type} "${name}" has value ${v} which is not in range of ${min} to ${max}`,
30+
);
2931
return v;
3032
}
3133

@@ -53,7 +55,9 @@ function Table(name, value) {
5355
Object.defineProperties(Table.prototype, {
5456
size: {
5557
get() {
56-
return this.value.length === 0 ? 0 : this.value.map((v) => v.size).reduce((a, b) => a + b);
58+
return this.value.length === 0
59+
? 0
60+
: this.value.map((v) => v.size).reduce((a, b) => a + b);
5761
},
5862
},
5963
encode: {
@@ -258,7 +262,13 @@ Object.defineProperties(LongDateTime.prototype, {
258262
size: { value: 8 },
259263
encode: {
260264
value() {
261-
return [0, 0, 0, 0, ...intToBytes(Math.round(this.value.getTime() / 1000) + 0x7c25b080, 4)];
265+
return [
266+
0,
267+
0,
268+
0,
269+
0,
270+
...intToBytes(Math.round(this.value.getTime() / 1000) + 0x7c25b080, 4),
271+
];
262272
},
263273
},
264274
});
@@ -353,7 +363,9 @@ Object.defineProperties(CffIndex.prototype, {
353363
}
354364
if (offSize) break;
355365
}
356-
const offsetType = { 1: uint8, 2: uint16, 3: uint24, 4: uint32 }[offSize];
366+
const offsetType = { 1: uint8, 2: uint16, 3: uint24, 4: uint32 }[
367+
offSize
368+
];
357369
return Table(this.name, [
358370
uint32('count', this.value.length),
359371
uint8('offSize', offSize),
@@ -420,7 +432,14 @@ Object.defineProperties(CffNum.prototype, {
420432
* @param {glyphBounds} props.glyphBounds
421433
* @returns {Table}
422434
*/
423-
const genHead = ({ majorVersion, minorVersion, checksumAdjustment, flags, date, glyphBounds }) =>
435+
const genHead = ({
436+
majorVersion,
437+
minorVersion,
438+
checksumAdjustment,
439+
flags,
440+
date,
441+
glyphBounds,
442+
}) =>
424443
Table('head', [
425444
uint16('majorVersion', 1),
426445
uint16('minorVersion', 0),
@@ -476,7 +495,8 @@ const genHhea = ({ glyphBounds, width }) =>
476495
* https://docs.microsoft.com/en-us/typography/opentype/spec/maxp
477496
* @returns {Table}
478497
*/
479-
const genMaxp = () => Table('maxp', [uint32('version', 0x00005000), uint16('numGlyphs', 2)]);
498+
const genMaxp = () =>
499+
Table('maxp', [uint32('version', 0x00005000), uint16('numGlyphs', 2)]);
480500

481501
/**
482502
* https://docs.microsoft.com/en-us/typography/opentype/spec/os2
@@ -546,7 +566,7 @@ const genOS2 = ({ width, glyphBounds }) =>
546566
*/
547567
const genName = ({ name, version }) => {
548568
const nameData = Table('data', [
549-
String16('copyright', 'github.com/jwr12135/fallback-font'),
569+
String16('copyright', 'github.com/jwr1/fallback-font'),
550570
String16('fontFamily', name),
551571
String16('fontSubfamily', 'Regular'),
552572
String16('uniqueID', `${name.replace(/ /g, '')}-${version}`),
@@ -730,13 +750,23 @@ const genCff2 = (path) =>
730750
]),
731751
CffIndex('globalSubrIndex', []),
732752
CffIndex('charStringsIndex', [
733-
Table('glyph0', [Table('callsubr', [CffNum('offset', -107), uint8('op', 10)])]),
734-
Table('glyph1', [Table('callsubr', [CffNum('offset', -107), uint8('op', 10)])]),
753+
Table('glyph0', [
754+
Table('callsubr', [CffNum('offset', -107), uint8('op', 10)]),
755+
]),
756+
Table('glyph1', [
757+
Table('callsubr', [CffNum('offset', -107), uint8('op', 10)]),
758+
]),
735759
]),
736760
CffIndex('fontDictIndex', [
737-
Table('Private', [CffNum('size', 2), CffNum('offset', 36), uint8('op', 18)]),
761+
Table('Private', [
762+
CffNum('size', 2),
763+
CffNum('offset', 36),
764+
uint8('op', 18),
765+
]),
766+
]),
767+
Table('privateDict0', [
768+
Table('Subrs', [CffNum('num', 2), uint8('op', 19)]),
738769
]),
739-
Table('privateDict0', [Table('Subrs', [CffNum('num', 2), uint8('op', 19)])]),
740770
CffIndex('localSubrIndex', [Table('localSubrIndex0', path.cffPath)]),
741771
]);
742772

@@ -749,8 +779,14 @@ const genCff2 = (path) =>
749779
*/
750780
const genHmtx = ({ width, glyphBounds }) =>
751781
Table('hmtx', [
752-
Table('glyph0', [uint16('advanceWidth', width), int16('lsb', glyphBounds.xMin)]),
753-
Table('glyph1', [uint16('advanceWidth', width), int16('lsb', glyphBounds.xMin)]),
782+
Table('glyph0', [
783+
uint16('advanceWidth', width),
784+
int16('lsb', glyphBounds.xMin),
785+
]),
786+
Table('glyph1', [
787+
uint16('advanceWidth', width),
788+
int16('lsb', glyphBounds.xMin),
789+
]),
754790
]);
755791

756792
/**
@@ -763,7 +799,11 @@ const calcChecksum = (data) => {
763799

764800
let sum = 0;
765801
for (let i = 0; i < bytes.length; i += 4) {
766-
const val = (bytes[i] << 24) + (bytes[i + 1] << 16) + (bytes[i + 2] << 8) + bytes[i + 3];
802+
const val =
803+
(bytes[i] << 24) +
804+
(bytes[i + 1] << 16) +
805+
(bytes[i + 2] << 8) +
806+
bytes[i + 3];
767807
sum += val < 0 ? val + 0x100000000 : val;
768808
}
769809

@@ -782,7 +822,9 @@ module.exports = {
782822
*/
783823
genFont({ name, version, path, width, date = new Date() }) {
784824
const fileName = name.toLowerCase().replace(/ /g, '-');
785-
const [majorVersion, minorVersion] = version.split('.').map((v) => parseInt(v, 10));
825+
const [majorVersion, minorVersion] = version
826+
.split('.')
827+
.map((v) => parseInt(v, 10));
786828
const glyphBounds = {
787829
xMin: path.xMin,
788830
yMin: path.yMin,
@@ -839,7 +881,9 @@ module.exports = {
839881
]);
840882
const newChecksumAdjustment = 0xb1b0afba - calcChecksum(otfFile.encode());
841883
checksumAdjustment.value =
842-
newChecksumAdjustment < 0 ? newChecksumAdjustment + 0x100000000 : newChecksumAdjustment;
884+
newChecksumAdjustment < 0
885+
? newChecksumAdjustment + 0x100000000
886+
: newChecksumAdjustment;
843887
writeFileSync(`./dist/${fileName}.otf`, new Uint8Array(otfFile.encode()));
844888

845889
spawn('./woff2/woff2_compress', [`./dist/${fileName}.otf`]);

0 commit comments

Comments
 (0)