OSDN Git Service

luatexja-fontspec-*.sty: forgot to update \setmonojfont
[luatex-ja/luatexja.git] / src / ltj-inputbuf.lua
1 --
2 -- luatexja/ltj-inputbuf.lua
3 --
4
5 luatexja.load_module('base');      local ltjb = luatexja.base
6 luatexja.load_module('charrange'); local ltjc = luatexja.charrange
7
8 require("unicode")
9 local utflen = utf.len
10 local utfbyte = utf.byte
11 local utfchar = utf.char
12 local node_new = node.new
13 local node_free = node.free
14 local id_glyph = node.id('glyph')
15 local getcatcode, getcount = tex.getcatcode, tex.getcount
16 local ltjc_is_japanese_char_curlist = ltjc.is_japanese_char_curlist
17
18 --- the following function is modified from jafontspec.lua (by K. Maeda).
19 --- Instead of "%", we use U+FFFFF for suppressing spaces.
20 --DEBUG require"socket"
21 local time_line = 0
22 local start_time_measure, stop_time_measure
23    = ltjb.start_time_measure, ltjb.stop_time_measure
24 local function add_comment(buffer)
25    start_time_measure('inputbuf')
26    local i = utflen(buffer)
27    while (i>0) and (getcatcode(utfbyte(buffer, i))==1
28                  or getcatcode(utfbyte(buffer, i))==2) do
29       i=i-1
30    end
31    if i>0 then
32       local c = utfbyte(buffer, i)
33       if c>=0x80 then
34          local ct = getcatcode(c)
35          local te = tex.endlinechar
36          local ctl = (te ~= -1) and (getcatcode(te)==5) and (getcatcode(getcount('ltjlineendcomment'))==14)
37          -- Is the catcode of endline character is 5 (end-of-line)?
38          -- Is the catcode of \ltjlineendcomment (new comment char) is 14 (comment)?
39          if ((ct==11) or (ct==12)) and ctl then
40             if ltjc_is_japanese_char_curlist(c) then
41                buffer = buffer .. utfchar(getcount('ltjlineendcomment'))
42             end
43          end
44       end
45    end
46    stop_time_measure('inputbuf')
47    return buffer
48 end
49
50 luatexbase.add_to_callback('process_input_buffer',
51    add_comment,'ltj.process_input_buffer')
52
53 --EOF