リビジョン | 0526b27bf88ed7f2adedef267f4d9226f6f5a692 (tree) |
---|---|
日時 | 2014-11-02 20:09:18 |
作者 | Hironori Kitagawa <h_kitagawa2001@yaho...> |
コミッター | Hironori Kitagawa |
get rid of attr_orig_char
@@ -359,7 +359,12 @@ | ||
359 | 359 | } |
360 | 360 | |
361 | 361 | %%% CJKShape=JIS2004 |
362 | -\__fontspec_define_feature_option:nnnnn{CJKShape}{JIS2004}{20}{5}{+jp04} | |
362 | +\__fontspec_define_feature_option:nnnnn{CJKShape}{JIS2004}{20}{100}{+jp04} | |
363 | +%%% CharacterWidth={VerticalAlternateProportional, VerticalAlternateHalf} | |
364 | +\__fontspec_define_feature_option:nnnnn{CharacterWidth}{VerticalAlternateProportional}{22}{100}{+vpal} | |
365 | +\__fontspec_define_feature_option:nnnnn{CharacterWidth}{VerticalAlternateHalf}{22}{101}{+vhal} | |
366 | +\__fontspec_define_feature_option:nnnnn{Kerning}{Vertical} {}{}{+vkrn} | |
367 | + | |
363 | 368 | |
364 | 369 | \ExplSyntaxOff |
365 | 370 | %%%%%%%% Now we completely ignore kanjifont definition file. |
@@ -90,8 +90,8 @@ local tex_dir | ||
90 | 90 | local attr_ablshift |
91 | 91 | local set_np_xspc_jachar |
92 | 92 | |
93 | -local attr_dir = luatexbase.attributes['ltj@dir'] | |
94 | 93 | local attr_icflag = luatexbase.attributes['ltj@icflag'] |
94 | +local ltjs_orig_char_table = ltjs.orig_char_table | |
95 | 95 | |
96 | 96 | local function get_attr_icflag(p) |
97 | 97 | return (has_attr(p, attr_icflag) or 0)%PROCESSED_BEGIN_FLAG |
@@ -169,8 +169,8 @@ local head -- the head of current list | ||
169 | 169 | local Np, Nq, Bp |
170 | 170 | local widow_Bp, widow_Np -- \jcharwidowpenalty 挿入位置管理用 |
171 | 171 | |
172 | -local ihb_flag -- JFM グルー挿入抑止用 flag | |
173 | - -- on: \inhibitglue 指定時,hlist の周囲 | |
172 | +local non_ihb_flag -- JFM グルー挿入抑止用 flag | |
173 | +-- false: \inhibitglue 指定時 true: それ以外 | |
174 | 174 | |
175 | 175 | -------------------- hlist 内の文字の検索 |
176 | 176 |
@@ -250,7 +250,7 @@ function check_box_high(Nx, box_ptr, box_end) | ||
250 | 250 | if first_char then |
251 | 251 | if getid(first_char)==id_glyph then |
252 | 252 | if getfield(first_char, 'lang') == lang_ja then |
253 | - set_np_xspc_jachar(Nx, first_char) | |
253 | + set_np_xspc_jachar_hbox(Nx, first_char) | |
254 | 254 | else |
255 | 255 | set_np_xspc_alchar(Nx, getchar(first_char),first_char, 1) |
256 | 256 | end |
@@ -319,11 +319,11 @@ local min, max = math.min, math.max | ||
319 | 319 | local function calc_np_aux_glyph_common(lp) |
320 | 320 | Np.nuc = lp |
321 | 321 | Np.id = npi |
322 | - if getfield(lp, 'lang') == lang_ja then | |
322 | + if ltjs_orig_char_table[lp] then | |
323 | 323 | Np.id = id_jglyph |
324 | 324 | set_np_xspc_jachar(Np, lp) |
325 | 325 | local npi, npf |
326 | - lp, head, npi, npf = capsule_glyph(lp, Np.met, Np.class, head, tex_dir) | |
326 | + lp, head, npi, npf = capsule_glyph(lp, Np.met, Np.class, head, tex_dir, lp) | |
327 | 327 | Np.first = (Np.first~=Np.nuc) and Np.first or npf or npi |
328 | 328 | Np.nuc = npi |
329 | 329 | return true, check_next_ickern(lp); |
@@ -344,7 +344,7 @@ local function calc_np_aux_glyph_common(lp) | ||
344 | 344 | lp=lx; break |
345 | 345 | else |
346 | 346 | local lid = getid(lx) |
347 | - if lid==id_glyph and getfield(lx, 'lang') ~= lang_ja then | |
347 | + if lid==id_glyph and not ltjs_orig_char_table[lx] then | |
348 | 348 | -- 欧文文字 |
349 | 349 | last_glyph = lx; set_attr(lx, attr_icflag, PROCESSED); Np.last = lx |
350 | 350 | y_adjust = has_attr(lx,attr_ablshift) or 0 |
@@ -443,7 +443,7 @@ local calc_np_auxtable = { | ||
443 | 443 | if lps==sid_user then |
444 | 444 | if getfield(lp, 'user_id')==luatexja.userid_table.IHB then |
445 | 445 | local lq = node_next(lp); |
446 | - head = node_remove(head, lp); node_free(lp); ihb_flag = true | |
446 | + head = node_remove(head, lp); node_free(lp); non_ihb_flag = false | |
447 | 447 | return false, lq; |
448 | 448 | else |
449 | 449 | set_attr(lp, attr_icflag, PROCESSED) |
@@ -516,7 +516,7 @@ calc_np_auxtable[id_adjust] = calc_np_auxtable.skip | ||
516 | 516 | function calc_np(lp, last) |
517 | 517 | local k |
518 | 518 | -- We assume lp = node_next(Np.last) |
519 | - Np, Nq, ihb_flag = Nq, Np, nil | |
519 | + Np, Nq, non_ihb_flag = Nq, Np, true | |
520 | 520 | -- We clear `predefined' entries of Np before pairs() loop, |
521 | 521 | -- because using only pairs() loop is slower. |
522 | 522 | Np.post, Np.pre, Np.xspc = nil, nil, nil |
@@ -561,13 +561,12 @@ do | ||
561 | 561 | |
562 | 562 | -- 和文文字のデータを取得 |
563 | 563 | local attr_jchar_class = luatexbase.attributes['ltj@charclass'] |
564 | - local attr_orig_char = luatexbase.attributes['ltj@origchar'] | |
565 | 564 | local attr_autospc = luatexbase.attributes['ltj@autospc'] |
566 | 565 | local attr_autoxspc = luatexbase.attributes['ltj@autoxspc'] |
567 | 566 | function set_np_xspc_jachar_yoko(Nx, x) |
568 | 567 | local m = ltjf_font_metric_table[getfont(x)] |
569 | - local cls, c = slow_find_char_class(has_attr(x, attr_orig_char), m, getchar(x)) | |
570 | - Nx.met, Nx.char = m, c; Nx.class = cls; | |
568 | + local cls, c = slow_find_char_class(ltjs_orig_char_table[x], m, getchar(x)) | |
569 | + Nx.met = m; Nx.class = cls | |
571 | 570 | if cls~=0 then set_attr(x, attr_jchar_class, cls) end |
572 | 571 | Nx.pre = table_current_stack[PRE + c] or 0 |
573 | 572 | Nx.post = table_current_stack[POST + c] or 0 |
@@ -578,11 +577,11 @@ do | ||
578 | 577 | function set_np_xspc_jachar_tate(Nx, x) |
579 | 578 | local m = ltjf_font_metric_table[getfont(x)] |
580 | 579 | local cls, c |
581 | - local c1, c2 = getchar(x), has_attr(x, attr_orig_char) | |
582 | - c = has_attr(x, attr_dir) or c1 or c2 | |
580 | + local c1, c2 = getchar(x), ltjs_orig_char_table[x][1] | |
581 | + c = ltjs_orig_char_table[x][2] or c1 or c2 | |
583 | 582 | cls = ltjf_find_char_class(c, m) |
584 | 583 | if cls==0 then cls = slow_find_char_class(c2, m, c1) end |
585 | - Nx.met, Nx.char = m, c; Nx.class = cls; | |
584 | + Nx.met = m; Nx.class = cls; | |
586 | 585 | if cls~=0 then set_attr(x, attr_jchar_class, cls) end |
587 | 586 | Nx.pre = table_current_stack[PRE + c] or 0 |
588 | 587 | Nx.post = table_current_stack[POST + c] or 0 |
@@ -590,6 +589,16 @@ do | ||
590 | 589 | Nx.kcat = table_current_stack[KCAT + c] or 0 |
591 | 590 | Nx.auto_kspc, Nx.auto_xspc = (has_attr(x, attr_autospc)==1), (has_attr(x, attr_autoxspc)==1) |
592 | 591 | end |
592 | + local function set_np_xspc_jachar_hbox(Nx, x) | |
593 | + local m = ltjf_font_metric_table[getfont(x)] | |
594 | + local c = getchar(x) | |
595 | + Nx.met = m; Nx.class = has_attr(x, attr_jchar_class) or 0; | |
596 | + Nx.pre = table_current_stack[PRE + c] or 0 | |
597 | + Nx.post = table_current_stack[POST + c] or 0 | |
598 | + Nx.xspc = table_current_stack[XSP + c] or 3 | |
599 | + Nx.kcat = table_current_stack[KCAT + c] or 0 | |
600 | + Nx.auto_kspc, Nx.auto_xspc = (has_attr(x, attr_autospc)==1), (has_attr(x, attr_autoxspc)==1) | |
601 | + end | |
593 | 602 | |
594 | 603 | -- 欧文文字のデータを取得 |
595 | 604 | local floor = math.floor |
@@ -604,9 +613,8 @@ do | ||
604 | 613 | Nx.pre = table_current_stack[PRE + c] or 0 |
605 | 614 | Nx.post = table_current_stack[POST + c] or 0 |
606 | 615 | Nx.xspc = table_current_stack[XSP + c] or 3 |
607 | - Nx.char = 'jcharbdd' | |
608 | 616 | else |
609 | - Nx.pre, Nx.post, Nx.char = 0, 0, -1 | |
617 | + Nx.pre, Nx.post = 0, 0 | |
610 | 618 | Nx.xspc = table_current_stack[XSP - 1] or 3 |
611 | 619 | end |
612 | 620 | Nx.met = nil |
@@ -621,7 +629,7 @@ do | ||
621 | 629 | if s then |
622 | 630 | if getid(s)==id_glyph then |
623 | 631 | if getfield(s, 'lang') == lang_ja then |
624 | - set_np_xspc_jachar(Nx, s) | |
632 | + set_np_xspc_jachar_hbox(Nx, s) | |
625 | 633 | else |
626 | 634 | set_np_xspc_alchar(Nx, getchar(s), s, 2) |
627 | 635 | end |
@@ -824,22 +832,19 @@ do | ||
824 | 832 | end |
825 | 833 | |
826 | 834 | local function calc_ja_ja_glue() |
827 | - if ihb_flag then return nil | |
835 | + local qm, pm = Nq.met, Np.met | |
836 | + if (qm.char_type==pm.char_type) and (qm.var==pm.var) then | |
837 | + return new_jfm_glue(qm, Nq.class, Np.class) | |
828 | 838 | else |
829 | - local qm, pm = Nq.met, Np.met | |
830 | - if (qm.char_type==pm.char_type) and (qm.var==pm.var) then | |
831 | - return new_jfm_glue(qm, Nq.class, Np.class) | |
832 | - else | |
833 | - local npn, nqn = Np.nuc, Nq.nuc | |
834 | - local gb, db = new_jfm_glue(qm, Nq.class, | |
835 | - slow_find_char_class(has_attr(npn, attr_orig_char), | |
836 | - qm, getchar(npn))) | |
837 | - local ga, da = new_jfm_glue(pm, | |
838 | - slow_find_char_class(has_attr(nqn, attr_orig_char), | |
839 | - pm, getchar(nqn)), | |
840 | - Np.class) | |
841 | - return calc_ja_ja_aux(gb, ga, db, da); | |
842 | - end | |
839 | + local npn, nqn = Np.nuc, Nq.nuc | |
840 | + local gb, db = new_jfm_glue(qm, Nq.class, | |
841 | + slow_find_char_class(ltjs_orig_char_table[npn], | |
842 | + qm, getchar(npn))) | |
843 | + local ga, da = new_jfm_glue(pm, | |
844 | + slow_find_char_class(ltjs_orig_char_table[nqn], | |
845 | + pm, getchar(nqn)), | |
846 | + Np.class) | |
847 | + return calc_ja_ja_aux(gb, ga, db, da); | |
843 | 848 | end |
844 | 849 | end |
845 | 850 |
@@ -882,36 +887,30 @@ end | ||
882 | 887 | -------------------- 隣接した「塊」間の処理 |
883 | 888 | |
884 | 889 | local function get_OA_skip() |
885 | - if not ihb_flag then | |
886 | - local pm = Np.met | |
887 | - return new_jfm_glue(pm, | |
888 | - fast_find_char_class(((Nq.id == id_math and -1) or (type(Nq.char)=='string' and Nq.char or 'jcharbdd')), pm), Np.class) | |
889 | - else return nil | |
890 | - end | |
890 | + local pm = Np.met | |
891 | + return new_jfm_glue(pm, | |
892 | + fast_find_char_class((Nq.id == id_math and -1 or 'jcharbdd'), pm), Np.class) | |
891 | 893 | end |
892 | 894 | local function get_OB_skip() |
893 | - if not ihb_flag then | |
894 | - local qm = Nq.met | |
895 | - return new_jfm_glue(qm, Nq.class, | |
896 | - fast_find_char_class(((Np.id == id_math and -1) or'jcharbdd'), qm)) | |
897 | - else return nil | |
898 | - end | |
895 | + local qm = Nq.met | |
896 | + return new_jfm_glue(qm, Nq.class, | |
897 | + fast_find_char_class((Np.id == id_math and -1 or'jcharbdd'), qm)) | |
899 | 898 | end |
900 | 899 | |
901 | 900 | -- (anything) .. jachar |
902 | 901 | local function handle_np_jachar(mode) |
903 | 902 | local qid = Nq.id |
904 | 903 | if qid==id_jglyph or ((qid==id_pbox or qid==id_pbox_w) and Nq.met) then |
905 | - local g = calc_ja_ja_glue() or get_kanjiskip() -- M->K | |
904 | + local g = non_ihb_flag and calc_ja_ja_glue() or get_kanjiskip() -- M->K | |
906 | 905 | handle_penalty_normal(Nq.post, Np.pre, g); real_insert(g) |
907 | 906 | elseif Nq.met then -- qid==id_hlist |
908 | - local g = get_OA_skip() or get_kanjiskip() -- O_A->K | |
907 | + local g = non_ihb_flag and get_OA_skip() or get_kanjiskip() -- O_A->K | |
909 | 908 | handle_penalty_normal(0, Np.pre, g); real_insert(g) |
910 | 909 | elseif Nq.pre then |
911 | - local g = get_OA_skip() or get_xkanjiskip(Np) -- O_A->X | |
910 | + local g = non_ihb_flag and get_OA_skip() or get_xkanjiskip(Np) -- O_A->X | |
912 | 911 | handle_penalty_normal((qid==id_hlist and 0 or Nq.post), Np.pre, g); real_insert(g) |
913 | 912 | else |
914 | - local g = get_OA_skip() -- O_A | |
913 | + local g = non_ihb_flag and get_OA_skip() -- O_A | |
915 | 914 | if qid==id_glue then handle_penalty_normal(0, Np.pre, g) |
916 | 915 | elseif qid==id_kern then handle_penalty_suppress(0, Np.pre, g) |
917 | 916 | else handle_penalty_always(0, Np.pre, g) |
@@ -927,10 +926,10 @@ end | ||
927 | 926 | -- jachar .. (anything) |
928 | 927 | local function handle_nq_jachar() |
929 | 928 | if Np.pre then |
930 | - local g = get_OB_skip() or get_xkanjiskip(Nq) -- O_B->X | |
929 | + local g = non_ihb_flag and get_OB_skip() or get_xkanjiskip(Nq) -- O_B->X | |
931 | 930 | handle_penalty_normal(Nq.post, (Np.id==id_hlist and 0 or Np.pre), g); real_insert(g) |
932 | 931 | else |
933 | - local g = get_OB_skip() -- O_B | |
932 | + local g =non_ihb_flag and get_OB_skip() -- O_B | |
934 | 933 | if Np.id==id_glue then handle_penalty_normal(Nq.post, 0, g) |
935 | 934 | elseif Np.id==id_kern then handle_penalty_suppress(Nq.post, 0, g) |
936 | 935 | else handle_penalty_always(Nq.post, 0, g) |
@@ -943,7 +942,7 @@ end | ||
943 | 942 | local function handle_np_ja_hlist() |
944 | 943 | local qid = Nq.id |
945 | 944 | if qid==id_jglyph or ((qid==id_pbox or Nq.id == id_pbox_w) and Nq.met) then |
946 | - local g = get_OB_skip() or get_kanjiskip() -- O_B->K | |
945 | + local g = non_ihb_flag and get_OB_skip() or get_kanjiskip() -- O_B->K | |
947 | 946 | handle_penalty_normal(Nq.post, 0, g); real_insert(g) |
948 | 947 | elseif Nq.met then -- Nq.id==id_hlist |
949 | 948 | local g = get_kanjiskip() -- K |
@@ -1015,7 +1014,7 @@ end | ||
1015 | 1014 | local function handle_list_head(par_indented) |
1016 | 1015 | local npi, pm = Np.id, Np.met |
1017 | 1016 | if npi == id_jglyph or (npi==id_pbox and pm) then |
1018 | - if not ihb_flag then | |
1017 | + if non_ihb_flag then | |
1019 | 1018 | local g = new_jfm_glue(pm, fast_find_char_class(par_indented, pm), Np.class) |
1020 | 1019 | if g then |
1021 | 1020 | set_attr(g, attr_icflag, BOXBDD) |
@@ -829,20 +829,22 @@ luatexbase.add_to_callback( | ||
829 | 829 | local vadv = {}; fmtable.v_advance = vadv |
830 | 830 | local ft = font_getfont(fnum) |
831 | 831 | local subtables = {} |
832 | - for feat_name,v in pairs(ft.specification.features.normal) do | |
833 | - if v then | |
834 | - for _,i in pairs(ft.resources.sequences) do | |
835 | - if i.order[1]== feat_name and i.type == 'gpos_single' then | |
836 | - for _,st in pairs(i.subtables) do | |
837 | - subtables[st] = true | |
832 | + if ft.specification then | |
833 | + for feat_name,v in pairs(ft.specification.features.normal) do | |
834 | + if v then | |
835 | + for _,i in pairs(ft.resources.sequences) do | |
836 | + if i.order[1]== feat_name and i.type == 'gpos_single' then | |
837 | + for _,st in pairs(i.subtables) do | |
838 | + subtables[st] = true | |
839 | + end | |
838 | 840 | end |
839 | 841 | end |
840 | - end | |
841 | - end | |
842 | - end | |
843 | - acc_feature(vadv, subtables, ft) | |
844 | - for i,v in pairs(vadv) do | |
845 | - vadv[i]=vadv[i]/ft.units_per_em*fmtable.size | |
842 | + end | |
843 | + end | |
844 | + acc_feature(vadv, subtables, ft) | |
845 | + for i,v in pairs(vadv) do | |
846 | + vadv[i]=vadv[i]/ft.units_per_em*fmtable.size | |
847 | + end | |
846 | 848 | end |
847 | 849 | return fmtable |
848 | 850 | end, 1, 'ltj.v_advance' |
@@ -43,7 +43,7 @@ local attr_curtfnt = luatexbase.attributes['ltj@curtfnt'] | ||
43 | 43 | local attr_icflag = luatexbase.attributes['ltj@icflag'] |
44 | 44 | |
45 | 45 | local is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char_direct |
46 | ---local ltjs_orig_char_table = ltjs.orig_char_table | |
46 | +local ltjs_orig_char_table = ltjs.orig_char_table | |
47 | 47 | local ltjf_get_vert_glyph = ltjf.get_vert_glyph |
48 | 48 | local ltjf_replace_altfont = ltjf.replace_altfont |
49 | 49 | local attr_orig_char = luatexbase.attributes['ltj@origchar'] |
@@ -67,9 +67,8 @@ do | ||
67 | 67 | if (has_attr(p, attr_icflag) or 0)<=0 and is_ucs_in_japanese_char(p) then |
68 | 68 | local pc = getchar(p) |
69 | 69 | local pf = ltjf_replace_altfont(has_attr(p, attr_curjfnt) or getfont(p), pc) |
70 | - setfield(p, 'font', pf) | |
71 | - setfield(p, 'lang', lang_ja) | |
72 | - set_attr(p, attr_orig_char, pc) | |
70 | + setfield(p, 'font', pf); setfield(p, 'lang', lang_ja) | |
71 | + ltjs_orig_char_table[p] = pc | |
73 | 72 | end |
74 | 73 | return p |
75 | 74 | end |
@@ -98,6 +97,9 @@ do | ||
98 | 97 | local p = head |
99 | 98 | for i = 1,#wt do wt[i]=nil end |
100 | 99 | for i = 1,#wtd do wtd[i]=nil end |
100 | + for i,_ in pairs(ltjs_orig_char_table) do | |
101 | + ltjs_orig_char_table[i] = nil | |
102 | + end | |
101 | 103 | ltjs.list_dir=ltjd_get_dir_count() |
102 | 104 | while p and p~=t do |
103 | 105 | local pfunc = suppress_hyphenate_ja_aux[getid(p)] |
@@ -130,13 +132,13 @@ local function set_box_stack_level(head, mode) | ||
130 | 132 | for p in Dnode.traverse_id(id_glyph,to_direct(head)) do |
131 | 133 | if (has_attr(p, attr_icflag) or 0)<=0 and getfield(p, 'lang')==lang_ja then |
132 | 134 | local pfn = has_attr(p, attr_curtfnt) or getfont(p) |
133 | - local pc = getchar(p) | |
135 | + local pc = ltjs_orig_char_table[p] | |
134 | 136 | local pf = ltjf_replace_altfont(pfn, pc) |
135 | - set_attr(p, attr_dir, pc) | |
136 | - pc = ltjf_get_vert_glyph(pf, pc) or pc | |
137 | - setfield(p, 'char', pc); set_attr(p, attr_orig_char, pc) | |
138 | - setfield(p, 'font', pf); --set_attr(p, attr_curjfnt, pf) | |
139 | - end | |
137 | + ltjs_orig_char_table[p] = { pc, ltjs_orig_char_table[p] } | |
138 | + local xc = ltjf_get_vert_glyph(pf, pc) or pc | |
139 | + setfield(p, 'char', xc); setfield(p, 'font', pf); | |
140 | + ltjs_orig_char_table[p] = { pc, xc } | |
141 | + end | |
140 | 142 | end |
141 | 143 | end |
142 | 144 | --luatexja.ext_show_node_list(head, 'S> ', print) |
@@ -111,6 +111,10 @@ function set_stack_skip(m,sp) | ||
111 | 111 | end |
112 | 112 | |
113 | 113 | -- These three functions are used in ltj-jfmglue.lua. |
114 | +-- list_dir and orig_char_table are used in other lua files. | |
115 | +orig_char_table = {} | |
116 | +list_dir = nil -- dummy | |
117 | +table_current_stack = nil -- dummy | |
114 | 118 | function report_stack_level(bsl) |
115 | 119 | table_current_stack = charprop_stack_table[bsl] |
116 | 120 | return bsl |
@@ -130,11 +134,5 @@ function get_stack_table(mc, d, idx) | ||
130 | 134 | return i or d |
131 | 135 | end |
132 | 136 | |
133 | --------------------------------------------------------------------------------- | |
134 | --- nest table (obeys TeX's semantic nest) | |
135 | --------------------------------------------------------------------------------- | |
136 | -nest_table = {} | |
137 | -local nest_table = nest_table | |
138 | - | |
139 | 137 | |
140 | 138 | -- EOF |