OSDN Git Service

round_threshold in vertical fonts
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 22 Apr 2020 06:36:22 +0000 (15:36 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 22 Apr 2020 06:36:22 +0000 (15:36 +0900)
src/jfm-ujisv.lua
src/ltj-setwidth.lua
test/test59-round_threshold.tex [new file with mode: 0644]

index ccae212..b2044bd 100644 (file)
@@ -28,6 +28,7 @@ local t = {
          [8] = { 0, 0, 0, kanjiskip_shrink=1 },
       },
       kern = { [307] = 0 },     
+      round_threshold = 0.01,
    },
 
    [1] = { -- 開き括弧類
index 0d684ef..c6fa235 100644 (file)
@@ -196,6 +196,11 @@ local function capsule_glyph_tate(p, met, char_data, head, dir)
       pwidth, ascender = feir.vheight[pc]*met.size, feir.vorigin[pc]*met.size
    end
    fwidth = fwidth or pwidth
+   if fwidth~=pwidth and char_data.round_threshold then
+      local frac = abs(pwidth / fwidth); 
+      local quot = floor(frac)
+      if frac-quot <char_data.round_threshold then fwidth = fwidth * quot end
+   end
    fshift.down = char_data.down; fshift.left = char_data.left
    fshift = call_callback("luatexja.set_width", fshift, met, char_data)
    local fheight = char_data.height or 0
diff --git a/test/test59-round_threshold.tex b/test/test59-round_threshold.tex
new file mode 100644 (file)
index 0000000..6e06670
--- /dev/null
@@ -0,0 +1,21 @@
+\documentclass{ltjsarticle}
+\usepackage[sourcehan-jp,nfssonly]{luatexja-preset}
+\begin{document}
+\lineskip0pt
+
+\setbox0=\hbox{\tate あ〳〵あ〱あ――あ}\leavevmode\vrule\copy0\vrule
+{\ttfamily\tiny\directlua{%
+  luatexja.ext_show_node(tex.getbox(0), '\string\\par> ', tex.print)
+}\par}
+
+\newpage
+\setbox0=\hbox{\yoko あ〳〵あ〱あ――あ}\par
+\hrule
+\copy0
+\hrule
+{\ttfamily\tiny\directlua{%
+  luatexja.ext_show_node(tex.getbox(0), '\string\\par> ', tex.print)
+}\par}
+
+\end{document}
+\bye