From 594fc9678065b536a21ead96bf888ceeb76c46de Mon Sep 17 00:00:00 2001 From: GuiWonder <55447192+GuiWonder@users.noreply.github.com> Date: Sun, 19 Mar 2023 07:07:07 +0800 Subject: [PATCH] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix convert for ”「 , #3 . --- main/convertf.py | 16 +++++++++++----- main/converto.py | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/main/convertf.py b/main/convertf.py index d0e56f3..7630de1 100644 --- a/main/convertf.py +++ b/main/convertf.py @@ -131,7 +131,10 @@ def removeglyhps(font): font.removeGlyph(gls) def ForCharslookups(font, tabch, mulchar): code_glyph, glyph_codes=getallcodesname(font) - font.addLookup('stchar', 'gsub_single', None, (("ccmp",(("hani",("dflt")),)),)) + lantgs=list() + for lantg in ('DFLT', 'hani', 'latn'): + lantgs.append((lantg, ("dflt",))) + font.addLookup('stchar', 'gsub_single', None, (("ccmp", tuple(lantgs)), )) font.addLookupSubtable('stchar', 'stchar1') if tabch=='ts': txtfl=['Chars_tsm', ] @@ -145,7 +148,7 @@ def ForCharslookups(font, tabch, mulchar): s, t = litm.split('\t') s = s.strip() t = t.strip() - if tabch!='ts' and s not in mulchar:continue + if tabch!='ts' and txf!='Punctuation' and s not in mulchar:continue if s and t and s != t and ord(t) in code_glyph and ord(s) in code_glyph: gntc = code_glyph[ord(t)] gnsc = code_glyph[ord(s)] @@ -176,8 +179,11 @@ def ForWordslookups(font, tabch): if len(stword) + sumf > 65535: raise RuntimeError('Not enough glyph space! You need ' + str(len(stword) + sumf - 65535) + ' more glyph space!') stword.sort(key=lambda x:len(x[0]), reverse = True) - font.addLookup('stmult', 'gsub_multiple', None, (("ccmp",(("hani",("dflt")),)),), 'stchar') - font.addLookup('stliga', 'gsub_ligature', None, (("ccmp",(("hani",("dflt")),)),)) + lantgs=list() + for lantg in ('DFLT', 'hani', 'latn'): + lantgs.append((lantg, ("dflt",))) + font.addLookup('stmult', 'gsub_multiple', None, (("ccmp", tuple(lantgs)), ), 'stchar') + font.addLookup('stliga', 'gsub_ligature', None, (("ccmp", tuple(lantgs)), )) i, j, tlen, wlen = 0, 0, 0, len(stword[0][0]) font.addLookupSubtable('stmult', 'stmult0') font.addLookupSubtable('stliga', 'stliga0') @@ -311,7 +317,7 @@ def jptotr(font): if alt[0] in tv and tv[alt[0]] == alt[1]: ltb.append((gls.glyphname, alt[0])) if len(ltb)<1: - raise RuntimeError('This font is not applicable! 此功能不適用這個字體。') + raise RuntimeError('This font is not applicable!') for t1 in ltb: unimvtogly(font, code_glyph, glyph_codes, t1[1], t1[0]) def unimvtogly(font, code_glyph, glyph_codes, uni, gly): diff --git a/main/converto.py b/main/converto.py index 6a24c98..781323c 100644 --- a/main/converto.py +++ b/main/converto.py @@ -189,7 +189,7 @@ def lkpsch(font, tabch, mulchar): if '\t' not in litm: continue s, t = litm.split('\t') s, t= s.strip(), t.strip() - if tabch!='ts' and s not in mulchar:continue + if tabch!='ts' and txf!='Punctuation' and s not in mulchar:continue if s and t and s != t and str(ord(s)) in font['cmap'] and str(ord(t)) in font['cmap']: kt[font['cmap'][str(ord(s))]] = font['cmap'][str(ord(t))] font['GSUB']['lookups']['stchars'] = {'type': 'gsub_single', 'flags': {}, 'subtables': [kt]}