diff --git a/README-SC.md b/README-SC.md index 66eb121..365ef24 100644 --- a/README-SC.md +++ b/README-SC.md @@ -1,17 +1,14 @@ [繁體中文](../../) **简体中文** -# Bright Moon Kai 皓月楷 & Array Stars Kai 繁星楷 +# Moon Stars Kai 月星楷 一款由 [Klee](https://github.com/fontworks-fonts/Klee) 衍生旧字形或古体字形风格的中文字体。 -## Bright Moon Kai 皓月楷 -在[霞鹜文楷 TC](https://github.com/lxgw/LxgwWenkaiTC)的基础上,结合[霞鹜文楷](https://github.com/lxgw/LxgwWenKai)以及 [Klee](https://github.com/fontworks-fonts/Klee)字形,参照《洪武正韵》(明嘉靖四十年刘以节刊本)制作。部分字形在*现代书写中已经很少见*,但可常见于书法字贴。 +## Moon Stars Kai 月星楷 +在 [Klee One](https://github.com/fontworks-fonts/Klee) 的基础上,结合[霞鹜文楷 TC](https://github.com/lxgw/LxgwWenkaiTC)、[霞鹜文楷](https://github.com/lxgw/LxgwWenKai)以及[芫荽](https://github.com/ButTaiwan/iansui)字形,参照《洪武正韵》(明嘉靖四十年刘以节刊本)制作。部分字形在*现代书写中已经很少见*,但可常见于书法字贴。 ![image](./pictures/picture001.png) -## Array Stars Kai 繁星楷 -由皓月楷修改,简入繁出的字体。此字体使用了 OpenType 功能,可根据文本内容动态匹配一简多繁的情况。 - -## CL 版本 -传承字形版。此版本与[霞鹜文楷 TC](https://github.com/lxgw/LxgwWenkaiTC) 字形接近。 +## Moon Stars Kai T 月星楷 繁 +由月星楷修改,简入繁出的字体。此字体使用了 OpenType 功能,可根据文本内容动态匹配一简多繁的情况。 ## 下载字体 可从本站 [Releases](../../releases) 页面下载字体。 @@ -20,9 +17,11 @@ 遵循 [SIL Open Font License 1.1](./LICENSE.txt)。 ## 鸣谢 -* [霞鹜文楷 TC](https://github.com/lxgw/LxgwWenkaiTC)、[霞鹜文楷](https://github.com/lxgw/LxgwWenKai) * [Klee](https://github.com/fontworks-fonts/Klee) +* [霞鹜文楷 TC](https://github.com/lxgw/LxgwWenkaiTC)、[霞鹜文楷](https://github.com/lxgw/LxgwWenKai) * [芫荽](https://github.com/ButTaiwan/iansui) * [FontForge](https://github.com/fontforge/fontforge) +* [otfcc](https://github.com/caryll/otfcc) * [FontTools](https://github.com/fonttools/fonttools) * [AFDKO](https://github.com/adobe-type-tools/afdko/) +* [OpenCC](https://github.com/BYVoid/OpenCC) diff --git a/README.md b/README.md index 4550b39..1f1dfa5 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,14 @@ **繁體中文** [简体中文](README-SC.md) -# Bright Moon Kai 皓月楷 & Array Stars Kai 繁星楷 +# Moon Stars Kai 月星楷 一款由 [Klee](https://github.com/fontworks-fonts/Klee) 衍生舊字形或古體字形風格的中文字型。 -## Bright Moon Kai 皓月楷 -在[霞鶩文楷 TC](https://github.com/lxgw/LxgwWenkaiTC)的基礎上,結合[霞鶩文楷](https://github.com/lxgw/LxgwWenKai)以及 [Klee](https://github.com/fontworks-fonts/Klee)字形,參照《洪武正韻》(明嘉靖四十年劉以節刊本)製作。部分字形在*現代書寫中已經很少見*,但可常見於書法字貼。 +## Moon Stars Kai 月星楷 +在 [Klee](https://github.com/fontworks-fonts/Klee) 的基礎上,結合[霞鶩文楷 TC](https://github.com/lxgw/LxgwWenkaiTC)、[霞鶩文楷](https://github.com/lxgw/LxgwWenKai)以及[芫荽](https://github.com/ButTaiwan/iansui)字形,參照《洪武正韻》(明嘉靖四十年劉以節刊本)製作。部分字形在*現代書寫中已經很少見*,但可常見於書法字貼。 ![image](./pictures/picture001.png) -## Array Stars Kai 繁星楷 -由皓月楷修改,簡入繁出的字型。此字型使用了 OpenType 功能,可根據文字内容動態匹配一簡多繁的情況。 - -## CL 版本 -傳承字形版。此版本與[霞鶩文楷 TC](https://github.com/lxgw/LxgwWenkaiTC) 字形接近。 +## Moon Stars Kai T 月星楷 繁 +由月星楷修改,簡入繁出的字型。此字型使用了 OpenType 功能,可根據文字内容動態匹配一簡多繁的情況。 ## 下載字型 可從本站 [Releases](../../releases) 頁面下載字型。 @@ -20,9 +17,11 @@ 遵循 [SIL Open Font License 1.1](./LICENSE.txt)。 ## 鳴謝 -* [霞鶩文楷 TC](https://github.com/lxgw/LxgwWenkaiTC)、[霞鶩文楷](https://github.com/lxgw/LxgwWenKai) * [Klee](https://github.com/fontworks-fonts/Klee) +* [霞鶩文楷 TC](https://github.com/lxgw/LxgwWenkaiTC)、[霞鶩文楷](https://github.com/lxgw/LxgwWenKai) * [芫荽](https://github.com/ButTaiwan/iansui) * [FontForge](https://github.com/fontforge/fontforge) +* [otfcc](https://github.com/caryll/otfcc) * [FontTools](https://github.com/fonttools/fonttools) * [AFDKO](https://github.com/adobe-type-tools/afdko/) +* [OpenCC](https://github.com/BYVoid/OpenCC) diff --git a/pictures/picture001.png b/pictures/picture001.png index fe20600..16cf70f 100644 Binary files a/pictures/picture001.png and b/pictures/picture001.png differ diff --git a/sources/sp04buildfinal.py b/sources/build.py similarity index 56% rename from sources/sp04buildfinal.py rename to sources/build.py index 9ae51f5..a564865 100644 --- a/sources/sp04buildfinal.py +++ b/sources/build.py @@ -2,31 +2,45 @@ from fontTools.ttLib import TTFont, newTable from fontTools.ttLib.tables import otTables -ftversion='1.07' +ftversion='1.100' +fthyen='Moon Stars Kai' +fthytc='月星楷' +fthysc='月星楷' +ftfxen='Moon Stars Kai T' +ftfxtc='月星楷 繁' +ftfxsc='月星楷 繁' + +comid='GUIW' +fturl='https://github.com/GuiWonder/MoonStarsKai' + hy=dict() -hy['en']='Bright Moon Kai' -hy['tc']='皓月楷' -hy['sc']='皓月楷' +hy['en']=fthyen +hy['tc']=fthytc +hy['sc']=fthysc hy['vs']=ftversion fx=dict() -fx['en']='Array Stars Kai' -fx['tc']='繁星楷' -fx['sc']='繁星楷' +fx['en']=ftfxen +fx['tc']=ftfxtc +fx['sc']=ftfxsc fx['vs']=ftversion -iscl=False -if len(sys.argv)>3 and sys.argv[3].lower()=='cl': - iscl=True - -if iscl: - hy['en']+=' CL' - fx['en']+=' CL' - for nmtg in ['tc', 'sc']: - hy[nmtg]+='CL' - fx[nmtg]+='CL' - pydir=os.path.abspath(os.path.dirname(__file__)) +def prouv(font, ispr): + cmap=font.getBestCmap() + for table in font["cmap"].tables: + if table.format==14: + for vsl in table.uvsDict.keys(): + newl=list() + for cg in table.uvsDict[vsl]: + if cg[1]==None and ispr: + newl.append((cg[0], cmap[cg[0]])) + elif cg[0] in cmap and cg[1]==cmap[cg[0]] and not ispr: + newl.append((cg[0], None)) + else: + newl.append((cg[0], cg[1])) + table.uvsDict[vsl]=newl + def glyrepl(font, repdic): for table in font["cmap"].tables: for cd in table.cmap: @@ -66,6 +80,11 @@ def rmft(font, tbnm, i): elif j-1 - bkcov=dics[0:i] - bkcov.reverse() - lahcov=dics[i+1:] - if sg!=tg and tg not in ltc: - if sg not in sgtb1: - sgtb1[sg]=tg - ltc[tg]=2 - elif sg not in sgtb2: - sgtb2[sg]=tg - ltc[tg]=3 - elif sg not in sgtb3: - sgtb3[sg]=tg - ltc[tg]=4 - else: - raise - bklst=list() - for strs in bkcov: - cvobjbk=otTables.Coverage() - cvobjbk.glyphs=list(set([cmap[ord(ch)] for ch in strs if ord(ch) in cmap])) - assert len(cvobjbk.glyphs)>0, strs - cvobjbk.glyphs=list(sorted([g for g in cvobjbk.glyphs], key=lambda g:glod.index(g))) - bklst.append(cvobjbk) - ahlst=list() - for strs in lahcov: - cvobjah=otTables.Coverage() - cvobjah.glyphs=list(set([cmap[ord(ch)] for ch in strs if ord(ch) in cmap])) - assert len(cvobjah.glyphs)>0, strs - cvobjah.glyphs=list(sorted([g for g in cvobjah.glyphs], key=lambda g:glod.index(g))) - ahlst.append(cvobjah) - cvobjip=otTables.Coverage() - cvobjip.glyphs=[cmap[ord(s)]] - mulsb=otTables.ChainContextSubst() - mulsb.Format=3 - mulsb.BacktrackCoverage=bklst - mulsb.InputCoverage=[cvobjip] - mulsb.LookAheadCoverage=ahlst - if sg!=tg: - sblrd=otTables.SubstLookupRecord() - sblrd.SequenceIndex=0 - sblrd.LookupListIndex=ltc[tg] - mulsb.SubstLookupRecord=[sblrd] - stmul.SubTable.append(mulsb) + + ltc=dict() + for phdc in phrdic: + s, t=phdc['s'], phdc['t'] + dics=phdc['p'] + sg=cmap[ord(s)] + tg=cmap[ord(t)] + i=dics.index(s) + assert i>-1 + bkcov=dics[0:i] + bkcov.reverse() + lahcov=dics[i+1:] + if sg!=tg and tg not in ltc: + if sg not in sgtb1: + sgtb1[sg]=tg + ltc[tg]=2 + elif sg not in sgtb2: + sgtb2[sg]=tg + ltc[tg]=3 + elif sg not in sgtb3: + sgtb3[sg]=tg + ltc[tg]=4 + else: + raise + bklst=list() + for strs in bkcov: + cvobjbk=otTables.Coverage() + cvobjbk.glyphs=list(set([cmap[ord(ch)] for ch in strs if ord(ch) in cmap])) + assert len(cvobjbk.glyphs)>0, strs + cvobjbk.glyphs=list(sorted([g for g in cvobjbk.glyphs], key=lambda g:glod.index(g))) + bklst.append(cvobjbk) + ahlst=list() + for strs in lahcov: + cvobjah=otTables.Coverage() + cvobjah.glyphs=list(set([cmap[ord(ch)] for ch in strs if ord(ch) in cmap])) + assert len(cvobjah.glyphs)>0, strs + cvobjah.glyphs=list(sorted([g for g in cvobjah.glyphs], key=lambda g:glod.index(g))) + ahlst.append(cvobjah) + cvobjip=otTables.Coverage() + cvobjip.glyphs=[cmap[ord(s)]] + mulsb=otTables.ChainContextSubst() + mulsb.Format=3 + mulsb.BacktrackCoverage=bklst + mulsb.InputCoverage=[cvobjip] + mulsb.LookAheadCoverage=ahlst + if sg!=tg: + sblrd=otTables.SubstLookupRecord() + sblrd.SequenceIndex=0 + sblrd.LookupListIndex=ltc[tg] + mulsb.SubstLookupRecord=[sblrd] + stmul.SubTable.append(mulsb) sgsb1.mapping=sgtb1 sgsb2.mapping=sgtb2 sgsb3.mapping=sgtb3 - with open(os.path.join(pydir, 'stoneo.dt'),'r',encoding='utf-8') as f: - for line in f.readlines(): - litm=line.split('#')[0].strip() - if '-' not in litm: continue - s, t=litm.split(' ')[0].split('-') - s, t=s.strip(), t.strip() - if s and t and s!=t and ord(s) in cmap and ord(t) in cmap and cmap[ord(s)]!=cmap[ord(t)]: - sgtb[cmap[ord(s)]]=cmap[ord(t)] + for s, t in list(chrdic.items()): + if ord(s) in cmap and ord(t) in cmap and cmap[ord(s)]!=cmap[ord(t)]: + sgtb[cmap[ord(s)]]=cmap[ord(t)] sgsb.mapping=sgtb for lkp in font["GSUB"].table.LookupList.Lookup: for st in lkp.SubTable: @@ -195,26 +221,45 @@ def stlks(font): for lsr in sr.Script.LangSysRecord: lsr.LangSys.FeatureIndex=[i+1 for i in lsr.LangSys.FeatureIndex] lsr.LangSys.FeatureIndex.insert(0, 0) -def stcmp(font): +def stcmp(font, chrdic): cmap=font.getBestCmap() + for s, t in list(chrdic.items()): + if ord(s) not in cmap and ord(t) in cmap: + setcg(font['cmap'].tables, ord(s), cmap[ord(t)]) +def getstdic(): + newdic=dict() with open(os.path.join(pydir, 'stoneo.dt'),'r',encoding='utf-8') as f: for line in f.readlines(): litm=line.split('#')[0].strip() if '-' not in litm: continue s, t=litm.split(' ')[0].split('-') s, t=s.strip(), t.strip() - if s and t and s!=t and ord(s) not in cmap and ord(t) in cmap: - setcg(font['cmap'].tables, ord(s), cmap[ord(t)]) + if s and t and s!=t: + newdic[s]=t + for s, t in list(newdic.items()): + if t in newdic: newdic[s]=newdic[t] + newlst=list() + with open(os.path.join(pydir, 'stonem.dt'),'r',encoding='utf-8') as f: + for line in f.readlines(): + litm=line.split('#')[0].strip() + if '-' not in litm: continue + dic1=dict() + ls=litm.strip().split(' ') + s, t=ls[0].split('-') + dic1['s'], dic1['t']=s, t + dic1['p']=ls[1:] + newlst.append(dic1) + return newdic, newlst -def setname(names, wt, ismono=False): +def setname(names, wt, ishw=False): fmlName=names['en'] scn=names['tc'] tcn=names['sc'] version=names['vs'] - if ismono: - fmlName+=' Mono' - scn+='等宽' - tcn+='等寬' + if ishw: + fmlName+=' HW' + scn+=' 半宽' + tcn+=' 半寬' ftName=fmlName ftNamesc=scn ftNametc=tcn @@ -226,7 +271,7 @@ def setname(names, wt, ismono=False): if wt=='Bold': subfamily='Bold' psName=fmlName.replace(' ', '')+'-'+wt - uniqID=version+';'+'GWF'+';'+psName + uniqID=version+';'+comid.strip()+';'+psName #if wt=='Bold': if wt in ('Regular', 'Bold'): fullName=ftName+' '+wt @@ -237,7 +282,7 @@ def setname(names, wt, ismono=False): fullNamesc=ftNamesc fullNametc=ftNametc newnane=newTable('name') - newnane.setName('Copyright 2023-2024 '+names['en'], 0, 3, 1, 1033) + newnane.setName(f'Copyright 2023-2024 {names["en"]} Project Authors ({fturl})', 0, 3, 1, 1033) newnane.setName(ftName, 1, 3, 1, 1033) newnane.setName(subfamily, 2, 3, 1, 1033) newnane.setName(uniqID, 3, 3, 1, 1033) @@ -246,7 +291,7 @@ def setname(names, wt, ismono=False): newnane.setName(psName, 6, 3, 1, 1033) newnane.setName('GuiWonder', 9, 3, 1, 1033) #newnane.setName(cfg['fontDiscript'], 10, 3, 1, 1033) - newnane.setName('https://github.com/GuiWonder/MoonStarsKai', 11, 3, 1, 1033) + newnane.setName(fturl, 11, 3, 1, 1033) newnane.setName('This Font Software is licensed under the SIL Open Font License, Version 1.1. This license is available with a FAQ at: https://scripts.sil.org/OFL', 13, 3, 1, 1033) newnane.setName('https://scripts.sil.org/OFL', 14, 3, 1, 1033) if wt not in ('Regular', 'Bold'): @@ -269,40 +314,41 @@ def setname(names, wt, ismono=False): return newnane def setrbbb(font, stylename): - assert stylename in {"regular", "bold", "italic", "bold italic", 'other'} - if stylename == "bold": - font["head"].macStyle = 0b01 - elif stylename == "bold italic": - font["head"].macStyle = 0b11 - elif stylename == "italic": - font["head"].macStyle = 0b10 - else: - font["head"].macStyle = 0b00 - selection = font["OS/2"].fsSelection - # First clear... - selection &= ~(1 << 0) - selection &= ~(1 << 5) - selection &= ~(1 << 6) - # ...then re-set the bits. - if stylename == "regular": - selection |= 1 << 6 - elif stylename == "bold": - selection |= 1 << 5 - elif stylename == "italic": - selection |= 1 << 0 - elif stylename == "bold italic": - selection |= 1 << 0 - selection |= 1 << 5 - font["OS/2"].fsSelection = selection + assert stylename in {"regular", "bold", "italic", "bold italic", 'other'} + if stylename == "bold": + font["head"].macStyle = 0b01 + elif stylename == "bold italic": + font["head"].macStyle = 0b11 + elif stylename == "italic": + font["head"].macStyle = 0b10 + else: + font["head"].macStyle = 0b00 + selection = font["OS/2"].fsSelection + # First clear... + selection &= ~(1 << 0) + selection &= ~(1 << 5) + selection &= ~(1 << 6) + # ...then re-set the bits. + if stylename == "regular": + selection |= 1 << 6 + elif stylename == "bold": + selection |= 1 << 5 + elif stylename == "italic": + selection |= 1 << 0 + elif stylename == "bold italic": + selection |= 1 << 0 + selection |= 1 << 5 + font["OS/2"].fsSelection = selection def saveft(font, mono=False): newtf=TTFont(infile) + newtf['vmtx']['.null']=(0, 0) if mono: newtf['OS/2'].panose.bProportion=9 newtf['OS/2'].xAvgCharWidth=500 newtf['head'].fontRevision=float(ftversion) - newtf['OS/2'].achVendID='GWF ' - for tb in ('name', 'cmap', 'GSUB'): + newtf['OS/2'].achVendID=comid + for tb in ('name', 'cmap', 'GSUB', 'GPOS'): newtf[tb]=font[tb] if weight.lower()=='bold': newtf['OS/2'].usWeightClass=700 @@ -327,19 +373,26 @@ def saveft(font, mono=False): infont['name']=setname(hy, weight) saveft(infont) +prouv(infont, True) hwcmp(infont) infont['name']=setname(hy, weight, True) +prouv(infont, False) saveft(infont, True) infont=TTFont(infile) infont['cmap'].tables=[table for table in infont['cmap'].tables if table.format!=0] -stcmp(infont) -stlks(infont) +prouv(infont, True) +chrdic, phrdic=getstdic() +stcmp(infont, chrdic) +stlks(infont, chrdic, phrdic) infont['name']=setname(fx, weight) +prouv(infont, False) saveft(infont) +prouv(infont, True) hwcmp(infont) infont['name']=setname(fx, weight, True) +prouv(infont, False) saveft(infont, True) diff --git a/sources/fwid.txt b/sources/fwid.txt deleted file mode 100644 index 3ad26af..0000000 --- a/sources/fwid.txt +++ /dev/null @@ -1,98 +0,0 @@ -   -    -! ! -# # -$ $ -% % -& & -( ( -) ) -* * -+ + -- - -/ / -0 0 -1 1 -2 2 -3 3 -4 4 -5 5 -6 6 -7 7 -8 8 -9 9 -: : -; ; -< < -= = -> > -? ? -@ @ -A A -B B -C C -D D -E E -F F -G G -H H -I I -J J -K K -L L -M M -N N -O O -P P -Q Q -R R -S S -T T -U U -V V -W W -X X -Y Y -Z Z -[ [ -\ \ -] ] -^ ^ -_ _ -` ` -a a -b b -c c -d d -e e -f f -g g -h h -i i -j j -k k -l l -m m -n n -o o -p p -q q -r r -s s -t t -u u -v v -w w -x x -y y -z z -{ { -| | -} } -~ ~ -¥ ¥ -₩ ₩ -" " -' ' -    -│ | diff --git a/sources/sp01buildttc.py b/sources/sp01buildttc.py deleted file mode 100644 index f60a03a..0000000 --- a/sources/sp01buildttc.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys -import fontforge - -print('Processing...') -fonts=list() -for fontfile in sys.argv[2:]: - font=fontforge.open(fontfile) - fonts.append(font) -print('Generating TTC...') -fonts[0].generateTtc(sys.argv[1], fonts[1:], ttcflags = ("merge"), layer = 1) -print('Finished!') diff --git a/sources/sp02buildttf.py b/sources/sp02buildttf.py deleted file mode 100644 index 1b338d2..0000000 --- a/sources/sp02buildttf.py +++ /dev/null @@ -1,157 +0,0 @@ -import sys, os -from fontTools.ttLib import TTFont, newTable -from fontTools.ttLib.tables import otTables - -def setcg(code, glyf): - for table in font["cmap"].tables: - if (table.format==4 and code<=0xFFFF) or table.format==12 or (table.format==6 and code<=0xFF) or code in table.cmap: - table.cmap[code]=glyf -def addlk(lktg, sgtb): - stsig=otTables.Lookup() - stsig.LookupType=1 - stsig.LookupFlag=0 - sgsb=otTables.SingleSubst() - stsig.SubTable=[sgsb] - sgsb.mapping=sgtb - for lkp in font["GSUB"].table.LookupList.Lookup: - for st in lkp.SubTable: - if st.LookupType in (5, 6) and hasattr(st, 'SubstLookupRecord'): - for sbrcd in st.SubstLookupRecord: - sbrcd.LookupListIndex+=1 - for ft in font["GSUB"].table.FeatureList.FeatureRecord: - ft.Feature.LookupListIndex=[i+1 for i in ft.Feature.LookupListIndex] - font["GSUB"].table.LookupList.Lookup.insert(0, stsig) - stft=otTables.FeatureRecord() - stft.Feature=otTables.Feature() - stft.FeatureTag=lktg - stft.Feature.LookupListIndex=[0, ] - font["GSUB"].table.FeatureList.FeatureRecord.insert(0, stft) - for sr in font["GSUB"].table.ScriptList.ScriptRecord: - sr.Script.DefaultLangSys.FeatureIndex=[i+1 for i in sr.Script.DefaultLangSys.FeatureIndex] - sr.Script.DefaultLangSys.FeatureIndex.insert(0, 0) - for lsr in sr.Script.LangSysRecord: - lsr.LangSys.FeatureIndex=[i+1 for i in lsr.LangSys.FeatureIndex] - lsr.LangSys.FeatureIndex.insert(0, 0) -def mergelk(): - mgl=dict() - mgl2=dict() - for i in range(len(font["GSUB"].table.LookupList.Lookup)): - tp=font["GSUB"].table.LookupList.Lookup[i].SubTable[0].LookupType - if tp not in mgl:mgl[tp]=list() - mgl[tp].append(i) - for i in range(len(fontmn["GSUB"].table.LookupList.Lookup)): - tp=fontmn["GSUB"].table.LookupList.Lookup[i].SubTable[0].LookupType - if tp not in mgl2:mgl2[tp]=list() - mgl2[tp].append(i) - - for tp in mgl: - assert len(mgl[tp])==len(mgl2[tp]) - for i in range(len(mgl[tp])): - i1, i2=mgl[tp][i], mgl2[tp][i] - lk1=font["GSUB"].table.LookupList.Lookup[i1] - lk2=fontmn["GSUB"].table.LookupList.Lookup[i2] - for j in range(len(lk1.SubTable)): - st1=lk1.SubTable[j] - st2=lk2.SubTable[j] - print(i1, i2, j) - assert st1.LookupType==st2.LookupType - if st1.LookupType==1: - tabl1=st1.mapping - tabl2=st2.mapping - for g1, g2 in list(tabl2.items()): - if g1 not in tabl1: - tabl1[g1]=g2 - elif st1.LookupType==4: - lg1=st1.ligatures - lg2=st2.ligatures - for g1 in lg2: - if g1 not in lg1: - lg1[g1]=lg2[g1] - else: - if lg1[g1]!=lg2[g1]: - for lgi1 in lg2[g1]: - if lgi1 not in lg1[g1]: - lg1[g1].append(lgi1) - elif st1.LookupType==6: - lk1.SubTable.append(st2) - else: - raise - -def rmlogo(fontlx): - for table in fontlx["cmap"].tables: - if 0xFFFFD in table.cmap: del table.cmap[0xFFFFD] - -def rmlklg(fontlx): - for ki in font["GSUB"].table.LookupList.Lookup: - for st in ki.SubTable: - if st.LookupType==7: - stbl=st.ExtSubTable - else: - stbl=st - lktp=stbl.LookupType - if lktp==4: - for li in list(stbl.ligatures): - for lg in list(stbl.ligatures[li]): - if lg.LigGlyph in ('uFFFFD', 'uFFFFD#1'): - stbl.ligatures[li].remove(lg) - if len(stbl.ligatures[li])<1: - del stbl.ligatures[li] - -def dftlk(font): - dfllan=list() - for sr in font['GSUB'].table.ScriptList.ScriptRecord: - if sr.ScriptTag=='DFLT': - dfllan=sr.Script.DefaultLangSys.FeatureIndex - break - for lsr in sr.Script.LangSysRecord: - print('locl', lsr.LangSys.FeatureIndex) - raise - assert len(dfllan)>0 - for sr in font['GSUB'].table.ScriptList.ScriptRecord: - if sr.ScriptTag!='DFLT': - sr.Script.DefaultLangSys.FeatureIndex=dfllan - -inft=sys.argv[1] -outft=sys.argv[2] -font=TTFont(inft, fontNumber=0) -fontmn=TTFont(inft, fontNumber=1) -rmlogo(font) -rmlogo(fontmn) -mergelk() -cmap=font.getBestCmap() -cmapmn=fontmn.getBestCmap() -glod=font.getGlyphOrder() -for gl in glod: - if font['hmtx'][gl][0] in (498, 499, 501, 502):font['hmtx'][gl]=(500, font['hmtx'][gl][1]) - if font['hmtx'][gl][0] in (998, 999, 1001, 1002):font['hmtx'][gl]=(1000, font['hmtx'][gl][1]) - -lktb=dict() -for cd in cmap: - if cd in cmapmn and cmap[cd]!=cmapmn[cd]: - lktb[cmap[cd]]=cmapmn[cd] -for cd in cmapmn: - if cd not in cmap: - setcg(cd, cmapmn[cd]) -addlk('hwid', lktb) -lkfw=dict() -cmap=font.getBestCmap() -with open(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'fwid.txt'),'r',encoding='utf-8') as f: - for line in f.readlines(): - litm=line.strip() - if '\t' not in litm: continue - s, t=litm.split('\t') - if ord(s) not in cmap: - print('Skip', s) - continue - if ord(t) not in cmap: - print('Skip', t) - continue - if cmap[ord(s)]!=cmap[ord(t)]: - lkfw[cmap[ord(s)]]=cmap[ord(t)] -addlk('fwid', lkfw) -rmlklg(font) -dftlk(font) -newft=TTFont(inft, fontNumber=0) -newft['GSUB']=font['GSUB'] -newft['cmap']=font['cmap'] -newft.save(outft) diff --git a/sources/sp03merge.py b/sources/sp03merge.py deleted file mode 100644 index ae18a63..0000000 --- a/sources/sp03merge.py +++ /dev/null @@ -1,90 +0,0 @@ -import os, sys -import fontforge - -chars='摇瑶謡谣遥飖鳐奂唤换涣焕痪吴俣娱娯悮误录剥渌禄𮬠𫘧绿彚彞彛写泻吕宫侣黄横奥粤虚嘘戯册删姗栅带滞毁揺戸戻抜涙髪歩渉毎晩絶舎舗巻圏呉薫黒黙諌仭刄劔卽厩廏旣曁郷囱徴殻郉釼緑縁録靱郞埓勻戋栈笺残浅践刬溅盏篯线贱钱饯𬣡為偽媯溈蒍没殁内呐昷媪愠揾榅氲温煴緼腽蒀蕰藴輼醖鰛真填巔慎槙鎮顛鷏教别术剎弒怵摋殺沭秫脎術述鉥鎩俞偷喻媮榆告尚秃查頽户彦産顔舌恬憇憩栝湉甛甜舐舔銛铦𦧲𦧺壬任凭侹妊姙婬庭廷恁挺梃涏淫烶珽紝絍纴艇荏莛蜓衽袵賃赁鋌铤霆霪頲颋飪餁饪鵀䗴𬘩𬸊𠄶風嵐楓渢瘋碸諷颪颭颮颯颱颳颴颶颷颸颺颻颼颿飀飃飄飆飇飈具俱埧惧危佹卼垝姽峗桅洈硊脆臲詭诡跪陒頠鮠𠱓𬱟𬶏及伋吸圾岌彶忣扱极汲笈級级芨趿鈒钑靸馺𥄫﨤唐傏塘搪溏煻瑭禟糖螗赯鄌醣餹𨶈𲉅成城娍宬晟珹盛筬膥臹荿誠诚郕鋮铖𡷫𣚺傯悤憁摠熜牕璁窗窻總聰蔥蟌驄骢𩕄冗沉慤亡匄吂塃妄嬴巟忘忙惘慌望杗杧棢氓瀛牤甿盲硭籝網罔羸肓臝芒茫荒莣菵虻蝄蠃謊谎贏赢輞辋邙鋩铓魍龬𩷶𱇮巨佢奆岠巪弡拒柜榘洰渠炬煚矩磲秬粔苣蕖詎讵距鉅钜鮔𠳔圍韋偉媁幃徫暐椲湋潿煒禕葦衛褘諱讆躗違郼鍏闈韌韓韔韙韛韜韝韞韠韡韤𬉧俈喾嚳慥晧梏浩澔焅牿皓硞窖筶簉糙誥诰造郜酷鋯锆靠鵠鹄㸆骨嗗搰榾滑猾磆蓇餶馉骫骭骯骰骱骳骴骵骶骷骸骹骺骼骽骾骿髁髂髃髄髅髆髈髋髌髎髑髒髓體髕髖髗鶻鹘䱻咼剮卨喎堝媧撾旤檛渦禍窩簻緺腡萵蝸過鍋騧𡁜周倜凋啁奝婤彫惆椆淍琱睭碉稠簓綢绸蜩裯調调賙赒週雕鯛鲷鵰㨄鬼傀塊媿嵬巍廆愧槐櫆瑰磈蒐醜隗餽魁魂魄魅魆魇魈魉魊魋魌魎魏魑魔魘魙䰟凡巩帆恐杋梵汎矾筑築芃茿蛩跫釩銎钒鞏㧬𠆩𣎆𱝬关咲浂渕联妃屺忌改杞玘紀纪芑蓜記记跽配魢鱾𨥈夅洚絳绛胮逄降鿍䂫伛偃傴剾匹区医匼匽匾匿區呕嘔堰塸妪嫕嫗嫛岖嶇彄怄慝慪抠揠摳暱枢椻樞欧歐殴毆沤漚熰瓯甌眍瞘繄翳苉蓲蝘謳讴貙躯軀郾醫鏂駆驅驱鰋鴎鶠鷖鷗鸥鹥鼴鿀䁥䝙䞁𡂿𧏾𫪘𫭟𫸩𬉼𬥺𬸘𰰤𰽜曼墁嫚幔慢摱槾漫熳縵缦蔓蘰謾谩鏝镘饅馒鬘鰻鳗㿸價槚檟覂覆覇賈贾𠿪嵆嵇稽𥡴乑聚藂衆鄹驟骤前偂剪彅揃擶椾櫤湔煎箭糋翦謭譾谫鬋卿𦐇傝塌搨榻毾溻禢褟蹋遢闒阘鰨鳎䌈䑽𤌙𦈖羞饈馐鱃𱈌曷偈喝噶堨愒揭擖暍朅楬歇毼渴猲碣竭羯臈葛蔼藹蝎蠍褐謁譪谒轕遏霭靄鞨餲鶡鹖𨭛𮝺𮩝﨟陋旅膂令伶冷呤唥囹坽姈岭岺嶺怜拎昤朎柃泠澪玲瓴砱笭羚翎聆舲苓蛉詅軨邻鈴铃零領领鴒鸰齡齢龄鿅䙥𠍐𦊓今仱吟含唅唸埝妗岑念惗扲捻搇敜昑晗梣棯棽浛涔淰焓焾琀琴盦矜砛硶稔笒紟腍芩莟菍衾衿諗谂貪贪趻鈐钤霠頷颔騐鯰鲶黔㱃䫈𪁏𪘒𫄛𬠖𮭦𰡘𱮜卑俾啤埤婢庳捭椑牌琕痺睥碑稗箄簰粺聛脾萆薭蜱螷裨豍郫錍陴鞞顰颦髀鵯鹎鼙䫌𠜱𥱼𱰾傕搉榷確靏鶴鹤𤌍𦞦僭噆憯撍潛熸簪蠶譖谮𨅔虧侉刳匏咢咵圬垮夸姱嫮崿愕挎摴杇桍樗污洿湂瓠粵絝绔肟胯腭萼蕚袴誇諤谔跨遌鄂鄠銙鍔锷雩顎颚鰐鳄鶚鹗齶㻬𥔲𰽴鼠攛癙竄躥鑹鼢鼦鼧鼩鼪鼫鼬鼯鼱鼷鼹巤擸獵臘蠟躐邋鑞镴鬣鱲𫚭辰侲傉儂唇噥娠宸嶩憹振搙晨桭溽漘濃燶穠縟繷缛耨脣脤膿莀蓐薅蜃褥賑赈辱農辳辴鄏醲鋠鎒震鬞㫳䟴䣅婁僂嘍塿屢屨嶁廔摟擻數樓櫢漊瘻瞜窶簍籔縷耬膢蔞藪螻褸軁鏤髏𠞭𥕍犮坺妭帗拔绂茇祓胈韨盋秡袚钹紱菝跋鈸鲅䯋韍魃髮鮁黻鼥圮然嘫撚燃繎𬙇䡭侌冎埁壾枔獌獦玈瘑矝肣蒁蛫蟃谽貏輵酓𦬸𦳯𩨜慺瘣𩴾畢嗶滭熚篳蓽蹕饆鷝㻫𢳂呑丢' - -def getallcodesname(thfont): - c_g = dict() - g_c=dict() - for gls in thfont.glyphs(): - g_c[gls.glyphname]=list() - if gls.unicode > -1: - c_g[gls.unicode]=gls.glyphname - g_c[gls.glyphname].append(gls.unicode) - if gls.altuni != None: - for uni in gls.altuni: - if uni[1] <= 0: - c_g[uni[0]] = gls.glyphname - g_c[gls.glyphname].append(uni[0]) - return c_g, g_c -def mergeft(font, fin2): - print(f'Loading {fin2}...') - code_glyph, glyph_codes=getallcodesname(font) - font2 = fontforge.open(fin2) - font2.reencode("unicodefull") - font2.em = font.em - code_glyph2, glyph_codes2=getallcodesname(font2) - print('Adding glyphs...') - code_codes2 = {} - for n2 in glyph_codes2.keys(): - lc = [ac1 for ac1 in glyph_codes2[n2]] - if len(lc) > 0: - code_codes2[lc[0]] = lc[1:] - font2.selection.select(*code_codes2.keys()) - font2.copy() - font.selection.select(*code_codes2.keys()) - font.paste() - font2.close() - -def mergeftex(font, fin2): - print('Remove glyphs...') - code_glyph, glyph_codes=getallcodesname(font) - - glys={code_glyph[ord(ch)] for ch in chars} - for gly in glys: - glyph_codes[gly]=[cd for cd in glyph_codes[gly] if chr(cd) not in chars] - if len(glyph_codes[gly])<1: - font.removeGlyph(gly) - else: - gl=font[gly] - lu=list() - gl.unicode=glyph_codes[gly][0] - for u1 in glyph_codes[gly][1:]: - lu.append((u1, -1, 0)) - if len(lu) > 0: gl.altuni = tuple(lu) - else: gl.altuni = None - font.reencode("unicodefull") - print(f'Loading {fin2}...') - font2 = fontforge.open(fin2) - font2.reencode("unicodefull") - font2.em = font.em - code_glyph2, glyph_codes2=getallcodesname(font2) - code_glyph, glyph_codes=getallcodesname(font) - print('Adding glyphs...') - for ch in chars: - uni=ord(ch) - newg=font.createChar(-1, 'gly'+str(uni)) - g2=font2[code_glyph2[uni]] - font2.selection.select(g2) - font2.copy() - font.selection.select(newg) - font.paste() - newg.unicode=g2.unicode - #newg.altuni=g2.altuni - font.reencode("unicodefull") - font2.close() - -def build(outft, inft, subft, subft2): - print('Target', outft) - print('Processing...') - font=fontforge.open(inft) - print('Merging glyphs...') - mergeft(font, subft) - if not (len(sys.argv)>5 and sys.argv[5].lower()=='cl'): - mergeftex(font, subft2) - print('Saving...') - font.generate(outft) - print('Finished', outft) - -if __name__ == "__main__": - build(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) diff --git a/sources/sp05buildttc.py b/sources/sp05buildttc.py deleted file mode 100644 index 9a623b7..0000000 --- a/sources/sp05buildttc.py +++ /dev/null @@ -1,17 +0,0 @@ -from afdko import otf2otc -import sys -wts=('Regular', 'Bold', 'Light') - -BK='BrightMoonKai' -AK='ArrayStarsKai' -SP='Super' -if len(sys.argv)>1 and sys.argv[1].lower()=='cl': - BK+='CL' - AK+='CL' - SP+='CL' -for wt in wts: - for fts in (BK, AK): - ttcarg=['-o', f'{fts}-{wt}.ttc', f'{fts}-{wt}.ttf', f'{fts}Mono-{wt}.ttf'] - otf2otc.run(ttcarg) - ttcarg=['-o', f'{SP}-{wt}.ttc', f'{BK}-{wt}.ttf', f'{BK}Mono-{wt}.ttf', f'{AK}-{wt}.ttf', f'{AK}Mono-{wt}.ttf'] - otf2otc.run(ttcarg) diff --git a/sources/sp06buildzip.py b/sources/sp06buildzip.py deleted file mode 100644 index 233af08..0000000 --- a/sources/sp06buildzip.py +++ /dev/null @@ -1,32 +0,0 @@ -import os -import sys - -BK='BrightMoonKai' -AK='ArrayStarsKai' -SP='Super' -if len(sys.argv)>1 and sys.argv[1].lower()=='cl': - BK+='CL' - AK+='CL' - SP+='CL' - -sevenz='7z' - -wts=('Regular', 'Bold', 'Light') -for fts in (BK, AK): - ttfs=list() - ttcs=list() - ttfs.append('LICENSE.txt') - ttcs.append('LICENSE.txt') - for wt in wts: - ttfs.append(f'{fts}-{wt}.ttf') - ttfs.append(f'{fts}Mono-{wt}.ttf') - ttcs.append(f'{fts}-{wt}.ttc') - os.system(f'{sevenz} a ./{fts}TTFs.zip {" ".join(ttfs)}') - os.system(f'{sevenz} a ./{fts}TTCs.zip {" ".join(ttcs)}') - -spftfl=list() -spftfl.append('LICENSE.txt') -for wt in wts: - spftfl.append(f'{SP}-{wt}.ttc') -os.system(f'{sevenz} a ./{SP}TTCs.zip {" ".join(spftfl)}') - diff --git a/sources/subset.zip b/sources/subset.zip index 654cbb2..f3064a0 100644 Binary files a/sources/subset.zip and b/sources/subset.zip differ