• R/O
  • HTTP
  • SSH
  • HTTPS

luatexja: コミット

ソースコードの管理場所


コミットメタ情報

リビジョン0526b27bf88ed7f2adedef267f4d9226f6f5a692 (tree)
日時2014-11-02 20:09:18
作者Hironori Kitagawa <h_kitagawa2001@yaho...>
コミッターHironori Kitagawa

ログメッセージ

get rid of attr_orig_char

変更サマリ

差分

--- a/src/addons/luatexja-fontspec-24.sty
+++ b/src/addons/luatexja-fontspec-24.sty
@@ -359,7 +359,12 @@
359359 }
360360
361361 %%% 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+
363368
364369 \ExplSyntaxOff
365370 %%%%%%%% Now we completely ignore kanjifont definition file.
--- a/src/ltj-jfmglue.lua
+++ b/src/ltj-jfmglue.lua
@@ -90,8 +90,8 @@ local tex_dir
9090 local attr_ablshift
9191 local set_np_xspc_jachar
9292
93-local attr_dir = luatexbase.attributes['ltj@dir']
9493 local attr_icflag = luatexbase.attributes['ltj@icflag']
94+local ltjs_orig_char_table = ltjs.orig_char_table
9595
9696 local function get_attr_icflag(p)
9797 return (has_attr(p, attr_icflag) or 0)%PROCESSED_BEGIN_FLAG
@@ -169,8 +169,8 @@ local head -- the head of current list
169169 local Np, Nq, Bp
170170 local widow_Bp, widow_Np -- \jcharwidowpenalty 挿入位置管理用
171171
172-local ihb_flag -- JFM グルー挿入抑止用 flag
173- -- on: \inhibitglue 指定時,hlist の周囲
172+local non_ihb_flag -- JFM グルー挿入抑止用 flag
173+-- false: \inhibitglue 指定時 true: それ以外
174174
175175 -------------------- hlist 内の文字の検索
176176
@@ -250,7 +250,7 @@ function check_box_high(Nx, box_ptr, box_end)
250250 if first_char then
251251 if getid(first_char)==id_glyph then
252252 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)
254254 else
255255 set_np_xspc_alchar(Nx, getchar(first_char),first_char, 1)
256256 end
@@ -319,11 +319,11 @@ local min, max = math.min, math.max
319319 local function calc_np_aux_glyph_common(lp)
320320 Np.nuc = lp
321321 Np.id = npi
322- if getfield(lp, 'lang') == lang_ja then
322+ if ltjs_orig_char_table[lp] then
323323 Np.id = id_jglyph
324324 set_np_xspc_jachar(Np, lp)
325325 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)
327327 Np.first = (Np.first~=Np.nuc) and Np.first or npf or npi
328328 Np.nuc = npi
329329 return true, check_next_ickern(lp);
@@ -344,7 +344,7 @@ local function calc_np_aux_glyph_common(lp)
344344 lp=lx; break
345345 else
346346 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
348348 -- 欧文文字
349349 last_glyph = lx; set_attr(lx, attr_icflag, PROCESSED); Np.last = lx
350350 y_adjust = has_attr(lx,attr_ablshift) or 0
@@ -443,7 +443,7 @@ local calc_np_auxtable = {
443443 if lps==sid_user then
444444 if getfield(lp, 'user_id')==luatexja.userid_table.IHB then
445445 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
447447 return false, lq;
448448 else
449449 set_attr(lp, attr_icflag, PROCESSED)
@@ -516,7 +516,7 @@ calc_np_auxtable[id_adjust] = calc_np_auxtable.skip
516516 function calc_np(lp, last)
517517 local k
518518 -- We assume lp = node_next(Np.last)
519- Np, Nq, ihb_flag = Nq, Np, nil
519+ Np, Nq, non_ihb_flag = Nq, Np, true
520520 -- We clear `predefined' entries of Np before pairs() loop,
521521 -- because using only pairs() loop is slower.
522522 Np.post, Np.pre, Np.xspc = nil, nil, nil
@@ -561,13 +561,12 @@ do
561561
562562 -- 和文文字のデータを取得
563563 local attr_jchar_class = luatexbase.attributes['ltj@charclass']
564- local attr_orig_char = luatexbase.attributes['ltj@origchar']
565564 local attr_autospc = luatexbase.attributes['ltj@autospc']
566565 local attr_autoxspc = luatexbase.attributes['ltj@autoxspc']
567566 function set_np_xspc_jachar_yoko(Nx, x)
568567 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
571570 if cls~=0 then set_attr(x, attr_jchar_class, cls) end
572571 Nx.pre = table_current_stack[PRE + c] or 0
573572 Nx.post = table_current_stack[POST + c] or 0
@@ -578,11 +577,11 @@ do
578577 function set_np_xspc_jachar_tate(Nx, x)
579578 local m = ltjf_font_metric_table[getfont(x)]
580579 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
583582 cls = ltjf_find_char_class(c, m)
584583 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;
586585 if cls~=0 then set_attr(x, attr_jchar_class, cls) end
587586 Nx.pre = table_current_stack[PRE + c] or 0
588587 Nx.post = table_current_stack[POST + c] or 0
@@ -590,6 +589,16 @@ do
590589 Nx.kcat = table_current_stack[KCAT + c] or 0
591590 Nx.auto_kspc, Nx.auto_xspc = (has_attr(x, attr_autospc)==1), (has_attr(x, attr_autoxspc)==1)
592591 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
593602
594603 -- 欧文文字のデータを取得
595604 local floor = math.floor
@@ -604,9 +613,8 @@ do
604613 Nx.pre = table_current_stack[PRE + c] or 0
605614 Nx.post = table_current_stack[POST + c] or 0
606615 Nx.xspc = table_current_stack[XSP + c] or 3
607- Nx.char = 'jcharbdd'
608616 else
609- Nx.pre, Nx.post, Nx.char = 0, 0, -1
617+ Nx.pre, Nx.post = 0, 0
610618 Nx.xspc = table_current_stack[XSP - 1] or 3
611619 end
612620 Nx.met = nil
@@ -621,7 +629,7 @@ do
621629 if s then
622630 if getid(s)==id_glyph then
623631 if getfield(s, 'lang') == lang_ja then
624- set_np_xspc_jachar(Nx, s)
632+ set_np_xspc_jachar_hbox(Nx, s)
625633 else
626634 set_np_xspc_alchar(Nx, getchar(s), s, 2)
627635 end
@@ -824,22 +832,19 @@ do
824832 end
825833
826834 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)
828838 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);
843848 end
844849 end
845850
@@ -882,36 +887,30 @@ end
882887 -------------------- 隣接した「塊」間の処理
883888
884889 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)
891893 end
892894 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))
899898 end
900899
901900 -- (anything) .. jachar
902901 local function handle_np_jachar(mode)
903902 local qid = Nq.id
904903 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
906905 handle_penalty_normal(Nq.post, Np.pre, g); real_insert(g)
907906 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
909908 handle_penalty_normal(0, Np.pre, g); real_insert(g)
910909 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
912911 handle_penalty_normal((qid==id_hlist and 0 or Nq.post), Np.pre, g); real_insert(g)
913912 else
914- local g = get_OA_skip() -- O_A
913+ local g = non_ihb_flag and get_OA_skip() -- O_A
915914 if qid==id_glue then handle_penalty_normal(0, Np.pre, g)
916915 elseif qid==id_kern then handle_penalty_suppress(0, Np.pre, g)
917916 else handle_penalty_always(0, Np.pre, g)
@@ -927,10 +926,10 @@ end
927926 -- jachar .. (anything)
928927 local function handle_nq_jachar()
929928 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
931930 handle_penalty_normal(Nq.post, (Np.id==id_hlist and 0 or Np.pre), g); real_insert(g)
932931 else
933- local g = get_OB_skip() -- O_B
932+ local g =non_ihb_flag and get_OB_skip() -- O_B
934933 if Np.id==id_glue then handle_penalty_normal(Nq.post, 0, g)
935934 elseif Np.id==id_kern then handle_penalty_suppress(Nq.post, 0, g)
936935 else handle_penalty_always(Nq.post, 0, g)
@@ -943,7 +942,7 @@ end
943942 local function handle_np_ja_hlist()
944943 local qid = Nq.id
945944 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
947946 handle_penalty_normal(Nq.post, 0, g); real_insert(g)
948947 elseif Nq.met then -- Nq.id==id_hlist
949948 local g = get_kanjiskip() -- K
@@ -1015,7 +1014,7 @@ end
10151014 local function handle_list_head(par_indented)
10161015 local npi, pm = Np.id, Np.met
10171016 if npi == id_jglyph or (npi==id_pbox and pm) then
1018- if not ihb_flag then
1017+ if non_ihb_flag then
10191018 local g = new_jfm_glue(pm, fast_find_char_class(par_indented, pm), Np.class)
10201019 if g then
10211020 set_attr(g, attr_icflag, BOXBDD)
--- a/src/ltj-jfont.lua
+++ b/src/ltj-jfont.lua
@@ -829,20 +829,22 @@ luatexbase.add_to_callback(
829829 local vadv = {}; fmtable.v_advance = vadv
830830 local ft = font_getfont(fnum)
831831 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
838840 end
839841 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
846848 end
847849 return fmtable
848850 end, 1, 'ltj.v_advance'
--- a/src/ltj-pretreat.lua
+++ b/src/ltj-pretreat.lua
@@ -43,7 +43,7 @@ local attr_curtfnt = luatexbase.attributes['ltj@curtfnt']
4343 local attr_icflag = luatexbase.attributes['ltj@icflag']
4444
4545 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
4747 local ltjf_get_vert_glyph = ltjf.get_vert_glyph
4848 local ltjf_replace_altfont = ltjf.replace_altfont
4949 local attr_orig_char = luatexbase.attributes['ltj@origchar']
@@ -67,9 +67,8 @@ do
6767 if (has_attr(p, attr_icflag) or 0)<=0 and is_ucs_in_japanese_char(p) then
6868 local pc = getchar(p)
6969 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
7372 end
7473 return p
7574 end
@@ -98,6 +97,9 @@ do
9897 local p = head
9998 for i = 1,#wt do wt[i]=nil end
10099 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
101103 ltjs.list_dir=ltjd_get_dir_count()
102104 while p and p~=t do
103105 local pfunc = suppress_hyphenate_ja_aux[getid(p)]
@@ -130,13 +132,13 @@ local function set_box_stack_level(head, mode)
130132 for p in Dnode.traverse_id(id_glyph,to_direct(head)) do
131133 if (has_attr(p, attr_icflag) or 0)<=0 and getfield(p, 'lang')==lang_ja then
132134 local pfn = has_attr(p, attr_curtfnt) or getfont(p)
133- local pc = getchar(p)
135+ local pc = ltjs_orig_char_table[p]
134136 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
140142 end
141143 end
142144 --luatexja.ext_show_node_list(head, 'S> ', print)
--- a/src/ltj-stack.lua
+++ b/src/ltj-stack.lua
@@ -111,6 +111,10 @@ function set_stack_skip(m,sp)
111111 end
112112
113113 -- 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
114118 function report_stack_level(bsl)
115119 table_current_stack = charprop_stack_table[bsl]
116120 return bsl
@@ -130,11 +134,5 @@ function get_stack_table(mc, d, idx)
130134 return i or d
131135 end
132136
133---------------------------------------------------------------------------------
134--- nest table (obeys TeX's semantic nest)
135---------------------------------------------------------------------------------
136-nest_table = {}
137-local nest_table = nest_table
138-
139137
140138 -- EOF
旧リポジトリブラウザで表示