ソースコードの管理場所
Revisão | c72bf6803b32910786d62b8cd329acbaedbcc157 (tree) |
---|---|
Hora | 2018-02-18 08:59:56 |
Autor | Hironori Kitagawa <h_kitagawa2001@yaho...> |
Commiter | Hironori Kitagawa |
stopped to use module(), which is removed in Lua 5.2. (WIP)
@@ -3,12 +3,10 @@ | ||
3 | 3 | -- |
4 | 4 | luatexbase.provides_module({ |
5 | 5 | name = 'luatexja.charrange', |
6 | - date = '2017/05/05', | |
6 | + date = '2018/02/18', | |
7 | 7 | description = 'Handling the range of Japanese characters', |
8 | 8 | }) |
9 | -module('luatexja.charrange', package.seeall) | |
10 | -local err, warn, info, log = luatexbase.errwarinf(_NAME) | |
11 | - | |
9 | +luatexja.charrange = {} | |
12 | 10 | luatexja.load_module('base'); local ltjb = luatexja.base |
13 | 11 | |
14 | 12 | local getchar = node.direct.getchar |
@@ -16,7 +14,8 @@ local has_attr = node.direct.has_attribute | ||
16 | 14 | local has_attr_node = node.has_attribute |
17 | 15 | local tex_getattr = tex.getattribute |
18 | 16 | |
19 | -ATTR_RANGE = 7 | |
17 | +local ATTR_RANGE = 7 | |
18 | +luatexja.charrange.ATTR_RANGE = ATTR_RANGE | |
20 | 19 | local jcr_cjk, jcr_noncjk = 0, 1 |
21 | 20 | local floor = math.floor |
22 | 21 | local pow = math.pow |
@@ -40,8 +39,7 @@ pow_table[31*ATTR_RANGE] = pow(2, 31) | ||
40 | 39 | -- external 217, 1 2 216, 217 and (out of range): 'other' |
41 | 40 | |
42 | 41 | -- initialize |
43 | -jcr_table_main = {} | |
44 | -local jcr_table_main = jcr_table_main | |
42 | +local jcr_table_main = {} | |
45 | 43 | local ucs_out = 0x110000 |
46 | 44 | |
47 | 45 | for i=0x0 ,0x7F do jcr_table_main[i]=-1 end |
@@ -49,7 +47,7 @@ for i=0x80 ,0xFF do jcr_table_main[i]=1 end | ||
49 | 47 | for i=0x100,ucs_out-1 do jcr_table_main[i]=0 end |
50 | 48 | |
51 | 49 | -- EXT: add characters to a range |
52 | -function add_char_range(b,e,ind) -- ind: external range number | |
50 | +function luatexja.charrange.add_char_range(b,e,ind) -- ind: external range number | |
53 | 51 | if not ind or ind<0 or ind>31*ATTR_RANGE then -- 0 はエラーにしない(隠し) |
54 | 52 | ltjb.package_error('luatexja', |
55 | 53 | "invalid character range number (" .. ind .. ")", |
@@ -70,32 +68,30 @@ function add_char_range(b,e,ind) -- ind: external range number | ||
70 | 68 | end |
71 | 69 | end |
72 | 70 | |
73 | -function char_to_range(c) -- return the external range number | |
71 | +function luatexja.charrange.char_to_range(c) -- return the external range number | |
74 | 72 | local r = jcr_table_main[ltjb.in_unicode(c, false)] or 217 |
75 | 73 | return (r~=0) and r or 217 |
76 | 74 | end |
77 | 75 | |
78 | -function get_range_setting(i) -- i: internal range number | |
76 | +local function get_range_setting(i) -- i: internal range number | |
79 | 77 | return floor(tex_getattr(kcat_attr_table[i])/pow_table[i])%2 |
80 | 78 | end |
81 | 79 | |
82 | 80 | -- glyph_node p は和文文字か? |
83 | -function is_ucs_in_japanese_char_node(p) | |
81 | +function luatexja.charrange.is_ucs_in_japanese_char(p) | |
84 | 82 | return nfn_table[jcr_table_main[c or p.char]](p) |
85 | 83 | end |
86 | -is_ucs_in_japanese_char = is_ucs_in_japanese_char_node | |
87 | --- only ltj-otf.lua uses this version | |
88 | 84 | |
89 | -function is_ucs_in_japanese_char_direct(p ,c) | |
85 | +function luatexja.charrange.is_ucs_in_japanese_char_direct(p ,c) | |
90 | 86 | return fn_table[jcr_table_main[c or getchar(p)]](p) |
91 | 87 | end |
92 | 88 | |
93 | -function is_japanese_char_curlist(c) -- assume that c>=0x80 | |
89 | +function luatexja.charrange.is_japanese_char_curlist(c) -- assume that c>=0x80 | |
94 | 90 | return get_range_setting(jcr_table_main[c])~= jcr_noncjk |
95 | 91 | end |
96 | 92 | |
97 | 93 | -- EXT |
98 | -function toggle_char_range(g, i) -- i: external range number | |
94 | +function luatexja.charrange.toggle_char_range(g, i) -- i: external range number | |
99 | 95 | if type(i)~='number' then |
100 | 96 | ltjb.package_error('luatexja', |
101 | 97 | "invalid character range number (" .. tostring(i).. ")", |
@@ -112,4 +108,6 @@ function toggle_char_range(g, i) -- i: external range number | ||
112 | 108 | end |
113 | 109 | end |
114 | 110 | |
111 | +luatexja.charrange.get_range_setting=get_range_setting | |
112 | + | |
115 | 113 | -- EOF |
@@ -1,58 +0,0 @@ | ||
1 | --- | |
2 | --- luatexja/infomute.lua | |
3 | --- | |
4 | -luatexbase.provides_module({ | |
5 | - name = 'luatexja.infomute', | |
6 | - date = '2011/06/05', | |
7 | - description = '', | |
8 | -}) | |
9 | -module('luatexja.infomute', package.seeall) | |
10 | -local err, warn, info, log = luatexbase.errwarinf(_NAME) | |
11 | - | |
12 | --------------------- | |
13 | ---! luatexbase.module_info() で特定のモジュールの情報出力だけ | |
14 | ---! 抑止したい. | |
15 | - | |
16 | -local org_texio = texio | |
17 | -local patch_applied = false | |
18 | -local info_mute = {} | |
19 | - | |
20 | -local function pick_module_name(line) | |
21 | - local mod | |
22 | - if line:sub(1, 7) == "Module " then | |
23 | - local s, e = line:find(" ", 8, true) | |
24 | - if s then mod = line:sub(8, s - 1) end | |
25 | - elseif line:sub(1, 1) == "(" then | |
26 | - local s, e = line:find(")", 2, true) | |
27 | - if s then mod = line:sub(2, s - 1) end | |
28 | - end | |
29 | - return mod | |
30 | -end | |
31 | - | |
32 | -local function patched_write_nl(line, ...) | |
33 | - local mod = pick_module_name(line) | |
34 | - if not (mod and info_mute[mod]) then | |
35 | - org_texio.write_nl(line, ...) | |
36 | - end | |
37 | -end | |
38 | - | |
39 | -local new_texio = setmetatable({ write_nl = patched_write_nl }, | |
40 | - { __index = org_texio }) | |
41 | -local org_fenv = getfenv(luatexbase.module_info) | |
42 | - | |
43 | -local function apply_patch() | |
44 | - setfenv(luatexbase.module_info, | |
45 | - setmetatable({ texio = new_texio }, { __index = org_fenv })) | |
46 | - patch_applied = true | |
47 | -end | |
48 | - | |
49 | ---! モジュール mod の情報出力を抑止する. | |
50 | -function add_mute(mod) | |
51 | - info_mute[mod] = true | |
52 | - if not patch_applied then | |
53 | - apply_patch() | |
54 | - end | |
55 | -end | |
56 | - | |
57 | --------------------- all done | |
58 | --- EOF |
@@ -3,11 +3,10 @@ | ||
3 | 3 | -- |
4 | 4 | luatexbase.provides_module({ |
5 | 5 | name = 'luatexja.jfmglue', |
6 | - date = '2017/05/05', | |
7 | - description = 'Insertion process of JFM glues and kanjiskip', | |
6 | + date = '2018/02/18', | |
7 | + description = 'Insertion process of JFM glues, [x]kanjiskip and others', | |
8 | 8 | }) |
9 | -module('luatexja.jfmglue', package.seeall) | |
10 | -local err, warn, info, log = luatexbase .errwarinf(_NAME) | |
9 | +luatexja.jfmglue = luatexja.jfmglue or {} | |
11 | 10 | |
12 | 11 | luatexja.load_module('base'); local ltjb = luatexja.base |
13 | 12 | luatexja.load_module('stack'); local ltjs = luatexja.stack |
@@ -16,9 +15,8 @@ luatexja.load_module('direction'); local ltjd = luatexja.direction | ||
16 | 15 | luatexja.load_module('setwidth'); local ltjw = luatexja.setwidth |
17 | 16 | local pairs = pairs |
18 | 17 | |
19 | -local nullfunc = function(n) return n end | |
20 | -local to_node = node.direct.tonode | |
21 | -local to_direct = node.direct.todirect | |
18 | +--local to_node = node.direct.tonode | |
19 | +--local to_direct = node.direct.todirect | |
22 | 20 | |
23 | 21 | local setfield = node.direct.setfield |
24 | 22 | local setglue = luatexja.setglue |
@@ -88,7 +86,7 @@ local list_dir | ||
88 | 86 | local capsule_glyph |
89 | 87 | local tex_dir |
90 | 88 | local attr_ablshift |
91 | -local set_np_xspc_jachar | |
89 | +local set_np_xspc_jachar, set_np_xspc_alchar | |
92 | 90 | local set_np_xspc_jachar_hbox |
93 | 91 | |
94 | 92 | local ltjs_orig_char_table = ltjs.orig_char_table |
@@ -147,7 +145,7 @@ end | ||
147 | 145 | end |
148 | 146 | |
149 | 147 | -- 「異なる JFM」の間の調整方法 |
150 | -diffmet_rule = math.two_paverage | |
148 | +luatexja.jfmglue.diffmet_rule = math.two_paverage | |
151 | 149 | function math.two_add(a,b) return a+b end |
152 | 150 | function math.two_average(a,b) return (a+b)*0.5 end |
153 | 151 | function math.two_paverage(a,b) return (a+b)/2 end |
@@ -165,6 +163,7 @@ local non_ihb_flag -- JFM グルー挿入抑止用 flag | ||
165 | 163 | -------------------- hlist 内の文字の検索 |
166 | 164 | |
167 | 165 | local first_char, last_char, find_first_char |
166 | +local check_box_high | |
168 | 167 | do |
169 | 168 | local ltjd_glyph_from_packed = ltjd.glyph_from_packed |
170 | 169 | local function check_box(box_ptr, box_end) |
@@ -235,7 +234,7 @@ local function check_box(box_ptr, box_end) | ||
235 | 234 | return found_visible_node |
236 | 235 | end |
237 | 236 | |
238 | -function check_box_high(Nx, box_ptr, box_end) | |
237 | +check_box_high = function (Nx, box_ptr, box_end) | |
239 | 238 | first_char = nil; last_char = nil; find_first_char = true |
240 | 239 | if check_box(box_ptr, box_end) then |
241 | 240 | local first_char = first_char |
@@ -555,7 +554,7 @@ end | ||
555 | 554 | -- We think that "Np is a Japanese character" if Np.met~=nil, |
556 | 555 | -- "Np is an alphabetic character" if Np.pre~=nil, |
557 | 556 | -- "Np is not a character" otherwise. |
558 | -after_hlist = nil -- global | |
557 | +local after_hlist = nil -- global | |
559 | 558 | local after_alchar, extract_np |
560 | 559 | do |
561 | 560 | local PRE = luatexja.stack_table_index.PRE |
@@ -601,6 +600,7 @@ do | ||
601 | 600 | |
602 | 601 | -- 欧文文字のデータを取得 |
603 | 602 | local floor = math.floor |
603 | + local nullfunc = function(n) return n end | |
604 | 604 | function set_np_xspc_alchar(Nx, c,x, lig) |
605 | 605 | if c~=-1 then |
606 | 606 | local f = (lig ==1) and nullfunc or node_tail |
@@ -648,7 +648,7 @@ end | ||
648 | 648 | |
649 | 649 | -------------------- 最下層の処理 |
650 | 650 | |
651 | -luatexbase.create_callback('luatexja.adjust_jfmglue', 'simple', nullfunc) | |
651 | +luatexbase.create_callback('luatexja.adjust_jfmglue', 'simple', function(n) return n end) | |
652 | 652 | |
653 | 653 | -- change penalties (or create a new penalty, if needed) |
654 | 654 | local function handle_penalty_normal(post, pre, g) |
@@ -749,11 +749,11 @@ do | ||
749 | 749 | local bk_ak = 2*id_kern - id_kern |
750 | 750 | |
751 | 751 | local function blend_diffmet(b, a, rb, ra) |
752 | - return round(diffmet_rule((1-rb)*b+rb*a, (1-ra)*b+ra*a)) | |
752 | + return round(luatexja.jfmglue.diffmet_rule((1-rb)*b+rb*a, (1-ra)*b+ra*a)) | |
753 | 753 | end |
754 | 754 | calc_ja_ja_aux = function (gb, ga, db, da) |
755 | - if diffmet_rule ~= math.two_pleft and diffmet_rule ~= math.two_pright | |
756 | - and diffmet_rule ~= math.two_paverage then | |
755 | + if luatexja.jfmglue.diffmet_rule ~= math.two_pleft and diffmet_rule ~= math.two_pright | |
756 | + and luatexja.jfmglue.diffmet_rule ~= math.two_paverage then | |
757 | 757 | db, da = 0, 1 |
758 | 758 | end |
759 | 759 | if not gb then |
@@ -808,6 +808,7 @@ end | ||
808 | 808 | local null_skip_table = {0, 0, 0} |
809 | 809 | -- get kanjiskip |
810 | 810 | local get_kanjiskip, kanjiskip_jfm_flag |
811 | +local get_kanjiskip_low | |
811 | 812 | local calc_ja_ja_glue |
812 | 813 | do |
813 | 814 | local KANJI_SKIP = luatexja.icflag_table.KANJI_SKIP |
@@ -891,6 +892,7 @@ end | ||
891 | 892 | -- get xkanjiskip |
892 | 893 | local get_xkanjiskip, xkanjiskip_jfm_flag |
893 | 894 | local get_xkanjiskip_normal, get_xkanjiskip_jfm |
895 | +local get_xkanjiskip_low | |
894 | 896 | do |
895 | 897 | local XKANJI_SKIP = luatexja.icflag_table.XKANJI_SKIP |
896 | 898 | local XKANJI_SKIP_JFM = luatexja.icflag_table.XKANJI_SKIP_JFM |
@@ -1063,6 +1065,7 @@ end | ||
1063 | 1065 | |
1064 | 1066 | |
1065 | 1067 | -- Nq が前側のクラスタとなることによる修正 |
1068 | +local adjust_nq | |
1066 | 1069 | do |
1067 | 1070 | local adjust_nq_aux = { |
1068 | 1071 | [id_glyph] = function() after_alchar(Nq) end, -- after_alchar(Nq) |
@@ -1075,7 +1078,7 @@ do | ||
1075 | 1078 | end, |
1076 | 1079 | } |
1077 | 1080 | |
1078 | - function adjust_nq() | |
1081 | + adjust_nq=function() | |
1079 | 1082 | local x = adjust_nq_aux[Nq.id] |
1080 | 1083 | if x then x() end |
1081 | 1084 | end |
@@ -1213,7 +1216,7 @@ end | ||
1213 | 1216 | -------------------- 外部から呼ばれる関数 |
1214 | 1217 | |
1215 | 1218 | -- main interface |
1216 | -function main(ahead, mode, dir) | |
1219 | +function luatexja.jfmglue.main(ahead, mode, dir) | |
1217 | 1220 | if not ahead then return ahead end |
1218 | 1221 | --luatexja.ext_show_node_list(to_node(ahead ), '>B ', print) |
1219 | 1222 | --print() |
@@ -1254,7 +1257,7 @@ do | ||
1254 | 1257 | local node_write = node.direct.write |
1255 | 1258 | |
1256 | 1259 | -- \inhibitglue |
1257 | - function create_inhibitglue_node() | |
1260 | + function luatexja.jfmglue.create_inhibitglue_node() | |
1258 | 1261 | local tn = node_new(id_whatsit, sid_user) |
1259 | 1262 | setfield(tn, 'user_id', IHB) |
1260 | 1263 | setfield(tn, 'type', 100) |
@@ -1264,7 +1267,7 @@ do | ||
1264 | 1267 | |
1265 | 1268 | -- Node for indicating beginning of a paragraph |
1266 | 1269 | -- (for ltjsclasses) |
1267 | - function create_beginpar_node() | |
1270 | + function luatexja.jfmglue.create_beginpar_node() | |
1268 | 1271 | local tn = node_new(id_whatsit, sid_user) |
1269 | 1272 | setfield(tn, 'user_id', BPAR) |
1270 | 1273 | setfield(tn, 'type', 100) |
@@ -1273,7 +1276,7 @@ do | ||
1273 | 1276 | end |
1274 | 1277 | |
1275 | 1278 | -- Node for indicating a head/end of a box |
1276 | - function create_boxbdd_node() | |
1279 | + function luatexja.jfmglue.create_boxbdd_node() | |
1277 | 1280 | local tn = node_new(id_whatsit, sid_user) |
1278 | 1281 | setfield(tn, 'user_id', BOXB) |
1279 | 1282 | setfield(tn, 'type', 100) |
@@ -1336,3 +1339,6 @@ do | ||
1336 | 1339 | "luatexja.beginpar.np_info_after", 1) |
1337 | 1340 | |
1338 | 1341 | end |
1342 | + | |
1343 | +luatexja.jfmglue.after_hlist = after_hlist | |
1344 | +luatexja.jfmglue.check_box_high = check_box_high | |
\ No newline at end of file |
@@ -3,10 +3,9 @@ | ||
3 | 3 | -- |
4 | 4 | luatexbase.provides_module({ |
5 | 5 | name = 'luatexja.jfont', |
6 | - date = '2017/09/04', | |
6 | + date = '2018/02/18', | |
7 | 7 | description = 'Loader for Japanese fonts', |
8 | 8 | }) |
9 | -module('luatexja.jfont', package.seeall) | |
10 | 9 | |
11 | 10 | luatexja.load_module('base'); local ltjb = luatexja.base |
12 | 11 | luatexja.load_module('charrange'); local ltjc = luatexja.charrange |
@@ -31,12 +30,14 @@ local id_glyph = node.id('glyph') | ||
31 | 30 | local id_kern = node.id('kern') |
32 | 31 | local cat_lp = luatexbase.catcodetables['latex-package'] |
33 | 32 | local FROM_JFM = luatexja.icflag_table.FROM_JFM |
33 | + | |
34 | +luatexja.jfont = luatexja.jfont or {} | |
34 | 35 | ------------------------------------------------------------------------ |
35 | 36 | -- LOADING JFM |
36 | 37 | ------------------------------------------------------------------------ |
37 | 38 | |
38 | -metrics={} -- this table stores all metric informations | |
39 | -font_metric_table={} -- [font number] -> jfm_name, jfm_var, size | |
39 | +local metrics={} -- this table stores all metric informations | |
40 | +local font_metric_table={} -- [font number] -> jfm_name, jfm_var, size | |
40 | 41 | |
41 | 42 | luatexbase.create_callback("luatexja.load_jfm", "data", function (ft, jn) return ft end) |
42 | 43 |
@@ -54,7 +55,7 @@ local function norm_val(a) | ||
54 | 55 | end |
55 | 56 | end |
56 | 57 | |
57 | -function define_jfm(t) | |
58 | +function luatexja.jfont.define_jfm(t) | |
58 | 59 | local real_char -- Does current character class have the 'real' character? |
59 | 60 | if t.dir~=jfm_dir then |
60 | 61 | defjfm_res= nil; return |
@@ -234,7 +235,8 @@ end | ||
234 | 235 | luatexbase.create_callback("luatexja.find_char_class", "data", |
235 | 236 | function (arg, fmtable, char) |
236 | 237 | return 0 |
237 | - end) | |
238 | + end) | |
239 | +local find_char_class | |
238 | 240 | do |
239 | 241 | local start_time_measure = ltjb.start_time_measure |
240 | 242 | local stop_time_measure = ltjb.stop_time_measure |
@@ -287,7 +289,7 @@ do | ||
287 | 289 | |
288 | 290 | -- EXT |
289 | 291 | local utf8 = unicode.utf8 |
290 | - function jfontdefX(g, dir, csname) | |
292 | + function luatexja.jfont.jfontdefX(g, dir, csname) | |
291 | 293 | jfm_dir, is_def_jfont = dir, true |
292 | 294 | cstemp = csname:sub( (utf8.byte(csname,1,1) == tex.escapechar) and 2 or 1, -1) |
293 | 295 | cstemp = cstemp:sub(1, ((cstemp:sub(-1,-1)==' ') and (cstemp:len()>=2)) and -2 or -1) |
@@ -301,7 +303,7 @@ do | ||
301 | 303 | -- EXT |
302 | 304 | local identifiers = fonts.hashes.identifiers |
303 | 305 | local provides_feature = luaotfload.aux.provides_feature |
304 | - function jfontdefY() | |
306 | + function luatexja.jfont.jfontdefY() | |
305 | 307 | local j = load_jfont_metric(jfm_dir) |
306 | 308 | local fn = font.id(cstemp) |
307 | 309 | local f = font_getfont(fn) |
@@ -352,12 +354,12 @@ do | ||
352 | 354 | local dir_tate = luatexja.dir_table.dir_tate |
353 | 355 | local tex_get_attr = tex.getattribute |
354 | 356 | -- PUBLIC function |
355 | - function get_zw() | |
357 | + function luatexja.jfont.get_zw() | |
356 | 358 | local a = font_metric_table[ |
357 | 359 | tex_get_attr((get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)] |
358 | 360 | return a and a.zw or 0 |
359 | 361 | end |
360 | - function get_zh() | |
362 | + function luatexja.jfont.get_zh() | |
361 | 363 | local a = font_metric_table[ |
362 | 364 | tex_get_attr((get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)] |
363 | 365 | return a and a.zw or 0 |
@@ -451,25 +453,25 @@ end | ||
451 | 453 | do |
452 | 454 | -- these function are called from ltj-latex.sty |
453 | 455 | local fenc_list, kyenc_list, ktenc_list = {}, {}, {} |
454 | - function add_fenc_list(enc) fenc_list[enc] = 'true ' end | |
455 | - function add_kyenc_list(enc) kyenc_list[enc] = 'true ' end | |
456 | - function add_ktenc_list(enc) ktenc_list[enc] = 'true ' end | |
457 | - function is_kyenc(enc) | |
456 | + function luatexja.jfont.add_fenc_list(enc) fenc_list[enc] = 'true ' end | |
457 | + function luatexja.jfont.add_kyenc_list(enc) kyenc_list[enc] = 'true ' end | |
458 | + function luatexja.jfont.add_ktenc_list(enc) ktenc_list[enc] = 'true ' end | |
459 | + function luatexja.jfont.is_kyenc(enc) | |
458 | 460 | tex.sprint(cat_lp, '\\let\\ifin@\\if' .. (kyenc_list[enc] or 'false ')) |
459 | 461 | end |
460 | - function is_ktenc(enc) | |
462 | + function luatexja.jfont.is_ktenc(enc) | |
461 | 463 | tex.sprint(cat_lp, '\\let\\ifin@\\if' .. (ktenc_list[enc] or 'false ')) |
462 | 464 | end |
463 | - function is_kenc(enc) | |
465 | + function luatexja.jfont.is_kenc(enc) | |
464 | 466 | tex.sprint(cat_lp, '\\let\\ifin@\\if' |
465 | 467 | .. (kyenc_list[enc] or ktenc_list[enc] or 'false ')) |
466 | 468 | end |
467 | 469 | |
468 | 470 | local kfam_list, Nkfam_list = {}, {} |
469 | - function add_kfam(fam) | |
471 | + function luatexja.jfont.add_kfam(fam) | |
470 | 472 | kfam_list[fam]=true |
471 | 473 | end |
472 | - function search_kfam(fam, use_fd) | |
474 | + function luatexja.jfont.search_kfam(fam, use_fd) | |
473 | 475 | if kfam_list[fam] then |
474 | 476 | tex.sprint(cat_lp, '\\let\\ifin@\\iftrue '); return |
475 | 477 | elseif Nkfam_list[fam] then |
@@ -491,20 +493,20 @@ do | ||
491 | 493 | end |
492 | 494 | end |
493 | 495 | local ffam_list, Nffam_list = {}, {} |
494 | - function is_ffam(fam) | |
496 | + function luatexja.jfont.is_ffam(fam) | |
495 | 497 | tex.sprint(cat_lp, '\\let\\ifin@\\if' .. (ffam_list[fam] or 'false ')) |
496 | 498 | end |
497 | - function add_ffam(fam) | |
499 | + function luatexja.jfont.add_ffam(fam) | |
498 | 500 | ffam_list[fam]='true ' |
499 | 501 | end |
500 | - function search_ffam_declared() | |
502 | + function luatexja.jfont.search_ffam_declared() | |
501 | 503 | local s = '' |
502 | 504 | for i,_ in pairs(fenc_list) do |
503 | 505 | s = s .. '\\cdp@elt{' .. i .. '}' |
504 | 506 | end |
505 | 507 | tex.sprint(cat_lp, s) |
506 | 508 | end |
507 | - function search_ffam_fd(fam) | |
509 | + function luatexja.jfont.search_ffam_fd(fam) | |
508 | 510 | if Nffam_list[fam] then |
509 | 511 | tex.sprint(cat_lp, '\\let\\ifin@\\iffalse '); return |
510 | 512 | else |
@@ -521,14 +523,13 @@ end | ||
521 | 523 | ------------------------------------------------------------------------ |
522 | 524 | -- ALTERNATE FONTS |
523 | 525 | ------------------------------------------------------------------------ |
524 | -alt_font_table = {} | |
525 | -local alt_font_table = alt_font_table | |
526 | +local alt_font_table = {} | |
526 | 527 | local attr_curaltfnt = {} |
527 | 528 | local ucs_out = 0x110000 |
528 | 529 | |
529 | 530 | ------ for TeX interface |
530 | 531 | -- EXT |
531 | -function set_alt_font(b,e,ind,bfnt) | |
532 | +function luatexja.jfont.set_alt_font(b,e,ind,bfnt) | |
532 | 533 | -- ind: 新フォント, bfnt: 基底フォント |
533 | 534 | if b>e then b, e = e, b end |
534 | 535 | if b*e<=0 then |
@@ -562,7 +563,7 @@ function set_alt_font(b,e,ind,bfnt) | ||
562 | 563 | end |
563 | 564 | |
564 | 565 | -- EXT |
565 | -function clear_alt_font(bfnt) | |
566 | +function luatexja.jfont.clear_alt_font(bfnt) | |
566 | 567 | if alt_font_table[bfnt] then |
567 | 568 | local t = alt_font_table[bfnt] |
568 | 569 | for i,_ in pairs(t) do t[i]=nil; end |
@@ -570,7 +571,7 @@ function clear_alt_font(bfnt) | ||
570 | 571 | end |
571 | 572 | |
572 | 573 | ------ used in ltjp.suppress_hyphenate_ja callback |
573 | -function replace_altfont(pf, pc) | |
574 | +function luatexja.jfont.replace_altfont(pf, pc) | |
574 | 575 | local a = alt_font_table[pf] |
575 | 576 | return a and a[pc] or pf |
576 | 577 | end |
@@ -580,7 +581,7 @@ end | ||
580 | 581 | local alt_font_table_latex = {} |
581 | 582 | |
582 | 583 | -- EXT |
583 | -function clear_alt_font_latex(bbase) | |
584 | +function luatexja.jfont.clear_alt_font_latex(bbase) | |
584 | 585 | local t = alt_font_table_latex[bbase] |
585 | 586 | if t then |
586 | 587 | for j,v in pairs(t) do t[j] = nil end |
@@ -588,7 +589,7 @@ function clear_alt_font_latex(bbase) | ||
588 | 589 | end |
589 | 590 | |
590 | 591 | -- EXT |
591 | -function set_alt_font_latex(b,e,ind,bbase) | |
592 | +function luatexja.jfont.set_alt_font_latex(b,e,ind,bbase) | |
592 | 593 | -- ind: Alt font の enc/fam/ser/shape, bbase: 基底フォントの enc/fam/ser/shape |
593 | 594 | if b>e then b, e = e, b end |
594 | 595 | if b*e<=0 then |
@@ -630,17 +631,17 @@ do | ||
630 | 631 | local alt_font_base, alt_font_base_num |
631 | 632 | local aftl_base |
632 | 633 | -- EXT |
633 | - function does_alt_set(bbase) | |
634 | + function luatexja.jfont.does_alt_set(bbase) | |
634 | 635 | aftl_base = alt_font_table_latex[bbase] |
635 | 636 | tex.sprint(cat_lp, '\\if' .. (aftl_base and 'true' or 'false')) |
636 | 637 | end |
637 | 638 | -- EXT |
638 | - function print_aftl_address() | |
639 | + function luatexja.jfont.print_aftl_address() | |
639 | 640 | tex.sprint(cat_lp, ';ltjaltfont' .. tostring(aftl_base):sub(8)) |
640 | 641 | end |
641 | 642 | |
642 | 643 | -- EXT |
643 | - function output_alt_font_cmd(dir, bbase) | |
644 | + function luatexja.jfont.output_alt_font_cmd(dir, bbase) | |
644 | 645 | alt_font_base = bbase |
645 | 646 | if dir == 't' then |
646 | 647 | alt_font_base_num = tex.getattribute(attr_curtfnt) |
@@ -660,7 +661,7 @@ do | ||
660 | 661 | end |
661 | 662 | |
662 | 663 | -- EXT |
663 | - function pickup_alt_font_a(size_str) | |
664 | + function luatexja.jfont.pickup_alt_font_a(size_str) | |
664 | 665 | local t = alt_font_table_latex[alt_font_base] |
665 | 666 | if t then |
666 | 667 | for i,v in pairs(t) do |
@@ -679,7 +680,7 @@ do | ||
679 | 680 | end |
680 | 681 | |
681 | 682 | -- EXT |
682 | - function pickup_alt_font_b(afnt_num, afnt_base) | |
683 | + function luatexja.jfont.pickup_alt_font_b(afnt_num, afnt_base) | |
683 | 684 | local t = alt_font_table[alt_font_base_num] |
684 | 685 | local ac = font_getfont(afnt_num).characters |
685 | 686 | if not t then t = {}; alt_font_table[alt_font_base_num] = t end |
@@ -703,7 +704,7 @@ end | ||
703 | 704 | -- 終了時に各種ノードを破棄 |
704 | 705 | ------------------------------------------------------------------------ |
705 | 706 | do |
706 | - function cleanup_size_cache() | |
707 | + function luatexja.jfont.cleanup_size_cache() | |
707 | 708 | --local gs, ke = 0, 0 |
708 | 709 | for _,n in pairs(metrics) do |
709 | 710 | for i,t in pairs(n.size_cache) do |
@@ -724,8 +725,8 @@ end | ||
724 | 725 | ------------------------------------------------------------------------ |
725 | 726 | -- 追加のフォント情報 |
726 | 727 | ------------------------------------------------------------------------ |
727 | -font_extra_info = {} | |
728 | -local font_extra_info = font_extra_info -- key: fontnumber | |
728 | +local font_extra_info = {} | |
729 | +luatexja.jfont.font_extra_info= font_extra_info -- key: fontnumber | |
729 | 730 | local font_extra_basename = {} -- key: basename |
730 | 731 | |
731 | 732 | local list_rotate_glyphs |
@@ -1154,7 +1155,7 @@ do | ||
1154 | 1155 | end |
1155 | 1156 | end |
1156 | 1157 | -- EXT: italic correction |
1157 | - function append_italic() | |
1158 | + function luatexja.jfont.append_italic() | |
1158 | 1159 | local p = to_direct(tex.nest[tex.nest.ptr].tail) |
1159 | 1160 | local TEMP = node_new(id_kern) |
1160 | 1161 | if p and getid(p)==id_glyph then |
@@ -1181,3 +1182,7 @@ do | ||
1181 | 1182 | end |
1182 | 1183 | end |
1183 | 1184 | |
1185 | +luatexja.jfont.metrics = metrics | |
1186 | +luatexja.jfont.font_metric_table = font_metric_table | |
1187 | +luatexja.jfont.find_char_class = find_char_class | |
1188 | + |
@@ -3,13 +3,12 @@ | ||
3 | 3 | -- |
4 | 4 | luatexbase.provides_module({ |
5 | 5 | name = 'luatexja.ruby', |
6 | - date = '2017/05/05', | |
6 | + date = '2018/02/18', | |
7 | 7 | description = 'Ruby annotation', |
8 | 8 | }) |
9 | -module('luatexja.ruby', package.seeall) | |
10 | -local err, warn, info, log = luatexbase.errwarinf(_NAME) | |
11 | - | |
9 | +luatexja.ruby = {} | |
12 | 10 | luatexja.load_module('stack'); local ltjs = luatexja.stack |
11 | +luatexja.load_module('base'); local ltjb = luatexja.base | |
13 | 12 | |
14 | 13 | local to_node = node.direct.tonode |
15 | 14 | local to_direct = node.direct.todirect |
@@ -74,7 +73,7 @@ local RUBY_POST = luatexja.userid_table.RUBY_POST | ||
74 | 73 | ---------------------------------------------------------------- |
75 | 74 | do |
76 | 75 | local getbox = node.direct.getbox |
77 | - function cpbox() return node_copy(getbox(0)) end | |
76 | + function luatexja.ruby.cpbox() return node_copy(getbox(0)) end | |
78 | 77 | end |
79 | 78 | |
80 | 79 | ---------------------------------------------------------------- |
@@ -119,9 +118,9 @@ end | ||
119 | 118 | |
120 | 119 | |
121 | 120 | -- 実行回数 + ルビ中身 から uniq_id を作る関数 |
122 | -old_break_info = {} -- public, 前 run 時の分割情報 | |
121 | +local old_break_info = {} -- public, 前 run 時の分割情報 | |
123 | 122 | local cache_handle |
124 | -function read_old_break_info() | |
123 | +function luatexja.ruby.read_old_break_info() | |
125 | 124 | if tex.jobname then |
126 | 125 | local fname = tex.jobname .. '.ltjruby' |
127 | 126 | local real_file = kpse.find_file(fname) |
@@ -269,11 +268,11 @@ local function texiface_low(rst, rtlr, rtlp) | ||
269 | 268 | end |
270 | 269 | |
271 | 270 | -- rst: table |
272 | -function texiface(rst, rtlr, rtlp) | |
271 | +function luatexja.ruby.texiface(rst, rtlr, rtlp) | |
273 | 272 | if #rtlr ~= #rtlp then |
274 | 273 | for i=1, #rtlr do node_free(rtlr[i]) end |
275 | 274 | for i=1, #rtlp do node_free(rtlp[i]) end |
276 | - luatexja.base.package_error('luatexja-ruby', | |
275 | + ltjb.package_error('luatexja-ruby', | |
277 | 276 | 'Group count mismatch between the ruby and\n' .. |
278 | 277 | 'the body (' .. #rtlr .. ' != ' .. #rtlp .. ').', |
279 | 278 | '') |