-
Fork this repositry.
-
Pick a fantastic name for your project.
-
Take a snapshot
git clone --branch=master --depth=1 [email protected]:me/fantastic-font.git
-
For further update
git remote add upstream https://github.com/milky-han/mhm.git git fetch upstream git merge upstream/master
git clone --branch=master --depth=1 https://github.com/milky-han/mhm.git my-workspace
cd my-workspace
git checkout -b mywork
-
Download latest Node.js from official site and install it; or install
nodejs
from package manager. -
Download latest Python 3 from official site and install it if not installed yet.
-
Install afdko globally.
pip install --user afdko
-
Download otfcc from GitHub release or Warcraft Font Merger repo (
bin-*/
), and add it toPATH
. -
Download ttfautohint from offcial site and add it to
PATH
.Windows binary works well in WineHQ.
-
Run
npm install
in your workspace. -
Download 7-Zip from official site and add it to
PATH
, or installp7zip
from package manager, if you would like to distribute your work.
Here we take Fira Code for example.
Download idh-cache.7z
from releases and extract it to your workspace
The directory stucture looks like:
fira-han ─┬─ ...
├─ cache ─── idh ─┬─ Light.json
│ ├─ Normal.json
│ ├─ Regular.json
│ ├─ Medium.json
│ ├─ Bold.json
│ └─ ...
├─ sources ─┬─ ...
│ ├─ FiraCode ─┬─ FiraCode-Light.ttf
│ │ ├─ FiraCode-Regular.ttf
│ │ ├─ FiraCode-Retina.ttf
│ │ ├─ FiraCode-Medium.ttf
│ │ ├─ FiraCode-Bold.ttf
│ │ └─ FiraCode-VF.ttf
│ └─ shs ─── ...
├─ config.json
├─ verdafile.js
└─ package.json
Note: you need either static instances (-Light.ttf
, -Regular.ttf
, -Retina.ttf
, -Medium.ttf
, and -Bold.ttf
) or variable font (-VF.ttf
).
To dicide the width, we are interested in these 2 values: head.unitsPerEm
and glyf["A"].advanceWidth
.
The values will be processed in following steps:
- Scale outlines and metric values, making the advance width of "A" match
width
inconfig.json
. - Set
head.unitsPerEm
to 1000.
Let us inspect metric values with otfccdump
.
otfccdump FiraCode-Regular.ttf --pretty -o FiraCode-Regular.json
Fira Code has head.unitsPerEm
of 1950 and glyf["A"].advanceWidth
of 1200.
We find that 1200/1950 ≈ 615/1000, which suggests
- 615 is a good value for
width
inconfig.json
, texts being the same size as Fira Code. - 600 is another good value, texts being slightly smaller, but having better alignment.
We choose 600. Edit config.json
:
"width": 600,
Edit config.json
:
"familyOrder": [ "code" ],
"families": {
"code": {
"isMono": true,
"latinGroup": "FiraCode",
"naming": {
"en_US": "Fira Han Code",
"zh_CN": "Fira 汉 Code",
"zh_TW": "Fira 漢 Code",
"zh_HK": "Fira 漢 Code",
"ja_JP": "ファイラ漢 Code",
"ko_KR": "파이라 한 Code"
}
}
},
Style | Fira Code | Source Han Sans |
---|---|---|
light |
Light | Light |
regular |
Regular | Normal |
retina |
Retina | Regular |
medium |
Medium | Medium |
bold |
Bold | Bold |
Edit config.json
:
"styleOrder": [
"light",
"regular",
"retina",
"medium",
"bold"
],
"styles": {
"light": {
"suffix": "-Light",
"name": "Light"
},
"regular": {
"suffix": "-Regular",
"name": "Regular"
},
"retina": {
"suffix": "-Retina",
"name": "Retina"
},
"medium": {
"suffix": "-Medium",
"name": "Medium"
},
"bold": {
"suffix": "-Bold",
"name": "Bold"
}
},
"shsSourceMap": {
...,
"style": {
"light" : "Light",
"regular": "Normal",
"retina" : "Regular",
"medium" : "Medium",
"bold" : "Bold"
}
}
Fira Code VF has 1 axis – wght
(weight).
Style | Fira Code VF | Source Han Sans |
---|---|---|
light |
wght = 300 | Light |
regular |
wght = 400 | Normal |
retina |
wght = 450 | Regular |
medium |
wght = 500 | Medium |
bold |
wght = 700 | Bold |
"styleOrder": [
"light",
"regular",
"retina",
"medium",
"bold"
],
"styles": {
"light": {
"suffix": "-VF",
"variation": { "wght": 300 },
"name": "Light"
},
"regular": {
"suffix": "-VF",
"variation": { "wght": 400 },
"name": "Regular"
},
"retina": {
"suffix": "-VF",
"variation": { "wght": 450 },
"name": "Retina"
},
"medium": {
"suffix": "-VF",
"variation": { "wght": 500 },
"name": "Medium"
},
"bold": {
"suffix": "-VF",
"variation": { "wght": 700 },
"name": "Bold"
}
},
"shsSourceMap": {
...,
"style": {
"light" : "Light",
"regular": "Normal",
"retina" : "Regular",
"medium" : "Medium",
"bold" : "Bold"
}
}
Keep what you need. For example, SC
, TC
and HC
.
"subfamilyOrder": {
"sc+tc+hc": [ "sc", "tc", "hc" ]
},
"ttcMode": {
"sc+tc+hc": "normal"
},
The number of unique glyphs in SC, TC and HC is less than 65535, so “normal” mode can be used. If you are not sure, use “mixed” mode.
Copyright notice in config.json
and LICENSE
:
"copyright": "Portions Copyright 2012-2015 The Fira Project Authors (https://github.com/tonsky/FiraCode). Portions © 2014-2019 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'.",
Filename prefix in verdafile.js
:
const PREFIX = `fira-han`;
const TTCPREFIX = `fira-han`;
Version in package.json
:
"name": "fira-han-code",
"version": "0.1.0",
npm run build ttf
npm run build ttc
The files would be in out/ttf
and/or out/ttc
directory.
To build 7z archive for distribution, run
npm run build all
The files would be in out/
directory.
NOTE: Check the licenses before distributing.
| Language | Naming |
| -------- | --------------- |
| en-US | Fira Han Code |
| zh-CN | Fira 汉 Code |
| zh-TW | Fira 漢 Code |
| zh-HK | Fira 漢 Code |
| ja-JP | ファイラ漢 Code |
| ko-KR | 파이라 한 Code |
function $initHighlight(block, flags) {
if (!!flags) {
try {
if (block.className.search(/\bno\-hightlight\b/) != -1)
return processBlock(block.__proto__.function, true, 0xFF);
} catch (e) {
/* handle exception */
}
for (var i = 0 / 2; i <= classes.length; i++) {
if (checkCondition(classes[i]) === undefined)
return /\d+[\s/]/g;
}
}
}