Skip to content

Commit

Permalink
remove SharedMedia font provider
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanoHao committed May 12, 2020
1 parent 0464e05 commit efe9405
Showing 1 changed file with 1 addition and 122 deletions.
123 changes: 1 addition & 122 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,52 +27,6 @@ class Config:
("GB", [ "RP" ]),
]

fontProviderWeight = [ 300, 400, 500, 700 ]
fontProviderWidth = [ 3, 5 ]
fontProviderInstance = {
# seperate western to 2 parts, avoid sed argument strips
"western1": [ Namespace(
weight = w,
width = wd,
family = "UI",
region = r[0] if type(r) == tuple else r,
feature = r[1] if type(r) == tuple else [],
encoding = "unspec"
) for w, wd, r in product(fontProviderWeight, fontProviderWidth, [ "CN", "TW", "HK", "JP" ]) ],
"western2": [ Namespace(
weight = w,
width = wd,
family = "UI",
region = r[0] if type(r) == tuple else r,
feature = r[1] if type(r) == tuple else [],
encoding = "unspec"
) for w, wd, r in product(fontProviderWeight, fontProviderWidth, [ "CL", ("CL", [ "OSF" ]), ("CL", [ "SC" ]), ("CL", [ "OSF", "SC" ]) ]) ],
"zhCN": [ Namespace(
weight = w,
width = wd,
family = "Sans",
region = r[0] if type(r) == tuple else r,
feature = r[1] if type(r) == tuple else [],
encoding = "unspec"
) for w, wd, r in product(fontProviderWeight, fontProviderWidth, [ "CN", "CL" ]) ],
"zhTW": [ Namespace(
weight = w,
width = wd,
family = "Sans",
region = r[0] if type(r) == tuple else r,
feature = r[1] if type(r) == tuple else [],
encoding = "unspec"
) for w, wd, r in product(fontProviderWeight, fontProviderWidth, [ "TW", "HK", "CL" ]) ],
"koKR": [ Namespace(
weight = w,
width = wd,
family = "UI",
region = r[0] if type(r) == tuple else r,
feature = r[1] if type(r) == tuple else [],
encoding = "unspec"
) for w, wd, r in product(fontProviderWeight, fontProviderWidth, [ "KR" ]) ],
}

config = Config()

weightMap = {
Expand Down Expand Up @@ -524,12 +478,11 @@ def ParamToArgument(conf):
"depend": [ "all" ],
},
"all": {
"depend": [ "out/SharedMedia-NowarNeoSans-${VERSION}.7z" ],
"depend": [],
},
"clean": {
"command": [
"-rm -rf build/",
"-rm -rf out/NowarNeoSansTypeface/",
"-rm -rf out/??*-???/",
]
}
Expand All @@ -539,80 +492,6 @@ def ParamToArgument(conf):
unique = lambda l: reduce(lambda l, x: l + [ x ] if x not in l else l, l, [])
powerset = lambda lst: reduce(lambda result, x: result + [subset + [x] for subset in result], lst, [[]])

# SharedMedia font provider
makefile["rule"]["out/SharedMedia-NowarNeoSans-${VERSION}.7z"] = {
"depend": [ "build/nowar/{}.otf".format(GenerateFilename(p)) for p in sum(config.fontProviderInstance.values(), []) ],
"command": [
# copy inferface directory
"mkdir -p out/",
"cp -r source/libsm out/NowarNeoSansTypeface",
"cp LICENSE.txt out/NowarNeoSansTypeface/",
"mkdir -p out/NowarNeoSansTypeface/Fonts/",
# replace dummy strings
"sed -i 's/__REPLACE_IN_BUILD__VERSION__/${VERSION}/' out/NowarNeoSansTypeface/NowarNeoSansTypeface.toc",
"sed -i '/__REPLACE_IN_BUILD__REGISTER_WESTERN1__/{{s/__REPLACE_IN_BUILD__REGISTER_WESTERN1__/{}/}}' out/NowarNeoSansTypeface/NowarNeoSansTypeface.lua".format(
"\\n".join(
[
r'NowarNeoSansTypeface:Register("font", "{}", [[Interface\\Addons\\NowarNeoSansTypeface\\Fonts\\{}.otf]], western + ruRU)'.format(
GenerateFriendlyFamily(p)[0x0409],
GenerateFilename(p).replace("unspec-", "")
) for p in config.fontProviderInstance["western1"]
]
)
),
"sed -i '/__REPLACE_IN_BUILD__REGISTER_WESTERN2__/{{s/__REPLACE_IN_BUILD__REGISTER_WESTERN2__/{}/}}' out/NowarNeoSansTypeface/NowarNeoSansTypeface.lua".format(
"\\n".join(
[
r'NowarNeoSansTypeface:Register("font", "{}", [[Interface\\Addons\\NowarNeoSansTypeface\\Fonts\\{}.otf]], western + ruRU)'.format(
GenerateFriendlyFamily(p)[0x0409],
GenerateFilename(p).replace("unspec-", "")
) for p in config.fontProviderInstance["western2"]
]
)
),
"sed -i '/__REPLACE_IN_BUILD__REGISTER_ZHCN__/{{s/__REPLACE_IN_BUILD__REGISTER_ZHCN__/{}/}}' out/NowarNeoSansTypeface/NowarNeoSansTypeface.lua".format(
"\\n".join(
[
r'NowarNeoSansTypeface:Register("font", "{}", [[Interface\\Addons\\NowarNeoSansTypeface\\Fonts\\{}.otf]], zhCN)'.format(
GenerateFriendlyFamily(p)[0x0804],
GenerateFilename(p).replace("unspec-", "")
) for p in config.fontProviderInstance["zhCN"]
]
)
),
"sed -i '/__REPLACE_IN_BUILD__REGISTER_ZHTW__/{{s/__REPLACE_IN_BUILD__REGISTER_ZHTW__/{}/}}' out/NowarNeoSansTypeface/NowarNeoSansTypeface.lua".format(
"\\n".join(
[
r'NowarNeoSansTypeface:Register("font", "{}", [[Interface\\Addons\\NowarNeoSansTypeface\\Fonts\\{}.otf]], zhTW)'.format(
GenerateFriendlyFamily(p)[0x0404],
GenerateFilename(p).replace("unspec-", "")
) for p in config.fontProviderInstance["zhTW"]
]
)
),
"sed -i '/__REPLACE_IN_BUILD__REGISTER_KOKR__/{{s/__REPLACE_IN_BUILD__REGISTER_KOKR__/{}/}}' out/NowarNeoSansTypeface/NowarNeoSansTypeface.lua".format(
"\\n".join(
[
r'NowarNeoSansTypeface:Register("font", "{}", [[Interface\\Addons\\NowarNeoSansTypeface\\Fonts\\{}.otf]], koKR)'.format(
GenerateFriendlyFamily(p)[0x0412],
GenerateFilename(p).replace("unspec-", "")
) for p in config.fontProviderInstance["koKR"]
]
)
),
# copy font files
"for file in $^; do cp $$file out/NowarNeoSansTypeface/Fonts/$${file#build/nowar/*-}; done",
# pack with 7z, group them by weight to generate smaller file in less time
"cd out/; 7z a -t7z -m0=LZMA:d=512m:fb=273 -ms ../$@ NowarNeoSansTypeface/ -x!NowarNeoSansTypeface/Fonts/\\*.otf",
] + [
"cd out/; 7z a -t7z -m0=LZMA:d=512m:fb=273 -ms ../$@ " + " ".join([
"NowarNeoSansTypeface/Fonts/{}.otf".format(GenerateFilename(p).replace("unspec-", ""))
for p in unique(sum(config.fontProviderInstance.values(), []))
if p.weight == w
]) for w in config.fontProviderWeight
]
}

# font pack for each regional variant and weight
for r, w, fea in product(config.fontPackRegion, config.fontPackWeight, powerset(config.fontPackFeature)):
tagList = [ r ] + fea
Expand Down

0 comments on commit efe9405

Please sign in to comment.