OSDN Git Service

Added tests
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 24 Jul 2019 21:17:36 +0000 (06:17 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 24 Jul 2019 21:17:36 +0000 (06:17 +0900)
src/ltj-jfont.lua
src/ltj-setwidth.lua
test/test51b-vorg.tex [new file with mode: 0644]

index b3d0fde..09a5677 100644 (file)
@@ -812,11 +812,11 @@ do
      local ascent = id.shared.rawdata.metadata.ascender
      local t_vorigin, t_ind_to_uni = {}, {}
      for i,v in pairs(id.shared.rawdata.descriptions) do
-        t_ind_to_uni[v.index] = i
-        if v.tsb then
-          local j = v.boundingbox[4] + v.tsb
-          if j~=ascent then print(i,j);t_vorigin[i]=j end
-        end
+       t_ind_to_uni[v.index] = i
+       if v.tsb then
+         local j = v.boundingbox[4] + v.tsb
+         if j~=ascent then t_vorigin[i]=j end
+       end
      end
      dest = dest or {}
      dest.ind_to_uni = t_ind_to_uni
@@ -890,63 +890,6 @@ do
    end
 end
 
-
-------------------------------------------------------------------------
--- calculate vadvance
-------------------------------------------------------------------------
-do
-   local function acc_feature(table_vadv, table_vorg, subtables, ft,  already_vert)
-      for char_num,v in pairs(ft.shared.rawdata.descriptions) do
-         if v.slookups then
-            for sn, sv in pairs(v.slookups) do
-               if subtables[sn] and type(sv)=='table' then
-                  if sv[4]~=0 then
-                     table_vadv[char_num]
-                        = (table_vadv[char_num] or 0) + sv[4]
-                  end
-                  if sv[2]~=0 and not already_vert then
-                     table_vorg[char_num]
-                        = (table_vorg[char_num] or 0) + sv[2]
-                  end
-               end
-            end
-         end
-      end
-   end
-
-luatexbase.add_to_callback(
-   "luatexja.define_jfont",
-   function (fmtable, fnum)
-      local vadv = {}; fmtable.v_advance = vadv
-      local vorg = {}; fmtable.v_origin = vorg
-      local ft = font_getfont(fnum)
-      local subtables = {}
-      if ft.specification then
-         for feat_name,v in pairs(ft.specification.features.normal) do
-            if v==true and ft.resources then
-               for _,i in pairs(ft.resources.sequences) do
-                  if i.order[1]== feat_name and i.type == 'gpos_single' and type(i.subtables)=='table' then
-                     for _,st in pairs(i.subtables) do
-                        subtables[st] = true
-                     end
-                  end
-               end
-            end
-         end
-         acc_feature(vadv, vorg, subtables, ft,
-                     ft.specification.features.normal.vrt2 or ft.specification.features.normal.vert)
-         for i,v in pairs(vadv) do
-            vadv[i]=vadv[i]/ft.units_per_em*fmtable.size
-         end
-         for i,v in pairs(vorg) do
-            vorg[i]=vorg[i]/ft.units_per_em*fmtable.size
-         end
-      end
-      return fmtable
-   end, 'ltj.v_advance', 1
-)
-end
-
 ------------------------------------------------------------------------
 -- make table of vertical glyphs which does not covered by vert feature
 -- nor UTR#50
index 43004f4..4e312be 100644 (file)
@@ -177,8 +177,7 @@ local function capsule_glyph_tate(p, met, char_data, head, dir)
    local ascent, descent = met.ascent, met.descent
    local fwidth, pwidth = char_data.width
    do
-      local pf = getfont(p)
-      local pc = getchar(p)
+      local pf, pc = getfont(p), getchar(p)
       local feir = ltjf_font_extra_info[pf]
       if feir and feir.rotation and met.vert_activated then
         if feir.rotation[pc] then
@@ -186,10 +185,10 @@ local function capsule_glyph_tate(p, met, char_data, head, dir)
         end
       end
       local ident = fonts.hashes.identifiers[pf]
-      pwidth = (ident.descriptions and ident.descriptions[pc] 
+      pwidth = (ident.descriptions and ident.descriptions[pc]
          and ident.descriptions[pc].vheight
          and ident.descriptions[pc].vheight / ident.units * met.size)
-        or (ident.metadata and ident.metadate.defaultvheight) or (ascent+descent)
+         or (ident.metadata and ident.metadata.defaultvheight) or (ascent+descent)
       ascent = feir.vorigin[pc] and (feir.vorigin[pc] / ident.units * met.size) or ascent
    end
    fwidth = fwidth or pwidth
diff --git a/test/test51b-vorg.tex b/test/test51b-vorg.tex
new file mode 100644 (file)
index 0000000..24c780d
--- /dev/null
@@ -0,0 +1,56 @@
+\documentclass{ltjarticle}
+\usepackage[margin=15mm,centering]{geometry}
+\usepackage{lltjext,xcolor}
+%\usepackage{lua-visual-debug}
+\begin{document}
+\def\V#1{%
+  \setbox0=\hbox to0pt{\yoko\hss\smash{#1} \kern-\zw\hss}%
+  \box0\relax
+}
+\def\YL{\rlap{\textcolor{magenta}{\vrule height 0.0625mm depth 0.0625mm width 500pt}}}
+\def\TEST#1{\smash{\hbox to 0pt{\tate%
+  \kern120pt\YL%
+  \tfont\A=#1:jfm=ujisv at 10pt\A
+  \jfont\B=#1:jfm=ujis at 10pt\B
+  国\V T\V y\V p\V o\V g\V r\V a\V p\V h\V y国\V Q国
+  \V J国\V{\ltjjachar`Å}国
+  \hss}}%
+  \smash{\hbox to 0pt{\tate%
+  \hbox to 120pt{\ttfamily #1\hss}\YL%
+  \tfont\A=#1:jfm=ujisv at 10pt\A
+  国Typography国Q国J国\ltjjachar`Å国\ltjjachar"3031国
+  \hss}}\quad}
+
+\def\TL{\smash{\rlap{\hbox to 0pt{\tate%
+  \kern120pt\color{cyan}\kern-0.0625mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+  \vrule height 400pt depth 0pt width 0.125mm\kern\dimexpr10pt-0.125mm%
+}}}}
+
+\leavevmode
+\TL
+\TEST{IPAExMincho}
+\TEST{HiraMinProN-W3}
+\TEST{KozMinPr6N-Regular}
+\TEST{YuMincho}
+\TEST{SourceHanSerif-Regular}
+
+\end{document}
+