From 5f2ec21151c8d2cada12b6d856bdf420ad1ae069 Mon Sep 17 00:00:00 2001 From: Hironori Kitagawa Date: Thu, 31 Dec 2020 21:51:41 +0900 Subject: [PATCH] more unicode library -> utf --- test/test17-totenwidth.tex | 2 +- test/test19-ivs.tex | 4 ++-- tool/jfm-convert.lua | 12 +++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/test/test17-totenwidth.tex b/test/test17-totenwidth.tex index 07ad828..a89067d 100644 --- a/test/test17-totenwidth.tex +++ b/test/test17-totenwidth.tex @@ -50,7 +50,7 @@ function adjust_width_toten(head) local xc = x.head local xcs = tex.round(font.fonts[xc.font].size*0.5) -- 句読点の最大補正幅 - local xcc = unicode.utf8.char(xc.char) + local xcc = utf.char(xc.char) local cts = compute_total_stretched(p) if (xcc == ',' or xcc == '、' or xcc == '.' or xcc == '。') and cts>=0 then local ag = node.new(id_glue) -- additional glue diff --git a/test/test19-ivs.tex b/test/test19-ivs.tex index 3f28997..036b52a 100644 --- a/test/test19-ivs.tex +++ b/test/test19-ivs.tex @@ -12,8 +12,8 @@ local list_color = 'blue!50!black' -- リスト表示の色 local attr_curjfnt = luatexbase.attributes['ltj@curjfnt'] - local ubyte = unicode.utf8.byte - local uchar = unicode.utf8.char + local ubyte = utf.byte + local uchar = utf.char local sort = table.sort function list_ivs(s) local c = ubyte(s) diff --git a/tool/jfm-convert.lua b/tool/jfm-convert.lua index 66b73a0..5f2baa8 100755 --- a/tool/jfm-convert.lua +++ b/tool/jfm-convert.lua @@ -3,7 +3,7 @@ local stderr = io.stderr local function show_usage(s) stderr:write('Error: ' .. s .. '\n'); - stderr:write('Usage: jfm-convert [-J|-U] \n'); + stderr:write('Usage: texlua jfm-convert [-J|-U] \n'); stderr:write('-J: JIS mode, -U: UCS mode \n'); stderr:write(' * The output will be written to stdout.\n'); stderr:write(' * I do not read virtual fonts which corresponded to .\n'); @@ -13,20 +13,21 @@ local function show_usage(s) os.exit(1) end -require('unicode'); local uchar = unicode.utf8.char kpse.set_program_name('luatex') +require('lualibs'); local uchar = utf.char jisx0208 = require('ltj-jisx0208.lua').table_jisx0208_uptex local function pass_ucs(s) return "'" .. uchar(s) .. "'" end local function jis_to_ucs(s) - local a = jisx0208[s-0x2020] + local i = s - 0x2020 + local a = jisx0208[math.floor(i/256)*94+(i%256)-94] or 0 return a and pass_ucs(a) or string.format('0x%X',s+0x200000) end -------- 引数解釈 -------- -require('unicode') + local filename local mode @@ -207,7 +208,8 @@ jfm_ptex:close() if not mode then mode = jis_to_ucs for i=1, #all_ctype do - if not jisx0208[all_ctype[i]-0x2020] then + local i = all_ctype[i]-0x2020 + if not jisx0208[math.floor(i/256)*94+(i%256)-94] then mode = pass_ucs; break end end -- 2.11.0