OSDN Git Service

more unicode library -> utf
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 31 Dec 2020 12:51:41 +0000 (21:51 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 31 Dec 2020 12:51:41 +0000 (21:51 +0900)
test/test17-totenwidth.tex
test/test19-ivs.tex
tool/jfm-convert.lua

index 07ad828..a89067d 100644 (file)
@@ -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
index 3f28997..036b52a 100644 (file)
@@ -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)
index 66b73a0..5f2baa8 100755 (executable)
@@ -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] <ptex_jfm>\n'); 
+  stderr:write('Usage: texlua jfm-convert [-J|-U] <ptex_jfm>\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 <ptex_jfm>.\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