@@ -171,15 +171,8 @@ def step1():
171
171
if str (ord (chs [1 ])) in font ['cmap' ]:
172
172
jpre [str (ord (chs [0 ]))]= font ['cmap' ][str (ord (chs [1 ]))]
173
173
shset = json .load (open (os .path .join (pydir , 'sourcehan.json' ), 'r' , encoding = 'utf-8' ))
174
- krch = shset ['krgl' ]
175
- tcch = shset ['tcgl' ]
176
- hcch = shset ['hcgl' ]
177
- scch = shset ['scgl' ]
174
+ krch , tcch , hcch , scch = shset ['krgl' ], shset ['tcgl' ], shset ['hcgl' ], shset ['scgl' ]
178
175
tbs = set ()
179
- #for krtb in lockor:
180
- # a=gettbs(krtb, xkrchg, False)
181
- # if len(a)>200:
182
- # tbs.update(a)
183
176
if len (krch )> 0 :
184
177
krchg = getgname (krch )
185
178
for zhktb in lockor :
@@ -584,7 +577,7 @@ def hwcmap():
584
577
print ('Processing' , ch )
585
578
font ['cmap' ][str (ord (ch ))]= hwlk [font ['cmap' ][str (ord (ch ))]]
586
579
except :
587
- print ('WARNING: No glyph for' , ch )
580
+ print ('WARNING: No HW glyph for' , ch )
588
581
589
582
def hwgpos ():
590
583
torm = ['kern' , 'palt' , 'vkrn' , 'vpal' ]
@@ -623,7 +616,7 @@ def itcmap():
623
616
try :
624
617
font ['cmap' ][str (ord (ch ))]= itlk [font ['cmap' ][str (ord (ch ))]]
625
618
except :
626
- print ('WARNING: No glyph for' , ch )
619
+ print ('WARNING: No It glyph for' , ch )
627
620
for uv in font ['cmap_uvs' ]:
628
621
if font ['cmap_uvs' ][uv ] in itlk :
629
622
font ['cmap_uvs' ][uv ]= itlk [font ['cmap_uvs' ][uv ]]
@@ -699,7 +692,7 @@ def stlookup():
699
692
if len (lw )> 0 :
700
693
sb ['match' ].append (lw )
701
694
else :
702
- break
695
+ raise RuntimeError ( line )
703
696
if not (s and t ) or chat < 0 :
704
697
raise RuntimeError (line )
705
698
if sg == tg :
@@ -729,8 +722,7 @@ def stlookup():
729
722
if '-' not in litm :
730
723
continue
731
724
s , t = litm .split (' ' )[0 ].split ('-' )
732
- s = s .strip ()
733
- t = t .strip ()
725
+ s , t = s .strip (), t .strip ()
734
726
if s and t and s != t and str (ord (s )) in font ['cmap' ] and str (ord (t )) in font ['cmap' ] and font ['cmap' ][str (ord (s ))]!= font ['cmap' ][str (ord (t ))]:
735
727
kt [font ['cmap' ][str (ord (s ))]]= font ['cmap' ][str (ord (t ))]
736
728
font ['GSUB' ]['lookups' ]['sigl' ]['subtables' ]= [kt ]
@@ -742,8 +734,7 @@ def ckstcmp():
742
734
if '-' not in litm :
743
735
continue
744
736
s , t = litm .split (' ' )[0 ].split ('-' )
745
- s = s .strip ()
746
- t = t .strip ()
737
+ s , t = s .strip (), t .strip ()
747
738
if s and t and s != t and str (ord (s )) not in font ['cmap' ] and str (ord (t )) in font ['cmap' ]:
748
739
font ['cmap' ][str (ord (s ))]= font ['cmap' ][str (ord (t ))]
749
740
@@ -784,18 +775,18 @@ def stname():
784
775
785
776
def getvcmp ():
786
777
a1 = dict ()
787
- font ['cmap' ]= dict (orcmp )
778
+ font ['cmap' ]= copy . deepcopy (orcmp )
788
779
a1 ['name' ], a1 ['file' ]= mkname ()
789
780
mkcmap ()
790
- a1 ['cmap' ]= dict (font ['cmap' ])
781
+ a1 ['cmap' ]= copy . deepcopy (font ['cmap' ])
791
782
if 'Mono' not in fpn :
792
783
a1 ['namehw' ], a1 ['filehw' ]= mkname ('hw' )
793
784
hwcmap ()
794
- a1 ['cmaphw' ]= dict (font ['cmap' ])
785
+ a1 ['cmaphw' ]= copy . deepcopy (font ['cmap' ])
795
786
else :
796
787
a1 ['nameit' ], a1 ['fileit' ]= mkname ('it' )
797
788
itcmap ()
798
- a1 ['cmapit' ]= dict (font ['cmap' ])
789
+ a1 ['cmapit' ]= copy . deepcopy (font ['cmap' ])
799
790
return a1
800
791
801
792
def savetmp (tmppath , fjson ):
@@ -869,12 +860,7 @@ def savefont(fontpath, tmpfl):
869
860
fpn = n1 ['nameString' ]
870
861
break
871
862
print ('Getting the localized lookups table...' )
872
- loc = set ()
873
- locjan = set ()
874
- lockor = set ()
875
- loczhs = set ()
876
- loczht = set ()
877
- loczhhk = set ()
863
+ loc , locjan , lockor , loczhs , loczht , loczhhk = (set () for i in range (6 ))
878
864
for lang in font ['GSUB' ]['languages' ].keys ():
879
865
for fs in font ['GSUB' ]['languages' ][lang ]['features' ]:
880
866
if fs .split ('_' )[0 ]== 'locl' :
@@ -911,7 +897,7 @@ def savefont(fontpath, tmpfl):
911
897
print ('Finished!' )
912
898
sys .exit ()
913
899
setinf ()
914
- orcmp = dict (font ['cmap' ])
900
+ orcmp = copy . deepcopy (font ['cmap' ])
915
901
print ('Build Fonts' )
916
902
mch , pun , simp = 'y' , '3' , '2'
917
903
AA = getvcmp ()
@@ -926,15 +912,15 @@ def savefont(fontpath, tmpfl):
926
912
print ('Generating fonts...' )
927
913
for aa1 in (AA , AATC , AASC , AAJP ):
928
914
aa1 ['file' ]= os .path .join (outd , aa1 ['file' ]+ '.' + exn )
929
- font ['cmap' ]= aa1 ['cmap' ]
915
+ font ['cmap' ]= copy . deepcopy ( aa1 ['cmap' ])
930
916
font ['name' ]= aa1 ['name' ]
931
917
aa1 ['tmp' ]= tempfile .mktemp ('.json' )
932
918
savetmp (aa1 ['tmp' ], font )
933
919
print ('Processing...' )
934
920
if 'Mono' not in fpn :
935
921
orgsb = copy .deepcopy (font ['GSUB' ])
936
922
font ['name' ]= AA ['name' ]
937
- font ['cmap' ]= AA ['cmap' ]
923
+ font ['cmap' ]= copy . deepcopy ( AA ['cmap' ])
938
924
ckstcmp ()
939
925
stlookup ()
940
926
AA ['namest' ], AA ['filest' ]= stname ()
@@ -948,15 +934,15 @@ def savefont(fontpath, tmpfl):
948
934
AA ['namesthw' ], AA ['filesthw' ]= stname ()
949
935
AA ['filesthw' ]= os .path .join (outd , AA ['filesthw' ]+ '.' + exn )
950
936
font ['name' ]= AA ['namesthw' ]
951
- font ['cmap' ]= AA ['cmaphw' ]
937
+ font ['cmap' ]= copy . deepcopy ( AA ['cmaphw' ])
952
938
ckstcmp ()
953
939
AA ['tmpsthw' ]= tempfile .mktemp ('.json' )
954
940
savetmp (AA ['tmpsthw' ], font )
955
941
print ('Processing...' )
956
- font ['GSUB' ]= orgsb
942
+ font ['GSUB' ]= copy . deepcopy ( orgsb )
957
943
for aa1 in (AA , AATC , AASC , AAJP ):
958
944
aa1 ['filehw' ]= os .path .join (outd , aa1 ['filehw' ]+ '.' + exn )
959
- font ['cmap' ]= aa1 ['cmaphw' ]
945
+ font ['cmap' ]= copy . deepcopy ( aa1 ['cmaphw' ])
960
946
font ['name' ]= aa1 ['namehw' ]
961
947
aa1 ['tmphw' ]= tempfile .mktemp ('.json' )
962
948
savetmp (aa1 ['tmphw' ], font )
@@ -965,7 +951,7 @@ def savefont(fontpath, tmpfl):
965
951
itgsub ()
966
952
for aa1 in (AA , AATC , AASC , AAJP ):
967
953
aa1 ['fileit' ]= os .path .join (outd , aa1 ['fileit' ]+ '.' + exn )
968
- font ['cmap' ]= aa1 ['cmapit' ]
954
+ font ['cmap' ]= copy . deepcopy ( aa1 ['cmapit' ])
969
955
font ['name' ]= aa1 ['nameit' ]
970
956
aa1 ['tmpit' ]= tempfile .mktemp ('.json' )
971
957
savetmp (aa1 ['tmpit' ], font )
0 commit comments