Skip to content

Commit

Permalink
0.1.3: proportional kana in UI variant
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanoHao committed Jan 12, 2019
1 parent 93e6d07 commit 83f8fb1
Show file tree
Hide file tree
Showing 12 changed files with 919 additions and 819 deletions.
1,532 changes: 767 additions & 765 deletions Makefile

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions README-Hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@

不同的地区变体采用了不同的字形标准。

| 地区变体\语言 | 西文 | 简体中文 | 繁体中文 | 韩国语 |
| -------------- | --------------------- | ------------ | -------- | -------- |
| CN | 中国大陆字形 | 中国大陆字形 | 台湾字形 | 传统字形 |
| TW | 台湾字形 | 中国大陆字形 | 台湾字形 | 传统字形 |
| HK | 香港字形 | 中国大陆字形 | 香港字形 | 传统字形 |
| CL | 传统字形 | 传统字形 | 传统字形 | 传统字形 |
| OSF | 传统字形(不齐线数字)| 传统字形 | 传统字形 | 传统字形 |
| 地区变体\语言 | 西文 | 简体中文 | 繁体中文 | 韩国语 |
| -------------- | ------------------------- | ------------ | -------- | -------- |
| CN | 中国大陆字形(UI) | 中国大陆字形 | 台湾字形 | 传统字形 |
| TW | 台湾字形(UI) | 中国大陆字形 | 台湾字形 | 传统字形 |
| HK | 香港字形(UI) | 中国大陆字形 | 香港字形 | 传统字形 |
| CL | 传统字形(UI) | 传统字形 | 传统字形 | 传统字形 |
| OSF | 传统字形(UI,不齐线数字)| 传统字形 | 传统字形 | 传统字形 |

* 西文:英语、西班牙语(拉丁美洲)、葡萄牙语、德语、西班牙语(欧洲)、法语、意大利语、俄语。
* UI:中西文共用的标点视作西文标点;比例假名。
15 changes: 8 additions & 7 deletions README-Hant.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@

不同的地區變體採用了不同的字形標準。

| 地區變體\語言 | 西文 | 簡體中文 | 繁體中文 | 韓國語 |
| -------------- | --------------------- | ------------ | -------- | -------- |
| CN | 中國大陸字形 | 中國大陸字形 | 臺灣字形 | 傳統字形 |
| TW | 臺灣字形 | 中國大陸字形 | 臺灣字形 | 傳統字形 |
| HK | 香港字形 | 中國大陸字形 | 香港字形 | 傳統字形 |
| CL | 傳統字形 | 傳統字形 | 傳統字形 | 傳統字形 |
| OSF | 傳統字形(不齊線數字)| 傳統字形 | 傳統字形 | 傳統字形 |
| 地區變體\語言 | 西文 | 簡體中文 | 繁體中文 | 韓國語 |
| -------------- | ------------------------- | ------------ | -------- | -------- |
| CN | 中國大陸字形(UI) | 中國大陸字形 | 臺灣字形 | 傳統字形 |
| TW | 臺灣字形(UI) | 中國大陸字形 | 臺灣字形 | 傳統字形 |
| HK | 香港字形(UI) | 中國大陸字形 | 香港字形 | 傳統字形 |
| CL | 傳統字形(UI) | 傳統字形 | 傳統字形 | 傳統字形 |
| OSF | 傳統字形(UI,不齊線數字)| 傳統字形 | 傳統字形 | 傳統字形 |

* 西文:英語、西班牙語(拉丁美洲)、葡萄牙語、德語、西班牙語(歐洲)、法語、義大利語、俄語。
* UI:中西文共用的標點視作西文標點;比例假名。
19 changes: 10 additions & 9 deletions README-Pinyin.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[English](README.md) [简体中文](README-Hans.md) [繁體中文](README-Hant.md) **Hànyǔ Pīnyīn**

*Zhùshì: zhè shì yī piān cèshì Kuòzhǎn Lāding Zìfú de wéndàng.*
*Zhùshì: zhè shì yī piān cèshì Kuòzhǎn Lādīng Zìfú de wéndàng.*

# Yǒu’ài Yuánjiǎo Zìtǐ

Expand Down Expand Up @@ -30,12 +30,13 @@ Yǒu’ài Yuánjiǎo Zìtǐ yǒu 4 zhǒng zìtǐ cūxì hé 5 zho

Bù tóng de dìqū biànhuà de zìtǐ xíngtài cǎiyòng le bù tóng de zìtǐ xíngtài biāozhǔn.

| | Xīfāng yǔyán | Jiǎntǐ zhōngwén | Fántǐ zhōngwén | Hánguó yǔ |
| ---- | --------------------- | ------------ | -------- | -------- |
| CN | Zhōngguó dàlù zìtǐ xíngtài | Zhōngguó dàlù zìtǐ xíngtài | Táiwān zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài |
| TW | Táiwān zìtǐ xíngtài | Zhōngguó dàlù zìtǐ xíngtài | Táiwān zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài |
| HK | Xiānggǎng zìtǐ xíngtài | Zhōngguó dàlù zìtǐ xíngtài | Xiānggǎng zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài |
| CL | Chuántǒng de zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài |
| OSF | Chuántǒng de zìtǐ xíngtài (bù duìqí jīzhǔnxiàn de shùzì) | Chuántǒng de zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài |
| | Xīfāng yǔyán | Jiǎntǐ zhōngwén | Fántǐ zhōngwén | Hánguó yǔ |
| --- | --- | --- | --- | --- |
| CN | Zhōngguó dàlù zìtǐ xíngtài (UI xíngshì) | Zhōngguó dàlù zìtǐ xíngtài | Táiwān zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài |
| TW | Táiwān zìtǐ xíngtài (UI xíngshì) | Zhōngguó dàlù zìtǐ xíngtài | Táiwān zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài |
| HK | Xiānggǎng zìtǐ xíngtài (UI xíngshì) | Zhōngguó dàlù zìtǐ xíngtài | Xiānggǎng zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài |
| CL | Chuántǒng de zìtǐ xíngtài (UI xíngshì) | Chuántǒng de zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài |
| OSF | Chuántǒng de zìtǐ xíngtài (UI xíngshì, bù duìqí jīzhǔnxiàn de shùzì) | Chuántǒng de zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài | Chuántǒng de zìtǐ xíngtài |

* Xīfāng wénzì: Yīngyǔ, Xībānyá yǔ (Lādīng Měizhōu), Pútáoyá yǔ, Déyǔ, Xībānyá yǔ (Ōuzhōu), Fǎyǔ, Yìdàlì yǔ, Éyǔ.
* Xīfāng yǔyán: Yīngyǔ, Xībānyá yǔ (Lādīng Měizhōu), Pútáoyá yǔ, Déyǔ, Xībānyá yǔ (Ōuzhōu), Fǎyǔ, Yìdàlì yǔ, Éyǔ.
* UI xíngshì: bèi zhōngwén hé xīfāng wénzì gòngyòng de biāodiǎn fúhào, dōu bèi dāngzuò xīfāng wénzì de biāodiǎn fúhào; Rìyǔ jiǎmíng de kuāndù shì chéngbǐlì de.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ Nowar Rounded is provided in 4 weights and 5 regional variants.

The shape of Chinese characters follows different standards in different regional variants.

| Regional Variants \ Language | European | 简体中文 | 繁體中文 | 한국어 |
| ---------------------------- | ---------------------------- | -------------- | --------- | ------- |
| CN | Mainland China | Mainland China | Taiwan | Classic |
| TW | Taiwan | Mainland China | Taiwan | Classic |
| HK | Hong Kong | Mainland China | Hong Kong | Classic |
| CL | Classic | Classic | Classic | Classic |
| OSF | Classic with Oldstyle Figure | Classic | Classic | Classic |
| | European | 简体中文 | 繁體中文 | 한국어 |
| --- | ----------------------------- | -------------- | --------- | ------- |
| CN | Mainland China (UI) | Mainland China | Taiwan | Classic |
| TW | Taiwan (UI) | Mainland China | Taiwan | Classic |
| HK | Hong Kong (UI) | Mainland China | Hong Kong | Classic |
| CL | Classic (UI) | Classic | Classic | Classic |
| OSF | Classic (UI, Oldstyle Figure) | Classic | Classic | Classic |

* European: English, Español (AL), Português, Deutsch, Español (EU), Français, Italiano, and Русский.
* UI: Ambiguous punctations are treated as Western; Kana are proportional.

## How to Build

Expand Down
28 changes: 14 additions & 14 deletions configure.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
ver=0.1.2

weight=(ExtraLight Light Regular Medium Bold ExtraBold)
nowarWeight=(Light Regular Medium Bold)

Expand All @@ -12,7 +10,9 @@ regionNameMap=([CN]=CN [TW]=TW [HK]=HK [CL]=Classic [OSF]=Oldstyle)
encoding=(unspec gbk big5 korean)

cat >Makefile <<EOF
all: $(echo {CN,TW,HK,CL,OSF}-{L,R,M,B}-$ver.7z)
VERSION = 0.1.3
all: $(echo {CN,TW,HK,CL,OSF}-{L,R,M,B}-\${VERSION}.7z)
clean:
-rm -rf noto/*/*.otd noto/rounded/ noto/osf/
Expand All @@ -28,25 +28,25 @@ nowar/NowarCompactRounded-$w.ttf: nowar/NowarCompactRounded-$w.otd
otfccbuild -O3 \$< -o \$@
nowar/NowarCompactRounded-$w.otd: noto/rounded/NotoRounded-Condensed$w.otd
mkdir -p nowar/
python rename-morph.py $w $ver
python rename-morph.py $w \${VERSION}
nowar/NowarCompactRounded-OSF-$w.ttf: nowar/NowarCompactRounded-OSF-$w.otd
otfccbuild -O3 \$< -o \$@
nowar/NowarCompactRounded-OSF-$w.otd: noto/osf/NotoRoundedOSF-Condensed$w.otd
mkdir -p nowar/
python rename-morph-osf.py $w $ver
python rename-morph-osf.py $w \${VERSION}
nowar/NowarWideRounded-$w.ttf: nowar/NowarWideRounded-$w.otd
otfccbuild -O3 \$< -o \$@
nowar/NowarWideRounded-$w.otd: noto/rounded/NotoRounded-$w.otd
mkdir -p nowar/
python rename-skurri.py $w $ver
python rename-skurri.py $w \${VERSION}
nowar/NowarWideRounded-OSF-$w.ttf: nowar/NowarWideRounded-OSF-$w.otd
otfccbuild -O3 \$< -o \$@
nowar/NowarWideRounded-OSF-$w.otd: noto/osf/NotoRoundedOSF-$w.otd
mkdir -p nowar/
python rename-skurri-osf.py $w $ver
python rename-skurri-osf.py $w \${VERSION}
noto/osf/NotoRoundedOSF-Condensed$w.otd:
cd noto; make osf/NotoRoundedOSF-Condensed$w.otd
Expand Down Expand Up @@ -83,13 +83,13 @@ nowar/$e-NowarCompactRoundedUI-$r-$w.ttf: nowar/$e-NowarCompactRoundedUI-$r-$w.o
otfccbuild -O3 \$< -o \$@
nowar/$e-NowarCompactRoundedUI-$r-$w.otd: noto/$latinvar/NotoRounded$osf-Condensed$w.otd rhr/ResourceHanRounded$r-$w.otd
mkdir -p nowar/
python merge-compactui.py $r $w $e $ver
python merge-compactui.py $r $w $e \${VERSION}
nowar/$e-NowarWideRoundedUI-$r-$w.ttf: nowar/$e-NowarWideRoundedUI-$r-$w.otd
otfccbuild -O3 \$< -o \$@
nowar/$e-NowarWideRoundedUI-$r-$w.otd: noto/$latinvar/NotoRounded$osf-$w.otd rhr/ResourceHanRounded$r-$w.otd
mkdir -p nowar/
python merge-wideui.py $r $w $e $ver
python merge-wideui.py $r $w $e \${VERSION}
EOF

Expand All @@ -98,19 +98,19 @@ nowar/$e-NowarCompactRounded-$r-$w.ttf: nowar/$e-NowarCompactRounded-$r-$w.otd
otfccbuild -O3 \$< -o \$@
nowar/$e-NowarCompactRounded-$r-$w.otd: noto/$latinvar/NotoRounded$osf-Condensed$w.otd rhr/ResourceHanRounded$r-$w.otd
mkdir -p nowar/
python merge-compact.py $r $w $e $ver
python merge-compact.py $r $w $e \${VERSION}
nowar/$e-NowarRounded-$r-$w.ttf: nowar/$e-NowarRounded-$r-$w.otd
otfccbuild -O3 \$< -o \$@
nowar/$e-NowarRounded-$r-$w.otd: noto/$latinvar/NotoRounded$osf-SemiCondensed$w.otd rhr/ResourceHanRounded$r-$w.otd
mkdir -p nowar/
python merge-rounded.py $r $w $e $ver
python merge-rounded.py $r $w $e \${VERSION}
nowar/$e-NowarWideRounded-$r-$w.ttf: nowar/$e-NowarWideRounded-$r-$w.otd
otfccbuild -O3 \$< -o \$@
nowar/$e-NowarWideRounded-$r-$w.otd: noto/$latinvar/NotoRounded$osf-$w.otd rhr/ResourceHanRounded$r-$w.otd
mkdir -p nowar/
python merge-wide.py $r $w $e $ver
python merge-wide.py $r $w $e \${VERSION}
EOF

Expand All @@ -119,7 +119,7 @@ nowar/$e-NowarWarcraftRounded-$r-$w.ttf: nowar/$e-NowarWarcraftRounded-$r-$w.otd
otfccbuild -O3 \$< -o \$@
nowar/$e-NowarWarcraftRounded-$r-$w.otd: noto/$latinvar/NotoRounded$osf-SemiCondensed$w.otd noto/$latinvar/NotoRounded$osf-Condensed$w.otd rhr/ResourceHanRounded$r-$w.otd
mkdir -p nowar/
python merge-warcraft.py $r $w $e $ver
python merge-warcraft.py $r $w $e \${VERSION}
EOF
done
Expand Down Expand Up @@ -268,7 +268,7 @@ for w in ${nowarWeight[@]}; do
koreanDisplayFont=$(getKoreanDisplayFont $rv $w)

cat >>Makefile <<EOF
$target-$ver.7z: $target/Fonts/MORPHEUS.ttf $target/Fonts/FRIZQT__.ttf $target/Fonts/ARIALN.ttf $target/Fonts/skurri.ttf \\
$target-\${VERSION}.7z: $target/Fonts/MORPHEUS.ttf $target/Fonts/FRIZQT__.ttf $target/Fonts/ARIALN.ttf $target/Fonts/skurri.ttf \\
$target/Fonts/MORPHEUS_CYR.ttf $target/Fonts/FRIZQT___CYR.ttf $target/Fonts/SKURRI_CYR.ttf \\
$target/Fonts/ARKai_C.ttf $target/Fonts/ARKai_T.ttf $target/Fonts/ARHei.ttf \\
$target/Fonts/bKAI00M.ttf $target/Fonts/bHEI00M.ttf $target/Fonts/bHEI01B.ttf $target/Fonts/blei00d.ttf \\
Expand Down
39 changes: 39 additions & 0 deletions fontlib/merge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
def AddRef(n, font, ref):
if n in ref:
return
glyph = font['glyf'][n]
if 'references' in glyph:
for r in glyph['references']:
ref.append(r['glyph'])
AddRef(r['glyph'], font, ref)

def TrimGlyph(font):
needed = []
for (_, n) in font['cmap'].items():
needed.append(n)
ref = []
for n in needed:
AddRef(n, font, ref)

unneeded = []
for n in font['glyf']:
if not (n in needed or n in ref):
unneeded.append(n)
for n in unneeded:
del font['glyf'][n]

def CopyRef(glyph, a, b):
if 'references' in glyph:
for r in glyph['references']:
if r['glyph'] not in a['glyf']:
a['glyf'][r['glyph']] = b['glyf'][r['glyph']]
CopyRef(a['glyf'][r['glyph']], a, b)

def MergeBelow(base, ext):
for (u, n) in ext['cmap'].items():
if u not in base['cmap'].keys():
base['cmap'][u] = n
if n not in base['glyf'].keys():
glyph = ext['glyf'][n]
base['glyf'][n] = glyph
CopyRef(glyph, base, ext)
25 changes: 25 additions & 0 deletions fontlib/pkana.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import re
from fontlib.unicode import IsKana
from fontlib.transform import Transform, ChangeAdvanceWidth

def GetLookupPalt(font):
palt = []
if 'GPOS' not in font:
return palt
gpos = font['GPOS']
lookups = gpos['lookups']
for l in lookups:
if 'palt' in l:
palt.append(lookups[l])
return palt

def ProportionalizeKana(font):
for palt in GetLookupPalt(font):
for sub in palt['subtables']:
for (n, d) in sub.items():
if re.match('^uni[0-9A-F]{4,5}$', n) and IsKana(int(n[3:], 16)):
glyph = font['glyf'][n]
if 'dx' in d:
Transform(glyph, 1, 0, 0, 1, d['dx'], 0)
if 'dWidth' in d:
ChangeAdvanceWidth(glyph, d['dWidth'])
16 changes: 16 additions & 0 deletions fontlib/transform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# x' = a x + b y + dx
# y' = c x + d y + dy
def Transform(glyph, a, b, c, d, dx, dy):
glyph['advanceWidth'] *= a
if 'contours' in glyph:
for contour in glyph['contours']:
for point in contour:
point['x'] = a * point['x'] + b * point['y'] + dx
point['y'] = c * point['x'] + d * point['y'] + dy
if 'references' in glyph:
for reference in glyph['references']:
reference['x'] = a * reference['x'] + b * reference['y'] + dx
reference['y'] = c * reference['x'] + d * reference['y'] + dy

def ChangeAdvanceWidth(glyph, adv):
glyph['advanceWidth'] += adv
16 changes: 16 additions & 0 deletions fontlib/unicode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class UnicodeRange:
Hiragana = [ (0x3040, 0x309F) ]
Katakana = [ (0x30A0, 0x30FF), (0x31F0, 0x31FF) ]

def IsHiragana(ch):
if ch is str:
ch = ord(ch)
return any([b <= ch <= e for (b, e) in UnicodeRange.Hiragana ])

def IsKatakana(ch):
if ch is str:
ch = ord(ch)
return any([b <= ch <= e for (b, e) in UnicodeRange.Katakana ])

def IsKana(ch):
return IsHiragana(ch) or IsKatakana(ch)
9 changes: 4 additions & 5 deletions merge-compactui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import sys
import json

from fontlib.pkana import ProportionalizeKana
from fontlib.merge import MergeBelow

def NameFont(font, region, weight, version):

Expand Down Expand Up @@ -193,11 +195,8 @@ def NameFont(font, region, weight, version):
baseFont['OS_2']['ulCodePageRange1'][encoding] = True
NameFont(baseFont, region2, weight, version)

for (uniId, glyphName) in asianFont['cmap'].items():
if uniId not in baseFont['cmap'].keys():
baseFont['cmap'][uniId] = glyphName
if glyphName not in baseFont['glyf'].keys():
baseFont['glyf'][glyphName] = asianFont['glyf'][glyphName]
ProportionalizeKana(asianFont)
MergeBelow(baseFont, asianFont)

outStr = json.dumps(baseFont, ensure_ascii=False)
with open("nowar/{}-NowarCompactRoundedUI-{}-{}.otd".format(encoding, region, weight), 'w') as outFile:
Expand Down
9 changes: 4 additions & 5 deletions merge-wideui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import sys
import json

from fontlib.pkana import ProportionalizeKana
from fontlib.merge import MergeBelow

def NameFont(font, region, weight, version):

Expand Down Expand Up @@ -192,11 +194,8 @@ def NameFont(font, region, weight, version):
baseFont['OS_2']['ulCodePageRange1'][encoding] = True
NameFont(baseFont, region2, weight, version)

for (uniId, glyphName) in asianFont['cmap'].items():
if uniId not in baseFont['cmap'].keys():
baseFont['cmap'][uniId] = glyphName
if glyphName not in baseFont['glyf'].keys():
baseFont['glyf'][glyphName] = asianFont['glyf'][glyphName]
ProportionalizeKana(asianFont)
MergeBelow(baseFont, asianFont)

outStr = json.dumps(baseFont, ensure_ascii=False)
with open("nowar/{}-NowarWideRoundedUI-{}-{}.otd".format(encoding, region, weight), 'w') as outFile:
Expand Down

0 comments on commit 83f8fb1

Please sign in to comment.