ソースコードの管理場所
修订版 | cd47cbb8581fedb03c2f9b7cb1607b68c858a2a0 (tree) |
---|---|
时间 | 2015-10-12 08:00:46 |
作者 | Hironori Kitagawa <h_kitagawa2001@yaho...> |
Commiter | Hironori Kitagawa |
small optimize
@@ -24,6 +24,7 @@ | ||
24 | 24 | %%%%%%%% fonts |
25 | 25 | \usepackage{luatexja-otf} |
26 | 26 | \directlua{luatexja.otf.enable_ivs()} |
27 | +\expandafter\let\csname xetex_suppressfontnotfounderror:D\endcsname\suppressfontnotfounderror | |
27 | 28 | \usepackage[match]{luatexja-fontspec} |
28 | 29 | \usepackage[kozuka-pr6n]{luatexja-preset} |
29 | 30 | \usepackage{unicode-math} |
@@ -5051,7 +5052,7 @@ This callback is called when \LuaTeX-ja is trying to encapsule a | ||
5051 | 5052 | その\textit{glyph\_node}をカプセル化しようとする際に呼び出される. |
5052 | 5053 | %</ja> |
5053 | 5054 | \begin{lstlisting}[numbers=left] |
5054 | -function (<table> shift_info, <table> jfont_info, <number> char_class) | |
5055 | +function (<table> shift_info, <table> jfont_info, <table> char_type) | |
5055 | 5056 | return <table> new_shift_info |
5056 | 5057 | end |
5057 | 5058 | \end{lstlisting} |
@@ -5090,7 +5091,7 @@ Then, the position of glyphs is shifted up by | ||
5090 | 5091 | (和文OpenTypeフォントの標準値) |
5091 | 5092 | \item 実フォント側の数値:$(\hbox{高さ})=28y$, $(\hbox{深さ})=5y$(和文TrueTypeフォントの標準値) |
5092 | 5093 | \end{itemize} |
5093 | -となっていたとする.すると,実際の文字の出力位置は,以下の量だけ上にぜらされることとなる: | |
5094 | +となっていたとする.すると,実際の文字の出力位置は,以下の量だけ上にずらされることとなる: | |
5094 | 5095 | %</ja> |
5095 | 5096 | \[ |
5096 | 5097 | \frac{88x}{88x+12x} (28y+5y) - 28y = \frac{26}{25}y= 1.04y. |
@@ -319,9 +319,9 @@ local function calc_np_aux_glyph_common(lp) | ||
319 | 319 | Np.first= (Np.first or lp) |
320 | 320 | if getfield(lp, 'lang') == lang_ja then |
321 | 321 | Np.id = id_jglyph |
322 | - local m, cls = set_np_xspc_jachar(Np, lp) | |
322 | + local m, mc, cls = set_np_xspc_jachar(Np, lp) | |
323 | 323 | local npi, npf |
324 | - lp, head, npi, npf = capsule_glyph(lp, m, cls, head, tex_dir, lp) | |
324 | + lp, head, npi, npf = capsule_glyph(lp, m, mc[cls], head, tex_dir) | |
325 | 325 | Np.first = (Np.first~=Np.nuc) and Np.first or npf or npi |
326 | 326 | Np.nuc = npi |
327 | 327 | return true, check_next_ickern(lp); |
@@ -567,6 +567,7 @@ do | ||
567 | 567 | c = c or c_glyph |
568 | 568 | local cls = slow_find_char_class(c, m, c_glyph) |
569 | 569 | Nx.met, Nx.class, Nx.char = m, cls, c; |
570 | + local mc = m.char_type; Nx.char_type = mc | |
570 | 571 | if cls~=0 then set_attr(x, attr_jchar_class, cls) end |
571 | 572 | if c~=c_glyph then set_attr(x, attr_jchar_code, c) end |
572 | 573 | Nx.pre = table_current_stack[PRE + c] or 0 |
@@ -574,12 +575,13 @@ do | ||
574 | 575 | Nx.xspc = table_current_stack[XSP + c] or 3 |
575 | 576 | Nx.kcat = table_current_stack[KCAT + c] or 0 |
576 | 577 | Nx.auto_kspc, Nx.auto_xspc = (has_attr(x, attr_autospc)==1), (has_attr(x, attr_autoxspc)==1) |
577 | - return m, cls | |
578 | + return m, mc, cls | |
578 | 579 | end |
579 | 580 | function set_np_xspc_jachar_hbox(Nx, x) |
580 | 581 | local m = ltjf_font_metric_table[getfont(x)] |
581 | 582 | local c = has_attr(x, attr_jchar_code) or getchar(x) |
582 | 583 | Nx.met, Nx.char = m, c; Nx.class = has_attr(x, attr_jchar_class) or 0; |
584 | + local mc = m.char_type; Nx.char_type = mc | |
583 | 585 | Nx.pre = table_current_stack[PRE + c] or 0 |
584 | 586 | Nx.post = table_current_stack[POST + c] or 0 |
585 | 587 | Nx.xspc = table_current_stack[XSP + c] or 3 |
@@ -682,9 +684,9 @@ local function handle_penalty_suppress(post, pre, g) | ||
682 | 684 | end |
683 | 685 | |
684 | 686 | -- 和文文字間の JFM glue を node 化 |
685 | -local function new_jfm_glue(m, bc, ac) | |
687 | +local function new_jfm_glue(mc, bc, ac) | |
686 | 688 | -- bc, ac: char classes |
687 | - local g = m.char_type[bc][ac] | |
689 | + local g = mc[bc][ac] | |
688 | 690 | if g then |
689 | 691 | if g[1] then |
690 | 692 | local f = node_new(id_glue) |
@@ -832,23 +834,24 @@ do | ||
832 | 834 | |
833 | 835 | calc_ja_ja_glue = function () |
834 | 836 | local qm, pm = Nq.met, Np.met |
835 | - if (qm.char_type==pm.char_type) and (qm.var==pm.var) then | |
836 | - local g, _, kn, kp, kh = new_jfm_glue(qm, Nq.class, Np.class) | |
837 | + local qmc, pmc = qm.char_type, pm.char_type | |
838 | + if (qmc==pmc) and (qm.var==pm.var) then | |
839 | + local g, _, kn, kp, kh = new_jfm_glue(qmc, Nq.class, Np.class) | |
837 | 840 | return g, (Np.auto_kspc or Nq.auto_kspc) and get_kanjiskip_low(false, qm, kn, kp, kh) |
838 | 841 | else |
839 | 842 | local npn, nqn = Np.nuc, Nq.nuc |
840 | 843 | local gb, db, bn, bp, bh |
841 | - = new_jfm_glue(qm, Nq.class, | |
844 | + = new_jfm_glue(qmc, Nq.class, | |
842 | 845 | slow_find_char_class(Np.char, |
843 | 846 | qm, getchar(npn))) |
844 | 847 | local ga, da, an, ap, ah |
845 | - = new_jfm_glue(pm, | |
848 | + = new_jfm_glue(pmc, | |
846 | 849 | slow_find_char_class(Nq.char, |
847 | 850 | pm, getchar(nqn)), |
848 | 851 | Np.class) |
849 | 852 | local g = calc_ja_ja_aux(gb, ga, db, da) |
850 | 853 | local k |
851 | - if (pm.char_type==qm.char_type) and (qm.var==pm.var) then | |
854 | + if (pmc==qmc) and (qm.var==pm.var) then | |
852 | 855 | gb = get_kanjiskip_low(false, qm, bn, bp, bh) |
853 | 856 | ga = get_kanjiskip_low(false, pm, an, ap, ah) |
854 | 857 | k = calc_ja_ja_aux(gb, ga, db, da) |
@@ -913,7 +916,7 @@ end | ||
913 | 916 | local function get_OA_skip(is_kanji) |
914 | 917 | local pm = Np.met |
915 | 918 | local g, _, kn, kp, kh = new_jfm_glue( |
916 | - pm, | |
919 | + pm.char_type, | |
917 | 920 | fast_find_char_class((Nq.id == id_math and -1 or 'jcharbdd'), pm), |
918 | 921 | Np.class) |
919 | 922 | local k |
@@ -928,7 +931,7 @@ end | ||
928 | 931 | local function get_OB_skip(is_kanji) |
929 | 932 | local qm = Nq.met |
930 | 933 | local g, _, kn, kp, kh = new_jfm_glue( |
931 | - qm, Nq.class, | |
934 | + qm.char_type, Nq.class, | |
932 | 935 | fast_find_char_class((Np.id == id_math and -1 or'jcharbdd'), qm)) |
933 | 936 | local k |
934 | 937 | if is_kanji==0 then |
@@ -1051,7 +1054,7 @@ local function handle_list_tail(mode) | ||
1051 | 1054 | -- the current list is the contents of a hbox |
1052 | 1055 | local npi, pm = Np.id, Np.met |
1053 | 1056 | if npi == id_jglyph or (npi==id_pbox and pm) then |
1054 | - local g = new_jfm_glue(pm, Np.class, fast_find_char_class('boxbdd', pm)) | |
1057 | + local g = new_jfm_glue(pm.char_type, Np.class, fast_find_char_class('boxbdd', pm)) | |
1055 | 1058 | if g then |
1056 | 1059 | set_attr(g, attr_icflag, BOXBDD) |
1057 | 1060 | head = insert_after(head, Np.last, g) |
@@ -1065,7 +1068,7 @@ local function handle_list_head(par_indented) | ||
1065 | 1068 | local npi, pm = Np.id, Np.met |
1066 | 1069 | if npi == id_jglyph or (npi==id_pbox and pm) then |
1067 | 1070 | if non_ihb_flag then |
1068 | - local g = new_jfm_glue(pm, fast_find_char_class(par_indented, pm), Np.class) | |
1071 | + local g = new_jfm_glue(pm.char_type, fast_find_char_class(par_indented, pm), Np.class) | |
1069 | 1072 | if g then |
1070 | 1073 | set_attr(g, attr_icflag, BOXBDD) |
1071 | 1074 | if getid(g)==id_glue and #Bp==0 then |
@@ -152,7 +152,7 @@ function (p, sty) | ||
152 | 152 | set_attr(r, attr_ykblshift, 0) |
153 | 153 | -- ltj-setwidth 内で実際の位置補正はおこなうので,補正量を退避 |
154 | 154 | local met = ltjf_font_metric_table[f] |
155 | - r = capsule_glyph_math(r, met, ltjf_find_char_class(pc, met)); | |
155 | + r = capsule_glyph_math(r, met, met.char_type[ltjf_find_char_class(pc, met)]); | |
156 | 156 | setfield(q, 'head', r); node_free(p); p=q; |
157 | 157 | set_attr(r, attr_yablshift, k) |
158 | 158 | end |
@@ -65,7 +65,7 @@ local ltjw = {} --export | ||
65 | 65 | luatexja.setwidth = ltjw |
66 | 66 | |
67 | 67 | luatexbase.create_callback("luatexja.set_width", "data", |
68 | - function (fstable, fmtable, jchar_class) | |
68 | + function (fstable, fmtable, char_data) | |
69 | 69 | return fstable |
70 | 70 | end) |
71 | 71 | local call_callback = luatexbase.call_callback |
@@ -75,14 +75,13 @@ local fshift = { down = 0, left = 0} | ||
75 | 75 | local min, max = math.min, math.max |
76 | 76 | |
77 | 77 | -- 和文文字の位置補正(横) |
78 | -local function capsule_glyph_yoko(p, met, class, head, dir) | |
79 | - local char_data = met.char_type[class] | |
78 | +local function capsule_glyph_yoko(p, met, char_data, head, dir) | |
80 | 79 | if not char_data then return node_next(p), head, p end |
81 | 80 | -- f*: whd specified in JFM |
82 | 81 | local fwidth, pwidth = char_data.width, getfield(p, 'width') |
83 | 82 | fwidth = (fwidth ~= 'prop') and fwidth or pwidth |
84 | 83 | fshift.down = char_data.down; fshift.left = char_data.left |
85 | - fshift = call_callback("luatexja.set_width", fshift, met, class) | |
84 | + fshift = call_callback("luatexja.set_width", fshift, met, char_data) | |
86 | 85 | local fheight, fdepth = char_data.height, char_data.depth |
87 | 86 | local kbl = has_attr(p, attr_ykblshift) or 0 |
88 | 87 | -- |
@@ -133,8 +132,7 @@ end | ||
133 | 132 | luatexja.setwidth.capsule_glyph_yoko = capsule_glyph_yoko |
134 | 133 | |
135 | 134 | -- 和文文字の位置補正(縦) |
136 | -local function capsule_glyph_tate(p, met, class, head, dir) | |
137 | - local char_data = met.char_type[class] | |
135 | +local function capsule_glyph_tate(p, met, char_data, head, dir) | |
138 | 136 | if not char_data then return node_next(p), head end |
139 | 137 | local ascent, descent = met.ascent, met.descent |
140 | 138 | local fwidth, pwidth = char_data.width |
@@ -150,7 +148,7 @@ local function capsule_glyph_tate(p, met, class, head, dir) | ||
150 | 148 | end |
151 | 149 | fwidth = (fwidth ~= 'prop') and fwidth or pwidth |
152 | 150 | fshift.down = char_data.down; fshift.left = char_data.left |
153 | - fshift = call_callback("luatexja.set_width", fshift, met, class) | |
151 | + fshift = call_callback("luatexja.set_width", fshift, met, char_data) | |
154 | 152 | local fheight, fdepth = char_data.height, char_data.depth |
155 | 153 | |
156 | 154 | local y_shift |
@@ -186,16 +184,15 @@ local function capsule_glyph_tate(p, met, class, head, dir) | ||
186 | 184 | end |
187 | 185 | luatexja.setwidth.capsule_glyph_tate = capsule_glyph_tate |
188 | 186 | |
189 | -local function capsule_glyph_math(p, met, class) | |
190 | - local char_data = met.char_type[class] | |
187 | +local function capsule_glyph_math(p, met, char_data) | |
191 | 188 | if not char_data then return nil end |
192 | 189 | local fwidth, pwidth = char_data.width, getfield(p, 'width') |
193 | 190 | fwidth = (fwidth ~= 'prop') and fwidth or pwidth |
194 | 191 | fshift.down = char_data.down; fshift.left = char_data.left |
195 | - fshift = call_callback("luatexja.set_width", fshift, met, class) | |
192 | + fshift = call_callback("luatexja.set_width", fshift, met, char_data) | |
196 | 193 | local fheight, fdepth = char_data.height, char_data.depth |
197 | - local y_shift, ca | |
198 | - = - getfield(p, 'yoffset') + (has_attr(p,attr_ykblshift) or 0), char_data.align | |
194 | + local y_shift | |
195 | + = - getfield(p, 'yoffset') + (has_attr(p,attr_ykblshift) or 0) | |
199 | 196 | setfield(p, 'yoffset', -fshift.down) |
200 | 197 | setfield(p, 'xoffset', getfield(p, 'xoffset') + char_data.align*(fwidth-pwidth) - fshift.left) |
201 | 198 | local box = node_new(id_hlist); |
@@ -1,5 +1,6 @@ | ||
1 | 1 | |
2 | 2 | require('lualibs') |
3 | +tableunpack = table.unpack | |
3 | 4 | |
4 | 5 | ------------------------------------------------------------------------ |
5 | 6 | -- naming: |