Skip to content

Commit 6635abd

Browse files
committed
Update sourcehantocl.py
1 parent cc88cab commit 6635abd

File tree

1 file changed

+20
-32
lines changed

1 file changed

+20
-32
lines changed

main/sourcehantocl.py

+20-32
Original file line numberDiff line numberDiff line change
@@ -50,37 +50,22 @@ def getgname(s):
5050

5151
def setpun(pzh, loczh):
5252
pg=getgname(pzh)
53-
zhp=list()
54-
etb=set()
55-
ztb=set()
53+
rplg=dict()
5654
for tb in loczh:
57-
allen=0
58-
for ctb in font['GSUB']['lookups'][tb]['subtables']:
59-
allen+=len(ctb)
60-
if allen>60:
61-
ztb.add(tb)
62-
else:
63-
etb.add(tb)
64-
for tb in ztb:
65-
for subtable in font['GSUB']['lookups'][tb]['subtables']:
66-
for j, t in list(subtable.items()):
67-
for p1 in pzh:
68-
cod=str(ord(p1))
69-
if cod in font['cmap']:
70-
g=font['cmap'][cod]
71-
if g==j:
72-
zhp.append((cod, t))
73-
for tb in etb:
74-
a=gettbs(tb, pg, True)
75-
if len(a)>0:
76-
relp=dict()
77-
for itm in a:
78-
if itm[0]!=itm[1]:
79-
relp[itm[0]]=itm[1]
80-
replg(relp)
81-
for punzh in zhp:
82-
print('Processing', chr(int(punzh[0])))
83-
font['cmap'][punzh[0]]=punzh[1]
55+
if tb in locjan:
56+
continue
57+
for glin in pg:
58+
for subtable in font['GSUB']['lookups'][tb]['subtables']:
59+
if glin in subtable:
60+
rplg[glin]=subtable[glin]
61+
for tb in locjan:
62+
if tb not in loczh:
63+
continue
64+
for glin in pg:
65+
for subtable in font['GSUB']['lookups'][tb]['subtables']:
66+
if glin not in rplg and glin in subtable:
67+
rplg[glin]=subtable[glin]
68+
replg(rplg)
8469

8570
def gfmloc(g, loczh):
8671
for zhtb in loczh:
@@ -882,6 +867,7 @@ def savefont(fontpath, tmpfl):
882867
break
883868
print('Getting the localized lookups table...')
884869
loc=set()
870+
locjan=set()
885871
lockor=set()
886872
loczhs=set()
887873
loczht=set()
@@ -890,7 +876,9 @@ def savefont(fontpath, tmpfl):
890876
for fs in font['GSUB']['languages'][lang]['features']:
891877
if fs.split('_')[0]=='locl':
892878
loc.update(set(font['GSUB']['features'][fs]))
893-
if lang.split('_')[-1].strip()=='KOR':
879+
if lang.split('_')[-1].strip()=='JAN':
880+
locjan.update(set(font['GSUB']['features'][fs]))
881+
elif lang.split('_')[-1].strip()=='KOR':
894882
lockor.update(set(font['GSUB']['features'][fs]))
895883
elif lang.split('_')[-1].strip()=='ZHS':
896884
loczhs.update(set(font['GSUB']['features'][fs]))
@@ -932,7 +920,7 @@ def savefont(fontpath, tmpfl):
932920
AAJP=getvcmp()
933921
rmloc()
934922
exn=inf.split('.')[-1].lower()
935-
print(f'Generating {exn.upper()}...')
923+
print('Generating fonts...')
936924
for aa1 in (AA, AATC, AASC, AAJP):
937925
aa1['file']=os.path.join(outd, aa1['file']+'.'+exn)
938926
font['cmap']=aa1['cmap']

0 commit comments

Comments
 (0)