Skip to content

Commit

Permalink
0.3.1: fix missing entries, Roboto-based font for 压缩字库
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanoHao committed Feb 5, 2019
1 parent 6037897 commit 94024de
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 4 deletions.
18 changes: 18 additions & 0 deletions build-win32.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ mkdir -p release
cd release


R=字体合并补全工具-简体中文压缩字库-$VERSION

mkdir -p $R

cp ../script-windows/link.url $R/主页-使用说明.url
cp ../script-windows/fonts.url $R/获取更多字体.url
cp ../bin-win32/{otfccbuild,otfccdump,merge-otd}.exe $R/
cp ../script-windows/comp.bat $R/补全.bat
cp ../script-windows/merge.bat $R/合并.bat
cp ../script-windows/merge+comp.bat $R/合并补全.bat
cp ../script-windows/pack-zh.bat $R/打包.bat
cp ../font/Nowar-Sans-CJK-XS-Regular.ttf $R/cjk.ttf
cp ../font/Nowar-Neo-Sans-LCG-Regular.ttf $R/latin.ttf

7z a -mx -myx -ms=on WarFontMerger-SC1-$VERSION.7z $R/
rar a -ma5 -m5 -s $R.rar $R/


R=字体合并补全工具-简体中文标准字库-$VERSION

mkdir -p $R
Expand Down
2 changes: 1 addition & 1 deletion build-win64.bash
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cp ../script-windows/merge.bat $R/合并.bat
cp ../script-windows/merge+comp.bat $R/合并补全.bat
cp ../script-windows/pack-zh.bat $R/打包.bat
cp ../font/Nowar-Sans-CJK-XS-Regular.ttf $R/cjk.ttf
cp ../font/Nowar-Sans-LCG-Medium.ttf $R/latin.ttf
cp ../font/Nowar-Neo-Sans-LCG-Regular.ttf $R/latin.ttf

7z a -mx -myx -ms=on WarFontMerger-SC1-$VERSION.7z $R/
rar a -ma5 -m5 -s $R.rar $R/
Expand Down
1 change: 1 addition & 0 deletions font-builder/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ wait
mkdir -p out

python trim-droid.py &
python trim-roboto.py Regular $ver &
python trim-noto.py Medium $ver &
python trim-shs-cn.py CN Medium gbk $ver &
python trim-shs.py SC Medium gbk $ver &
Expand Down
Binary file added font-builder/src/Roboto-Regular.ttf
Binary file not shown.
4 changes: 2 additions & 2 deletions font-builder/trim-droid.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def NameFont(font, region, weight, version):
"encodingID": 1,
"languageID": 1033,
"nameID": 13,
"nameString": "Licensed under the Apache License, Version 2.0"
"nameString": "Licensed under the Apache License, Version 2.0."
},
{
"platformID": 3,
Expand Down Expand Up @@ -142,7 +142,7 @@ def TrimGlyph(font):

if __name__ == '__main__':

with open("src/NotoSans-SemiCondensedMedium.otd", 'rb') as latinFile:
with open("src/Roboto-Regular.otd", 'rb') as latinFile:
latinFont = json.loads(latinFile.read().decode('UTF-8', errors='replace'))

# quotes, em-dash and ellipsis
Expand Down
156 changes: 156 additions & 0 deletions font-builder/trim-roboto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import json
import sys

def NameFont(font, weight, version):

isStdStyle = weight == 'Regular' or weight == 'Bold'

font['OS_2']['achVendID'] = 'Cyan'
font['name'] = [
{
"platformID": 3,
"encodingID": 1,
"languageID": 1033,
"nameID": 0,
"nameString": "Copyright © 2018—2019 Cyano Hao, with reserved font name “Nowar”, “有爱”, and “有愛”. Portions Copyright 2011 Google Inc."
},
{
"platformID": 3,
"encodingID": 1,
"languageID": 1033,
"nameID": 1,
"nameString": "Nowar Neo Sans (Latin, Кириллица and Ελληνικό)" if isStdStyle else "Nowar Neo Sans (Latin, Кириллица and Ελληνικό) " + weight
},
{
"platformID": 3,
"encodingID": 1,
"languageID": 1033,
"nameID": 2,
"nameString": weight if isStdStyle else "Regular"
},
{
"platformID": 3,
"encodingID": 1,
"languageID": 1033,
"nameID": 3,
"nameString": "Nowar Neo Sans (Latin, Кириллица and Ελληνικό) " + weight + ' ' + str(version)
},
{
"platformID": 3,
"encodingID": 1,
"languageID": 1033,
"nameID": 4,
"nameString": "Nowar Neo Sans (Latin, Кириллица and Ελληνικό) " + weight
},
{
"platformID": 3,
"encodingID": 1,
"languageID": 1033,
"nameID": 5,
"nameString": str(version)
},
{
"platformID": 3,
"encodingID": 1,
"languageID": 1033,
"nameID": 6,
"nameString": "Nowar-Neo-Sans-LCG-" + weight.replace(' ', '-')
},
{
"platformID": 3,
"encodingID": 1,
"languageID": 1033,
"nameID": 8,
"nameString": "Cyano Hao"
},
{
"platformID": 3,
"encodingID": 1,
"languageID": 1033,
"nameID": 9,
"nameString": "Christian Robertson"
},
{
"platformID": 3,
"encodingID": 1,
"languageID": 1033,
"nameID": 11,
"nameString": "https://github.com/CyanoHao"
},
{
"platformID": 3,
"encodingID": 1,
"languageID": 1033,
"nameID": 13,
"nameString": "Licensed under the Apache License, Version 2.0."
},
{
"platformID": 3,
"encodingID": 1,
"languageID": 1033,
"nameID": 14,
"nameString": "http://www.apache.org/licenses/LICENSE-2.0"
},
{
"platformID": 3,
"encodingID": 1,
"languageID": 1033,
"nameID": 16,
"nameString": "Nowar Neo Sans (Latin, Кириллица and Ελληνικό)"
},
{
"platformID": 3,
"encodingID": 1,
"languageID": 1033,
"nameID": 17,
"nameString": weight
},
]

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 = [ font['glyph_order'][0] ]
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]

if __name__ == '__main__':
weight = sys.argv[1]
version = sys.argv[2]

with open("src/Roboto-{}.otd".format(weight), 'rb') as baseFile:
baseFont = json.loads(baseFile.read().decode('UTF-8', errors='replace'))

NameFont(baseFont, weight, version)

# quotes, em-dash and ellipsis
for u in [0x2014, 0x2018, 0x2019, 0x201C, 0x201D, 0x2026]:
if str(u) in baseFont['cmap']:
del baseFont['cmap'][str(u)]

del baseFont['GSUB']
del baseFont['GPOS']
del baseFont['GDEF']
TrimGlyph(baseFont)

outStr = json.dumps(baseFont, ensure_ascii=False)
with open("out/Nowar-Neo-Sans-LCG-{}.otd".format(weight), 'w') as outFile:
outFile.write(outStr)
Binary file added font/Nowar-Neo-Sans-LCG-Regular.ttf
Binary file not shown.
Binary file modified font/Nowar-Sans-CJK-CL-Medium.ttf
Binary file not shown.
Binary file modified font/Nowar-Sans-CJK-CN-Medium.ttf
Binary file not shown.
Binary file modified font/Nowar-Sans-CJK-SC-Medium.ttf
Binary file not shown.
Binary file modified font/Nowar-Sans-CJK-TC-Medium.ttf
Binary file not shown.
Binary file modified font/Nowar-Sans-CJK-XS-Regular.ttf
Binary file not shown.
Binary file modified font/Nowar-Sans-LCG-Medium.ttf
Binary file not shown.
18 changes: 18 additions & 0 deletions src/merge-name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,5 +463,23 @@ json MergeNameTable(const vector<json> &nametables) {
}
}

if (GetNameEntry(result, NameId::LicenseDescription) == "")
result.push_back({
{"platformID", Platform::Windows},
{"encodingID", Encoding::Unicode},
{"languageID", Language::en_US},
{"nameID", NameId::LicenseDescription},
{"nameString", license},
});

if (GetNameEntry(result, NameId::Copyright) == "")
result.push_back({
{"platformID", Platform::Windows},
{"encodingID", Encoding::Unicode},
{"languageID", Language::en_US},
{"nameID", NameId::Copyright},
{"nameString", copyright},
});

return result;
}
2 changes: 1 addition & 1 deletion version.bash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=0.3.0
VERSION=0.3.1

0 comments on commit 94024de

Please sign in to comment.