OSDN Git Service

\CID for vertical form glyphs of non-AJ1 fonts
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 1 May 2019 08:15:54 +0000 (17:15 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 1 May 2019 08:15:54 +0000 (17:15 +0900)
src/addons/luatexja-ajmacros.sty
src/ltj-otf.lua
src/ltj-rmlgbm.lua
test/test10-otf.pdf
test/test10-otf.tex

index 3acc195..ca187cc 100644 (file)
        \@ajligdef{#1}{\number\@tempcnta}\advance\@tempcnta\@ne
        \expandafter\@ajligaturedef\fi}
 \def\@aj@ligdef#1#2#3{\expandafter\xdef\csname ajLig\@ajmojifam#1\endcsname
-       {\noexpand\CID{\noexpand\unless\noexpand\ifnum\noexpand\ltjgetparameter\noexpand{direction\noexpand}=3 #2\noexpand\else#3\noexpand\fi}}}
+       {\unexpanded{\unless\ifnum\ltjgetparameter{direction}=3 }%
+        \noexpand\CID{#2}\noexpand\else\noexpand\CID{#3}\noexpand\fi}}
 \def\@aj@ligaturedef#1{\ifx\@nil#1\else
        \@aj@ligdef{#1}{\number\@tempcnta}{\number\@tempcntb}%
        \advance\@tempcnta\@ne\advance\@tempcntb\@ne
index d083026..165bb75 100644 (file)
@@ -85,16 +85,40 @@ local function get_ucs_from_rmlgbm(c)
       local w = ltjr_cidfont_data["Adobe-Japan1"].characters[v]. tounicode
       -- must be non-nil!
       local i = string.len(w)
+      local r
       if i==4 then -- UCS2
-         return tonumber(w,16)
+         r = tonumber(w,16)
       elseif i==8 then
          i,w = tonumber(string.sub(w,1,4),16), tonumber(string.sub(w,-4),16)
          if (w>=0xD800) and (w<=0xDB7F) and (i>=0xDC00) and (i<=0xDFFF) then -- Surrogate pair
-            return (w-0xD800)*0x400 + (i-0xDC00)
+            r = (w-0xD800)*0x400 + (i-0xDC00)
          else
-            return 0
+            r = 0
          end
       end
+      if ltjr_cidfont_data["Adobe-Japan1"].shared.ltj_vert_table[r] then
+         -- CID が縦組用字形だった場合
+         local curjfnt_num = tex_get_attr((ltjd_get_dir_count()==dir_tate)
+                                        and attr_curtfnt or attr_curjfnt)
+         local t = identifiers[curjfnt_num]
+         if t.resources.sequences then
+            for _,i in pairs(t.resources.sequences) do
+               if (i.order[1]=='vert' or i.order[1]=='vrt2')
+                  and i.type == 'gsub_single' and i.steps then
+                  for _,j in pairs(i.steps) do
+                     if type(j)=='table' then 
+                        if type(j.coverage)=='table' then
+                           for i,k in pairs(j.coverage) do
+                              if i==r then return k end
+                           end
+                        end
+                     end
+                  end
+               end
+            end
+         end
+      end
+      return r
    end
 end
 
index abdece2..357560c 100644 (file)
@@ -185,7 +185,7 @@ do
       for i = 0,kx[2] do cidm[i] = -1 end
       open_cmap_file(kx[1] .. "-V", increment, tonumber, entry)
       for i,v in pairs(tt) do
-         ttv[i] =  cidmo[v.index]
+        ttv[i] =  cidmo[v.index] -- "unicode" of vertical variant
       end
 
       -- tounicode エントリ
index 3feb837..05a342c 100644 (file)
Binary files a/test/test10-otf.pdf and b/test/test10-otf.pdf differ
index 0f28fcd..f3adfba 100644 (file)
@@ -2,10 +2,10 @@
 \documentclass{ltjsarticle}
 \usepackage{luacode}
 \usepackage{luatexja-otf}
+\usepackage[sourcehan,nfssonly]{luatexja-preset}
 \begin{document}
 
-※このファイルはフォントを埋め込んでいないため,代替されるフォントによっては正しく
-表示されないでしょう.
+※このファイルは源ノ明朝・源ノ角ゴシックを埋め込んでいます.
 
 森\UTF{9DD7}外と内田百\UTF{9592}とが\UTF{9AD9}島屋に行くところを想像した。
 
 
 {\bf(速報)}世界陸上\CID{20660},\ajLig{ボルト}がフライングで失格.
 
+
+\ajLig{明治}\ajLig{大正}\ajLig{昭和}\ajLig{平成}\ajLig{令和}%
+\textgt{\ajLig{明治}\ajLig{大正}\ajLig{昭和}\ajLig{平成}\ajLig{令和}}
+
+\hbox{\tate
+  \ajLig{明治}\ajLig{大正}\ajLig{昭和}\ajLig{平成}\ajLig{令和}%
+  \textgt{\ajLig{明治}\ajLig{大正}\ajLig{昭和}\ajLig{平成}\ajLig{令和}}}
+
+
 \aj半角{半角カタカナひらがな} %←JFM の問題か,半角ひらがなが全角幅で出てしまう.
 ←luatexja-otf.sty内で,JFMの文法拡張を行いました.
 
@@ -51,13 +60,13 @@ luatexja-otf.styの下でも,TrueTypeフォントは正常に読めるよね
 
 \newpage
 
-\section*{Adobe-Japan1-6 全グリフ}
+\section*{Adobe-Japan1-7 全グリフ}
 
 {\footnotesize
 % 表の作成は Lua でサボってしまう.
 % \CID{0} (.notdef) は luaotfload がマッピングしてくれないみたい.
 \begin{luacode*}
-for i = 0, 23057 do
+for i = 0, 23059 do
    if i % 50 == 0 then
       tex.print(string.format("\\noindent%05d", i))
    end