ソースコードの管理場所
Revisão | 37f1bb93a832e691f61cb06e771759d2602de827 (tree) |
---|---|
Hora | 2014-10-28 14:22:31 |
Autor | Hironori Kitagawa <h_kitagawa2001@yaho...> |
Commiter | Hironori Kitagawa |
Use lang field for judgement if a glyph_node repr. a JAchar or not.
@@ -0,0 +1,158 @@ | ||
1 | +-- | |
2 | +-- luatexja/ltj-pretreat.lua | |
3 | +-- | |
4 | + | |
5 | +luatexja.load_module('base'); local ltjb = luatexja.base | |
6 | +luatexja.load_module('charrange'); local ltjc = luatexja.charrange | |
7 | +luatexja.load_module('stack'); local ltjs = luatexja.stack | |
8 | +luatexja.load_module('jfont'); local ltjf = luatexja.jfont | |
9 | +luatexja.load_module('direction'); local ltjd = luatexja.direction | |
10 | + | |
11 | +local Dnode = node.direct or node | |
12 | + | |
13 | +local nullfunc = function(n) return n end | |
14 | +local to_node = (Dnode ~= node) and Dnode.tonode or nullfunc | |
15 | +local to_direct = (Dnode ~= node) and Dnode.todirect or nullfunc | |
16 | + | |
17 | +local setfield = (Dnode ~= node) and Dnode.setfield or function(n, i, c) n[i] = c end | |
18 | +local getid = (Dnode ~= node) and Dnode.getid or function(n) return n.id end | |
19 | +local getfont = (Dnode ~= node) and Dnode.getfont or function(n) return n.font end | |
20 | +local getchar = (Dnode ~= node) and Dnode.getchar or function(n) return n.char end | |
21 | +local getfield = (Dnode ~= node) and Dnode.getfield or function(n, i) return n[i] end | |
22 | +local getsubtype = (Dnode ~= node) and Dnode.getsubtype or function(n) return n.subtype end | |
23 | + | |
24 | +local pairs = pairs | |
25 | +local floor = math.floor | |
26 | +local has_attr = Dnode.has_attribute | |
27 | +local set_attr = Dnode.set_attribute | |
28 | +local node_traverse = Dnode.traverse | |
29 | +local node_remove = Dnode.remove | |
30 | +local node_next = (Dnode ~= node) and Dnode.getnext or node.next | |
31 | +local node_free = Dnode.free | |
32 | +local node_end_of_math = Dnode.end_of_math | |
33 | +local tex_getcount = tex.getcount | |
34 | + | |
35 | +local id_glyph = node.id('glyph') | |
36 | +local id_math = node.id('math') | |
37 | +local id_whatsit = node.id('whatsit') | |
38 | +local sid_user = node.subtype('user_defined') | |
39 | + | |
40 | +local attr_dir = luatexbase.attributes['ltj@dir'] | |
41 | +local attr_curjfnt = luatexbase.attributes['ltj@curjfnt'] | |
42 | +local attr_curtfnt = luatexbase.attributes['ltj@curtfnt'] | |
43 | +local attr_icflag = luatexbase.attributes['ltj@icflag'] | |
44 | + | |
45 | +local is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char_direct | |
46 | +local ltjf_get_vert_glyph = ltjf.get_vert_glyph | |
47 | +local ltjf_replace_altfont = ltjf.replace_altfont | |
48 | +local attr_orig_char = luatexbase.attributes['ltj@origchar'] | |
49 | +local STCK = luatexja.userid_table.STCK | |
50 | +local DIR = luatexja.userid_table.DIR | |
51 | +local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG | |
52 | + | |
53 | +local dir_tate = luatexja.dir_table.dir_tate | |
54 | +local lang_ja = token.create('ltj@@japanese')[2] | |
55 | +------------------------------------------------------------------------ | |
56 | +-- MAIN PROCESS STEP 1: replace fonts | |
57 | +------------------------------------------------------------------------ | |
58 | +local wt, wtd = {}, {} | |
59 | +do | |
60 | + local ltjd_get_dir_count = ltjd.get_dir_count | |
61 | + local start_time_measure, stop_time_measure | |
62 | + = ltjb.start_time_measure, ltjb.stop_time_measure | |
63 | + local head | |
64 | + local is_dir_tate | |
65 | + local suppress_hyphenate_ja_aux = {} | |
66 | + suppress_hyphenate_ja_aux[id_glyph] = function(p) | |
67 | + if (has_attr(p, attr_icflag) or 0)<=0 and is_ucs_in_japanese_char(p) then | |
68 | + local pc = getchar(p) | |
69 | + local pf = ltjf_replace_altfont(has_attr(p, attr_curjfnt) or getfont(p), pc) | |
70 | + setfield(p, 'font', pf); set_attr(p, attr_curjfnt, pf) | |
71 | + setfield(p, 'lang', lang_ja) | |
72 | + set_attr(p, attr_orig_char, pc) | |
73 | + end | |
74 | + return p | |
75 | + end | |
76 | + suppress_hyphenate_ja_aux[id_math] = function(p) | |
77 | + return node_end_of_math(node_next(p)) end | |
78 | + suppress_hyphenate_ja_aux[50] = function(p) return p end | |
79 | + suppress_hyphenate_ja_aux[id_whatsit] = function(p) | |
80 | + if getsubtype(p)==sid_user then | |
81 | + local uid = getfield(p, 'user_id') | |
82 | + if uid==STCK then | |
83 | + wt[#wt+1] = p; node_remove(head, p) | |
84 | + elseif uid==DIR then | |
85 | + if has_attr(p, attr_icflag)<PROCESSED_BEGIN_FLAG then | |
86 | + ltjs.list_dir = has_attr(p, attr_dir) | |
87 | + else | |
88 | + wtd[#wtd+1] = p; node_remove(head, p) | |
89 | + end | |
90 | + end | |
91 | + end | |
92 | + return p | |
93 | + end | |
94 | + | |
95 | + local function suppress_hyphenate_ja (h,t) | |
96 | + start_time_measure('ltj_hyphenate') | |
97 | + head = to_direct(h) | |
98 | + local p = head | |
99 | + for i = 1,#wt do wt[i]=nil end | |
100 | + for i = 1,#wtd do wtd[i]=nil end | |
101 | + ltjs.list_dir=ltjd_get_dir_count() | |
102 | + while p and p~=t do | |
103 | + local pfunc = suppress_hyphenate_ja_aux[getid(p)] | |
104 | + p = node_next(pfunc and pfunc(p) or p) | |
105 | + end | |
106 | + stop_time_measure('ltj_hyphenate'); start_time_measure('tex_hyphenate') | |
107 | + lang.hyphenate(h, t) | |
108 | + stop_time_measure('tex_hyphenate') | |
109 | + return h | |
110 | + end | |
111 | + | |
112 | + luatexbase.add_to_callback('hyphenate', | |
113 | + function (head,tail) | |
114 | + return suppress_hyphenate_ja(head) | |
115 | + end,'ltj.hyphenate') | |
116 | +end | |
117 | + | |
118 | +-- mode: true iff this function is called from hpack_filter | |
119 | +local ltjs_report_stack_level = ltjs.report_stack_level | |
120 | +local function set_box_stack_level(head, mode) | |
121 | + local box_set, cl = 0, tex.currentgrouplevel + 1 | |
122 | + for _,p in pairs(wt) do | |
123 | + if mode and getfield(p, 'value')==cl then box_set = 1 end; node_free(p) | |
124 | + end | |
125 | + ltjs_report_stack_level(tex_getcount('ltj@@stack') + box_set) | |
126 | + for _,p in pairs(wtd) do | |
127 | + node_free(p) | |
128 | + end | |
129 | + is_dir_tate = ltjs.list_dir == dir_tate | |
130 | + if is_dir_tate then | |
131 | + for p in Dnode.traverse_id(id_glyph,to_direct(head)) do | |
132 | + if (has_attr(p, attr_icflag) or 0)<=0 and has_attr(p, attr_curjfnt)==getfont(p) then | |
133 | + local pfn = has_attr(p, attr_curtfnt) or getfont(p) | |
134 | + local pc = getchar(p) | |
135 | + local pf = ltjf_replace_altfont(pfn, pc) | |
136 | + set_attr(p, attr_dir, pc) | |
137 | + pc = ltjf_get_vert_glyph(pf, pc) or pc | |
138 | + setfield(p, 'char', pc); set_attr(p, attr_orig_char, pc) | |
139 | + setfield(p, 'font', pf); set_attr(p, attr_curjfnt, pf) | |
140 | + end | |
141 | + end | |
142 | + end | |
143 | + return head | |
144 | +end | |
145 | + | |
146 | +-- CALLBACKS | |
147 | +luatexbase.add_to_callback('hpack_filter', | |
148 | + function (head) | |
149 | + return set_box_stack_level(head, true) | |
150 | + end,'ltj.hpack_filter_pre',1) | |
151 | +luatexbase.add_to_callback('pre_linebreak_filter', | |
152 | + function (head) | |
153 | + return set_box_stack_level(head, false) | |
154 | + end,'ltj.pre_linebreak_filter_pre',1) | |
155 | + | |
156 | +luatexja.pretreat = { | |
157 | + set_box_stack_level = set_box_stack_level, | |
158 | +} |
@@ -46,7 +46,7 @@ local id_glue_spec = node.id('glue_spec') | ||
46 | 46 | local id_whatsit = node.id('whatsit') |
47 | 47 | local attr_icflag = luatexbase.attributes['ltj@icflag'] |
48 | 48 | local attr_jchar_class = luatexbase.attributes['ltj@charclass'] |
49 | -local attr_curjfnt = luatexbase.attributes['ltj@curjfnt'] | |
49 | +local lang_ja = token.create('ltj@@japanese')[2] | |
50 | 50 | |
51 | 51 | local ltjf_font_metric_table = ltjf.font_metric_table |
52 | 52 | local spec_zero_glue = ltjj.spec_zero_glue |
@@ -189,7 +189,7 @@ local function aw_step1(p, res, total) | ||
189 | 189 | -- and ((xi == id_penalty) or (xi == id_kern) or (xi == id_kern)) do |
190 | 190 | -- x = node_prev(x); xi = getid(x) |
191 | 191 | -- end |
192 | - if xi == id_glyph and has_attr(x, attr_curjfnt) == getfont(x) then | |
192 | + if xi == id_glyph and getfield(x, 'lang')==lang_ja then | |
193 | 193 | -- 和文文字 |
194 | 194 | xc = x |
195 | 195 | elseif xi == id_hlist and get_attr_icflag(x) == PACKED then |
@@ -66,6 +66,7 @@ local id_box_like = 256 -- vbox, shifted hbox | ||
66 | 66 | local id_pbox = 257 -- already processed nodes (by \unhbox) |
67 | 67 | local id_pbox_w = 258 -- cluster which consists of a whatsit |
68 | 68 | local sid_user = node.subtype('user_defined') |
69 | +local lang_ja = token.create('ltj@@japanese')[2] | |
69 | 70 | |
70 | 71 | local sid_start_link = node.subtype('pdf_start_link') |
71 | 72 | local sid_start_thread = node.subtype('pdf_start_thread') |
@@ -89,7 +90,6 @@ local tex_dir | ||
89 | 90 | local attr_ablshift |
90 | 91 | local set_np_xspc_jachar |
91 | 92 | |
92 | -local attr_curjfnt = luatexbase.attributes['ltj@curjfnt'] | |
93 | 93 | local attr_dir = luatexbase.attributes['ltj@dir'] |
94 | 94 | local attr_icflag = luatexbase.attributes['ltj@icflag'] |
95 | 95 |
@@ -99,10 +99,6 @@ end | ||
99 | 99 | |
100 | 100 | -------------------- Helper functions |
101 | 101 | |
102 | -local function copy_attr(new, old) | |
103 | - -- 仕様が決まるまで off にしておく | |
104 | -end | |
105 | - | |
106 | 102 | -- This function is called only for acquiring `special' characters. |
107 | 103 | local function fast_find_char_class(c,m) |
108 | 104 | return m.chars[c] or 0 |
@@ -234,7 +230,7 @@ local function check_box(box_ptr, box_end) | ||
234 | 230 | first_char = p; find_first_char = false |
235 | 231 | end |
236 | 232 | last_char = p; found_visible_node = true |
237 | - elseif pid==id_rule and get_attr_icflag(p)==PACKED then | |
233 | + elseif pid==id_rule and get_attr_icflag(p)==PACKED then | |
238 | 234 | -- do nothing |
239 | 235 | elseif not (pid==id_ins or pid==id_mark |
240 | 236 | or pid==id_adjust or pid==id_whatsit |
@@ -253,7 +249,7 @@ function check_box_high(Nx, box_ptr, box_end) | ||
253 | 249 | local first_char = first_char |
254 | 250 | if first_char then |
255 | 251 | if getid(first_char)==id_glyph then |
256 | - if getfont(first_char) == (has_attr(first_char, attr_curjfnt) or -1) then | |
252 | + if getfield(first_char, 'lang') == lang_ja then | |
257 | 253 | set_np_xspc_jachar(Nx, first_char) |
258 | 254 | else |
259 | 255 | set_np_xspc_alchar(Nx, getchar(first_char),first_char, 1) |
@@ -321,7 +317,7 @@ local min, max = math.min, math.max | ||
321 | 317 | local function calc_np_aux_glyph_common(lp) |
322 | 318 | Np.nuc = lp |
323 | 319 | Np.id = npi |
324 | - if (getfont(lp) == (has_attr(lp, attr_curjfnt) or -1)) then | |
320 | + if getfield(lp, 'lang') == lang_ja then | |
325 | 321 | Np.id = id_jglyph |
326 | 322 | set_np_xspc_jachar(Np, lp) |
327 | 323 | local npi, npf |
@@ -346,12 +342,12 @@ local function calc_np_aux_glyph_common(lp) | ||
346 | 342 | lp=lx; break |
347 | 343 | else |
348 | 344 | local lid = getid(lx) |
349 | - if lid==id_glyph and not(getfont(lx) == (has_attr(lx, attr_curjfnt) or -1)) then | |
345 | + if lid==id_glyph and getfield(lx, 'lang') ~= lang_ja then | |
350 | 346 | -- 欧文文字 |
351 | 347 | last_glyph = lx; set_attr(lx, attr_icflag, PROCESSED); Np.last = lx |
352 | 348 | y_adjust = has_attr(lx,attr_ablshift) or 0 |
353 | 349 | node_depth = max(getfield(lx, 'depth') + min(y_adjust, 0), node_depth) |
354 | - adj_depth = (y_adjust>0) and max(getfield(lp, 'depth') + y_adjust, adj_depth) or adj_depth | |
350 | + adj_depth = (y_adjust>0) and max(getfield(lx, 'depth') + y_adjust, adj_depth) or adj_depth | |
355 | 351 | setfield(lx, 'yoffset', getfield(lx, 'yoffset') - y_adjust) |
356 | 352 | elseif lid==id_kern then |
357 | 353 | local ls = getsubtype(lx) |
@@ -633,7 +629,7 @@ do | ||
633 | 629 | local s = Nx.last_char |
634 | 630 | if s then |
635 | 631 | if getid(s)==id_glyph then |
636 | - if getfont(s) == (has_attr(s, attr_curjfnt) or -1) then | |
632 | + if getfield(s, 'lang') == lang_ja then | |
637 | 633 | set_np_xspc_jachar(Nx, s) |
638 | 634 | else |
639 | 635 | set_np_xspc_alchar(Nx, getchar(s), s, 2) |
@@ -665,6 +665,7 @@ end | ||
665 | 665 | -- MISC |
666 | 666 | ------------------------------------------------------------------------ |
667 | 667 | do |
668 | + local get_dir_count = ltjd.get_dir_count | |
668 | 669 | local is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char_direct |
669 | 670 | local tex_set_attr = tex.setattribute |
670 | 671 | local font = font |
@@ -677,7 +678,7 @@ do | ||
677 | 678 | setfield(g, 'subtype', 1) |
678 | 679 | set_attr(g, attr_icflag, ITALIC) |
679 | 680 | if is_ucs_in_japanese_char(p) then |
680 | - f = has_attr(p, attr_curjfnt) | |
681 | + f = has_attr(p, (get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt) | |
681 | 682 | local j = font_metric_table[f] |
682 | 683 | setfield(g, 'kern', j.char_type[find_char_class(getchar(p), j)].italic) |
683 | 684 | else |
@@ -8,6 +8,8 @@ luatexja.load_module('base'); local ltjb = luatexja.base | ||
8 | 8 | luatexja.load_module('jfont'); local ltjf = luatexja.jfont |
9 | 9 | luatexja.load_module('rmlgbm'); local ltjr = luatexja.rmlgbm |
10 | 10 | luatexja.load_module('charrange'); local ltjc = luatexja.charrange |
11 | +luatexja.load_module('direction'); local ltjd = luatexja.direction | |
12 | +luatexja.load_module('stack'); local ltjs = luatexja.stack | |
11 | 13 | |
12 | 14 | local id_glyph = node.id('glyph') |
13 | 15 | local id_whatsit = node.id('whatsit') |
@@ -41,13 +43,18 @@ local node_traverse_id = Dnode.traverse_id | ||
41 | 43 | local identifiers = fonts.hashes.identifiers |
42 | 44 | |
43 | 45 | local attr_curjfnt = luatexbase.attributes['ltj@curjfnt'] |
46 | +local attr_curtfnt = luatexbase.attributes['ltj@curtfnt'] | |
44 | 47 | local attr_yablshift = luatexbase.attributes['ltj@yablshift'] |
45 | 48 | local attr_ykblshift = luatexbase.attributes['ltj@ykblshift'] |
49 | +local attr_tablshift = luatexbase.attributes['ltj@tablshift'] | |
50 | +local attr_tkblshift = luatexbase.attributes['ltj@tkblshift'] | |
51 | +local lang_ja = token.create('ltj@@japanese')[2] | |
46 | 52 | |
47 | 53 | local ltjf_font_metric_table = ltjf.font_metric_table |
48 | 54 | local ltjf_find_char_class = ltjf.find_char_class |
49 | 55 | local ltjr_cidfont_data = ltjr.cidfont_data |
50 | 56 | local ltjc_is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char |
57 | +local ltjd_get_dir_count = ltjd.get_dir_count | |
51 | 58 | |
52 | 59 | luatexja.userid_table.OTF = luatexbase.newuserwhatsitid('char_by_cid', 'luatexja') |
53 | 60 | luatexja.userid_table.VSR = luatexbase.newuserwhatsitid('replace_vs', 'luatexja') |
@@ -80,43 +87,51 @@ end | ||
80 | 87 | -- This whatsit node will be extracted to a glyph_node |
81 | 88 | local function append_jglyph(char) |
82 | 89 | local p = node_new(id_whatsit,sid_user) |
83 | - local v = tex.attribute[attr_curjfnt] | |
84 | 90 | setfield(p, 'user_id', OTF) |
85 | 91 | setfield(p, 'type', 100) |
86 | 92 | setfield(p, 'value', char) |
87 | - set_attr(p, attr_yablshift, tex.attribute[attr_ykblshift]) | |
88 | 93 | node_write(p) |
89 | 94 | end |
90 | 95 | |
91 | -local function cid(key) | |
92 | - if key==0 then return append_jglyph(char) end | |
93 | - local curjfnt = identifiers[tex.attribute[attr_curjfnt]] | |
94 | - if not curjfnt.cidinfo or | |
95 | - curjfnt.cidinfo.ordering ~= "Japan1" and | |
96 | - curjfnt.cidinfo.ordering ~= "GB1" and | |
97 | - curjfnt.cidinfo.ordering ~= "CNS1" and | |
98 | - curjfnt.cidinfo.ordering ~= "Korea1" then | |
99 | --- ltjb.package_warning('luatexja-otf', | |
100 | --- 'Current Japanese font (or other CJK font) "' | |
101 | --- ..curjfnt.psname..'" is not a CID-Keyed font (Adobe-Japan1 etc.)') | |
102 | - return append_jglyph(get_ucs_from_rmlgbm(key)) | |
103 | - end | |
104 | - local char = curjfnt.resources.unicodes[curjfnt.cidinfo.ordering..'.'..tostring(key)] | |
105 | - if not char then | |
106 | - ltjb.package_warning('luatexja-otf', | |
107 | - 'Current Japanese font (or other CJK font) "' | |
108 | - ..curjfnt.psname..'" does not have the specified CID character (' | |
109 | - ..tostring(key)..')', | |
110 | - 'Use a font including the specified CID character.') | |
111 | - char = 0 | |
96 | +local cid | |
97 | +do | |
98 | + local dir_tate = luatexja.dir_table.dir_tate | |
99 | + local tex_get_attr = tex.getattribute | |
100 | + cid = function (key) | |
101 | + if key==0 then return append_jglyph(char) end | |
102 | + local curjfnt = identifiers[tex_get_attr((ltjd_get_dir_count()==dir_tate) | |
103 | + and attr_curtfnt or attr_curjfnt)] | |
104 | + if not curjfnt.cidinfo or | |
105 | + curjfnt.cidinfo.ordering ~= "Japan1" and | |
106 | + curjfnt.cidinfo.ordering ~= "GB1" and | |
107 | + curjfnt.cidinfo.ordering ~= "CNS1" and | |
108 | + curjfnt.cidinfo.ordering ~= "Korea1" then | |
109 | + -- ltjb.package_warning('luatexja-otf', | |
110 | + -- 'Current Japanese font (or other CJK font) "' | |
111 | + -- ..curjfnt.psname..'" is not a CID-Keyed font (Adobe-Japan1 etc.)') | |
112 | + return append_jglyph(get_ucs_from_rmlgbm(key)) | |
113 | + end | |
114 | + local char = curjfnt.resources.unicodes[curjfnt.cidinfo.ordering..'.'..tostring(key)] | |
115 | + if not char then | |
116 | + ltjb.package_warning('luatexja-otf', | |
117 | + 'Current Japanese font (or other CJK font) "' | |
118 | + ..curjfnt.psname..'" does not have the specified CID character (' | |
119 | + ..tostring(key)..')', | |
120 | + 'Use a font including the specified CID character.') | |
121 | + char = 0 | |
122 | + end | |
123 | + return append_jglyph(char) | |
112 | 124 | end |
113 | - return append_jglyph(char) | |
114 | 125 | end |
115 | 126 | |
116 | 127 | local function extract(head) |
117 | 128 | head = to_direct(head) |
118 | 129 | local p = head |
119 | 130 | local v |
131 | + local is_dir_tate = ltjs.list_dir == dir_tate | |
132 | + local attr_ablshift = is_dir_tate and attr_tablshift or attr_yablshift | |
133 | + local attr_kblshift = is_dir_tate and attr_tkblshift or attr_ykblshift | |
134 | + local attr_curfnt = is_dir_tate and attr_curtfnt or attr_curjfnt | |
120 | 135 | while p do |
121 | 136 | if getid(p)==id_whatsit then |
122 | 137 | if getsubtype(p)==sid_user then |
@@ -125,14 +140,12 @@ local function extract(head) | ||
125 | 140 | local g = node_new(id_glyph) |
126 | 141 | setfield(g, 'subtype', 0) |
127 | 142 | setfield(g, 'char', getfield(p, 'value')) |
128 | - v = has_attr(p, attr_curjfnt); setfield(g, 'font',v) | |
129 | - set_attr(g, attr_curjfnt, puid==OTF and v or -1) | |
130 | - -- VSR yields ALchar | |
131 | - v = has_attr(p, attr_yablshift) | |
132 | - if v then | |
133 | - set_attr(g, attr_yablshift, v) | |
143 | + v = has_attr(p, attr_curfnt); setfield(g, 'font',v) | |
144 | + if puid==OTF then | |
145 | + setfield(g, 'lang', lang_ja) | |
146 | + set_attr(g, attr_kblshift, has_attr(p, attr_kblshift)) | |
134 | 147 | else |
135 | - unset_attr(g, attr_yablshift) | |
148 | + set_attr(g, attr_ablshift, has_attr(p, attr_ablshift)) | |
136 | 149 | end |
137 | 150 | head = node_insert_after(head, p, g) |
138 | 151 | head = node_remove(head, p) |
@@ -290,8 +303,6 @@ do | ||
290 | 303 | setfield(p, 'user_id', uid) |
291 | 304 | setfield(p, 'type', 100) |
292 | 305 | setfield(p, 'value', char) |
293 | - set_attr(p, attr_curjfnt, pf) | |
294 | - set_attr(p, attr_yablshift, has_attr(bp, attr_ykblshift) or 0) | |
295 | 306 | return p |
296 | 307 | end |
297 | 308 |
@@ -314,7 +325,7 @@ do | ||
314 | 325 | node_free(q) |
315 | 326 | if pt then |
316 | 327 | local np = ivs_jglyph(pt, p, pf, |
317 | - (has_attr(p,attr_curjfnt) or 0)==pf and OTF or VSR) | |
328 | + (getfield(p, 'lang') or 0)==lang_ja and OTF or VSR) | |
318 | 329 | head = node_insert_after(head, p, np) |
319 | 330 | head = node_remove(head,p) |
320 | 331 | node_free(p) |
@@ -51,14 +51,14 @@ local DIR = luatexja.userid_table.DIR | ||
51 | 51 | local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG |
52 | 52 | |
53 | 53 | local dir_tate = luatexja.dir_table.dir_tate |
54 | -local lang_ja = token.create('ltj@japanese')[2] | |
54 | +local lang_ja = token.create('ltj@@japanese')[2] | |
55 | 55 | ------------------------------------------------------------------------ |
56 | 56 | -- MAIN PROCESS STEP 1: replace fonts |
57 | 57 | ------------------------------------------------------------------------ |
58 | 58 | local wt, wtd = {}, {} |
59 | 59 | do |
60 | 60 | local ltjd_get_dir_count = ltjd.get_dir_count |
61 | - local start_time_measure, stop_time_measure | |
61 | + local start_time_measure, stop_time_measure | |
62 | 62 | = ltjb.start_time_measure, ltjb.stop_time_measure |
63 | 63 | local head |
64 | 64 | local is_dir_tate |
@@ -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); set_attr(p, attr_curjfnt, pf) | |
70 | + setfield(p, 'font', pf); --set_attr(p, attr_curjfnt, pf) | |
71 | 71 | setfield(p, 'lang', lang_ja) |
72 | - --setfield(p, 'subtype', floor(getsubtype(p)*0.5)*2) | |
73 | 72 | set_attr(p, attr_orig_char, pc) |
74 | 73 | end |
75 | 74 | return p |
@@ -78,7 +77,7 @@ do | ||
78 | 77 | return node_end_of_math(node_next(p)) end |
79 | 78 | suppress_hyphenate_ja_aux[50] = function(p) return p end |
80 | 79 | suppress_hyphenate_ja_aux[id_whatsit] = function(p) |
81 | - if getsubtype(p)==sid_user then | |
80 | + if getsubtype(p)==sid_user then | |
82 | 81 | local uid = getfield(p, 'user_id') |
83 | 82 | if uid==STCK then |
84 | 83 | wt[#wt+1] = p; node_remove(head, p) |
@@ -130,14 +129,14 @@ local function set_box_stack_level(head, mode) | ||
130 | 129 | is_dir_tate = ltjs.list_dir == dir_tate |
131 | 130 | if is_dir_tate then |
132 | 131 | for p in Dnode.traverse_id(id_glyph,to_direct(head)) do |
133 | - if (has_attr(p, attr_icflag) or 0)<=0 and has_attr(p, attr_curjfnt)==getfont(p) then | |
132 | + if (has_attr(p, attr_icflag) or 0)<=0 and getfield(p, 'lang')==lang_ja then | |
134 | 133 | local pfn = has_attr(p, attr_curtfnt) or getfont(p) |
135 | 134 | local pc = getchar(p) |
136 | 135 | local pf = ltjf_replace_altfont(pfn, pc) |
137 | 136 | set_attr(p, attr_dir, pc) |
138 | 137 | pc = ltjf_get_vert_glyph(pf, pc) or pc |
139 | 138 | setfield(p, 'char', pc); set_attr(p, attr_orig_char, pc) |
140 | - setfield(p, 'font', pf); set_attr(p, attr_curjfnt, pf) | |
139 | + setfield(p, 'font', pf); --set_attr(p, attr_curjfnt, pf) | |
141 | 140 | end |
142 | 141 | end |
143 | 142 | end |