OSDN Git Service

\ajLig{令和}, new lua func: luatexja.jfont.register_vert_replace
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 1 May 2019 00:15:50 +0000 (09:15 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 1 May 2019 00:15:50 +0000 (09:15 +0900)
src/addons/luatexja-ajmacros.sty
src/ltj-compat.lua
src/ltj-inputbuf.lua
src/ltj-jfont.lua
src/ltj-plain.sty
src/luatexja.lua
src/patches/lltjdefs.sty

index 8ca804f..3acc195 100644 (file)
@@ -2,7 +2,7 @@
 % luatexja-ajmacros.sty
 %
 % Original:
-% \ProvidesPackage{ajmacros}[2005/12/25 13:52 iNOUE Koich! <inoue@ma.ns.musashi-tech.ac.jp>]
+% \ProvidesPackage{ajmacros}[2019/04/01 21:00 iNOUE Koich! <inoue@ma.ns.musashi-tech.ac.jp>]
 %
 
 
 \@ajligdef{より}{12181}
 \@ajligdef{升}{16194}
 \@ajligdef{コト}{16195}
+\@aj@ligdef{令和}{23058}{23059}%AJ1-7
 %
 \def\@ajmojifam{○}
 \@tempcnta7613
index a4c1d68..bd79854 100644 (file)
@@ -18,6 +18,7 @@ end
 
 
 -- \kuten, \jis, \euc, \sjis, \ucs, \kansuji
+local utfchar=utf.char
 local function to_kansuji(num)
    if not num then num=0; return
    elseif num<0 then
@@ -25,7 +26,7 @@ local function to_kansuji(num)
    end
    local s = ""
    while num~=0 do
-      s = utf.char(
+      s = utfchar(
         ltjs.get_stack_table(luatexja.stack_table_index.KSJ + num%10,
                                '', tex.getcount('ltj@@stack'))) .. s
       num=math.floor(num/10)
index f8a7b57..e901d43 100644 (file)
@@ -6,9 +6,9 @@ luatexja.load_module('base');      local ltjb = luatexja.base
 luatexja.load_module('charrange'); local ltjc = luatexja.charrange
 
 require("unicode")
-local utflen = unicode.utf8.len
-local utfbyte = unicode.utf8.byte
-local utfchar = unicode.utf8.char
+local utflen = utf.len
+local utfbyte = utf.byte
+local utfchar = utf.char
 local node_new = node.new
 local node_free = node.free
 local id_glyph = node.id('glyph')
index 30a2468..c653c4a 100644 (file)
@@ -3,7 +3,7 @@
 --
 luatexbase.provides_module({
   name = 'luatexja.jfont',
-  date = '2019/04/30',
+  date = '2019/05/01',
   description = 'Loader for Japanese fonts',
 })
 
@@ -297,10 +297,10 @@ do
    end
 
 -- EXT
-   local utf8 = unicode.utf8
+   local utfbyte = utf.byte
    function luatexja.jfont.jfontdefX(g, dir, csname)
       jfm_dir, is_def_jfont = dir, true
-      cstemp = csname:sub( (utf8.byte(csname,1,1) == tex.escapechar) and 2 or 1, -1)
+      cstemp = csname:sub( (utfbyte(csname,1,1) == tex.escapechar) and 2 or 1, -1)
       cstemp = cstemp:sub(1, ((cstemp:sub(-1,-1)==' ') and (cstemp:len()>=2)) and -2 or -1)
       global_flag = g and '\\global' or ''
       tex.sprint(cat_lp, '\\expandafter\\font\\csname ',
@@ -1093,10 +1093,7 @@ do
      [0x300C]=0xFE41, [0x300D]=0xFE42, [0x300E]=0xFE43, [0x300F]=0xFE44,
      [0xFF3B]=0xFE47, [0xFF3D]=0xFE48, 
   }
-  local vert_jpotf_table = {
-     [0xFF0C]=0xFE11, [0xFF0E]=0xFE12,
-     [0x201C]=0x301D, [0x201D]=0x301F,
-  }
+  local vert_jpotf_table = {}
   local function add_vform(coverage, vform, ft, add_vert, jpotf_vert)
     if type(coverage)~='table' then return end
     for i,v in pairs(vert_form_table) do
@@ -1104,7 +1101,7 @@ do
     end
     if jpotf_vert then
       for i,v in pairs(vert_jpotf_table) do
-       if ft.characters[v] then  vform[i] = coverage[v] or v end
+       if ft.characters[v] then  vform[i] = coverage[v] or vform[v] or v end
       end
     end
     if add_vert then -- vert feature が有効にならない場合
@@ -1112,6 +1109,18 @@ do
     end
   end
 
+  local utfbyte, utfsub = utf.byte, utf.sub
+  luatexja.jfont.register_vert_replace = function(t)
+    for i,v in pairs(t) do
+      local ic = (type(i)=='number') and i or 
+        ((type(i)=='string') and utfbyte(utfsub(i,1,1)) or nil)
+      if ic then
+        vert_jpotf_table[ic] = (type(v)=='number') and v or 
+          ((type(v)=='string') and utfbyte(utfsub(v,1,1)) or nil)
+      end
+    end  
+  end
+
 luatexbase.add_to_callback(
    "luatexja.define_jfont",
    function (fmtable, fnum)
index 1409c35..4277998 100644 (file)
@@ -14,7 +14,7 @@
 \ifltj@in@latex                 %<*LaTeX>
   \NeedsTeXFormat{LaTeX2e}
   \PackageWarning{ltj-plain}{Don't load this package directly; load luatexja.sty instead.}
-  \ProvidesPackage{ltj-plain}[2019/02/11]
+  \ProvidesPackage{ltj-plain}[2019/05/01]
 \fi                             %</LaTeX>
 
 %%------------------
 \protected\def\@@end{%
   \directlua{luatexja.ext_cleanup()}\ltj@@orig@end}
 
+\directlua{luatexja.jfont.register_vert_replace{
+  [',']='、', ['.']='。', ['“']=0x301D, ['”']=0x301F,
+}}
+
 %%------------------ all done
 \ltj@plain@AtEnd
 \endinput
index 8fb24a8..9756ead 100644 (file)
@@ -400,7 +400,7 @@ local function get_attr_icflag(p)
 end
 
 local prefix, inner_depth
-
+local utfchar = utf.char
 local function debug_show_node_X(p,print_fn, limit)
    local k = prefix
    local s
@@ -409,7 +409,7 @@ local function debug_show_node_X(p,print_fn, limit)
    .. ' ' .. pt .. ' ' .. tostring(p.subtype) .. ' '
    if pt == 'glyph' then
       s = base .. ' ' .. 
-         (p.char>=0xF0000 and string.format('(U+%X)', p.char) or utf.char(p.char)) .. ' '
+         (p.char>=0xF0000 and string.format('(U+%X)', p.char) or utfchar(p.char)) .. ' '
          .. tostring(p.font) .. ' (' .. print_scaled(p.height) .. '+'
          .. print_scaled(p.depth) .. ')x' .. print_scaled(p.width)
       if p.xoffset~=0 or p.yoffset~=0 then
@@ -561,7 +561,7 @@ local function debug_show_node_X(p,print_fn, limit)
       end
       prefix = k;
    elseif pt=='math_char' then
-      s = base .. ' fam: ' .. p.fam .. ' , char = ' .. utf.char(p.char)
+      s = base .. ' fam: ' .. p.fam .. ' , char = ' .. utfchar(p.char)
       print_fn(s)
    elseif pt=='sub_box' or pt=='sub_mlist' then
       print_fn(base)
index 21f6c4c..91827a3 100644 (file)
@@ -3,7 +3,7 @@
 %
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lltjdefs}[2019/02/11 Default font settings of LuaTeX-ja]
+\ProvidesPackage{lltjdefs}[2019/05/01 Default font settings of LuaTeX-ja]
 
 \ifdefined\ltj@stdmcfont\else\def\ltj@stdmcfont{IPAExMincho}\fi
 \ifdefined\ltj@stdgtfont\else\def\ltj@stdgtfont{IPAExGothic}\fi
 \directlua{for x=128,255 do luatexja.math.is_math_letters[x] = true end}
 \protected\def\<{\ifvmode\leavevmode\fi\inhibitglue}
 
+\directlua{luatexja.jfont.register_vert_replace{
+  [',']='、', ['.']='。', ['“']=0x301D, ['”']=0x301F,
+}}
+
 % END OF FILE
 \endinput