ソースコードの管理場所
リビジョン | 7e79c030be542ca5e2c00e69a3395780418ec4f7 (tree) |
---|---|
日時 | 2019-09-14 08:45:34 |
作者 | Hironori Kitagawa <h_kitagawa2001@yaho...> |
コミッター | Hironori Kitagawa |
jpotf was broken in recent commits
@@ -854,22 +854,7 @@ do | ||
854 | 854 | [0x300C]=0xFE41, [0x300D]=0xFE42, [0x300E]=0xFE43, [0x300F]=0xFE44, |
855 | 855 | [0xFF3B]=0xFE47, [0xFF3D]=0xFE48, |
856 | 856 | } |
857 | - local vert_jpotf_table = {} | |
858 | - local function add_vform(i, k, vform, ft, add_vert, jpotf_vert) | |
859 | - if type(coverage)~='table' then return end | |
860 | - for i,v in pairs(vert_form_table) do | |
861 | - if not coverage[i] and ft.characters[v] then vform[i] = v end | |
862 | - end | |
863 | - if jpotf_vert then | |
864 | - for i,v in pairs(vert_jpotf_table) do | |
865 | - if ft.characters[v] then vform[i] = coverage[v] or vform[v] or v end | |
866 | - end | |
867 | - end | |
868 | - if add_vert then -- vert feature が有効にならない場合 | |
869 | - for i,v in pairs(coverage) do vform[i] = vform[i] or v end | |
870 | - end | |
871 | - end | |
872 | - | |
857 | + local vert_jpotf_table, vert_feat = {}, {vert=true} | |
873 | 858 | local utfbyte, utfsub = utf.byte, utf.sub |
874 | 859 | luatexja.jfont.register_vert_replace = function(t) |
875 | 860 | for i,v in pairs(t) do |
@@ -887,20 +872,25 @@ luatexbase.add_to_callback( | ||
887 | 872 | function (fmtable, fnum) |
888 | 873 | local vform = {}; fmtable.vform = vform |
889 | 874 | local t = font_getfont(fnum) |
890 | - if t.specification and t.resources then | |
891 | - local add_vert = not ltju.exist_feature(fnum, 'vert') and not ltju.exist_feature(fnum, 'vrt2') | |
892 | - local jpotf_vert = ltju.specified_feature(fnum, 'jpotf') | |
893 | - -- 現在の language, script で vert もvrt2 も有効にできない場合,強制的に vert 適用 | |
894 | - for _,i in pairs(t.resources.sequences) do | |
895 | - if i.order[1]== 'vert' and i.type == 'gsub_single' and i.steps then | |
896 | - for _,j in pairs(i.steps) do | |
897 | - if type(j)=='table' then | |
898 | - add_vform(j.coverage,vform, t, add_vert, jpotf_vert) | |
899 | - end | |
900 | - end | |
901 | - end | |
902 | - end | |
875 | + if not t then return fmtable end | |
876 | + for i,v in pairs(vert_form_table) do | |
877 | + if t.characters[v] then vform[i] = v end | |
878 | + end | |
879 | + if ltju.specified_feature(fnum, 'jpotf') then | |
880 | + for i,v in pairs(vert_jpotf_table) do | |
881 | + if t.characters[v] then vform[i] = vform[v] or v end | |
882 | + end | |
883 | + end | |
884 | + if not ltju.exist_feature(fnum, 'vert') and not ltju.exist_feature(fnum, 'vrt2') then | |
885 | + -- 現在の (script, lang) で vert もvrt2 も有効にできない場合, | |
886 | + -- 全 (script,lang) の vert を強制的に適用 | |
887 | + ltju.loop_over_feat(t, vert_feat, function (i,k) vform[i] = vform[i] or k end, true) | |
903 | 888 | end |
889 | + -- vform の中身を vert 適用結果に変える | |
890 | + ltju.loop_over_feat(t, vert_feat, | |
891 | + function (i,k) | |
892 | + for j,w in pairs(vform) do if w==k then vform[j]=nil elseif w==i then vform[j] = k end end | |
893 | + end) | |
904 | 894 | return fmtable |
905 | 895 | end, 'ltj.get_vert_form', 1 |
906 | 896 | ) |
@@ -83,16 +83,17 @@ local function loop_over_duplicates(id, func) | ||
83 | 83 | end |
84 | 84 | aux.loop_over_duplicates = loop_over_duplicates |
85 | 85 | |
86 | -local function loop_over_feat(id, feature_name, func) | |
86 | +local function loop_over_feat(id, feature_name, func, universal) | |
87 | 87 | -- feature_name: like { vert=true, vrt2 = true, ...} |
88 | 88 | -- func: return non-nil iff abort this fn |
89 | +-- universal: true iff look up all (script, lang) pair | |
89 | 90 | local t = (type(id)=="table") and id or getfont(id) |
90 | 91 | if t and t.resources and t.resources.sequences then |
91 | 92 | for _,i in pairs(t.resources.sequences) do |
92 | 93 | if i.order[1] and feature_name[i.order[1]] then |
93 | 94 | local f = i.features and i.features[i.order[1]] |
94 | 95 | if i.type == 'gsub_single' and i.steps |
95 | - and f and f[t.properties.script] and f[t.properties.script][t.properties.language] then | |
96 | + and f and (universal or (f[t.properties.script] and f[t.properties.script][t.properties.language])) then | |
96 | 97 | for _,j in pairs(i.steps) do |
97 | 98 | if type(j)=='table' then |
98 | 99 | if type(j.coverage)=='table' then |