By the way, default JFM and SourceHanSansJP will result in strange kerning when two-em-dashes are used.
https://i.loli.net/2020/04/21/WEhDqLP8JxR2kzj.png
% !TeX program = LuaLaTeX
% !TeX encoding = UTF-8
\documentclass{article}
\usepackage{luatexja}
\usepackage{luatexja-ruby}
\usepackage[no-math]{luatexja-fontspec}
\defaultjfontfeatures{
Script=CJK
}
\setmainjfont{SourceHanSansJP}[
UprightFont=*-Normal,
BoldFont=*-Medium,
Language=Japanese
]
\title{Test}
\begin{document}
\maketitle
\ruby{明日}{あした}——明日
\end{document}
Usually, dimensions which are specified by a JFM and actual glyph dimensions differs. For example, "明" in SourceHanSansJP-Normal 10pt has only 7.92pt in height and 0.81pt in depth, but the default JFM requests 8.8pt in height and 1.2pt in depth.
To cope with the difference, LuaTeX-ja sometimes adds \norule (invisible rule), or packs the character into another box. But the JFM "prop" does not specify any dimensions, so "明日" with this JFM takes less vertical space than it with the default JFM.
\documentclass{article}
\usepackage{luatexja-fontspec}
\setsansfont{SourceHanSansJP-Normal}[Script=CJK, Language=Japanese]
\setmainjfont{SourceHanSansJP-Normal}[Script=CJK, Language=Japanese]
% Note that Japanese fonts are scaled by 0.962216 by default
%\tracingonline1\showboxbreadth10000 \showboxdepth10000
\begin{document}
% as ALchars
\setbox0\hbox{\sffamily \ltjalchar`明}%
\typeout{(\the\ht0:\the\dp0)}% ==> (7.92pt:0.81pt)
% as JAchars; default JFM (ujis)
\setbox0\hbox{明}%
\typeout{(\the\ht0:\the\dp0)}% ==> (8.46753pt:1.15466pt)
%\showbox0
% ==> \hbox(8.46753+1.15466)x9.6222, direction TLT
% .\whatsit4=[]
% .\norule(8.46753+1.15466)x0.0
% .\JY3/SourceHanSansJP-Normal(1)/m/n/10 明
% as JAchars; JFM=prop
\addjfontfeatures{YokoFeatures={JFM=prop}}
\setbox0\hbox{明}%
\typeout{(\the\ht0:\the\dp0)}% ==> (7.62077pt:0.7794pt)
%\showbox0
% ==> \hbox(7.62077+0.7794)x9.6222, direction TLT
% .\whatsit4=[]
% .\JY3/SourceHanSansJP-Normal(2)/m/n/10 明
\end{document}
Perhaps saving the following file as jfm-propw.lua, and specifying "JFM=propw" should resolve the issue.
luatexja.jfont.define_jfm {
dir = 'yoko',
zw = 1.0, zh = 1.0,
[0] = {
align = 'left', left = 0.0, down = 0.0,
-- width = 'prop', height = 'prop', depth = 'prop', italic=0.0, <= jfm-prop.lua
width = 'prop', height = 0.88, depth = 0.12, italic=0.0,
}
}
This behavior is not inspected in the default font.
luatexja-fontspec does not execute \setmainjfont etc. automatically.
By the way, default JFM and SourceHanSansJP will result in strange kerning when two-em-dashes are used.
It seems that two em-dashes makes a ligature, which is assigned to U+F0554 by LuaTeX. Because this codepoint belongs to a Private Use Area, we cannot specify its width in JFM. I'll think another approach.
Thanks.
luatexja.jfont.define_jfm {
dir = 'yoko',
zw = 1.0, zh = 1.0,
[0] = {
align = 'left', left = 0.0, down = 0.0,
-- width = 'prop', height = 'prop', depth = 'prop', italic=0.0, <= jfm-prop.lua
width = 'prop', height = 0.88, depth = 0.12, italic=0.0,
}
}
That's exactly how I workaround this issue so far. I just replaced the contents of jfm-prop.lua with that, but I do not think that is an elegant solution. Will this JFM file be added to luatexja in the future? Adding this file to my own environment is not a satisfatory way because some of these documents are open-sourced, while adding this file to each document seems inconvenient.
Also, I wonder why I did not encounter this issue prior to texlive 2019?
Will this JFM file be added to luatexja in the future?
Yes, as jfm-prop.lua (old) and jfm-propw.lua (as above comment).
It seems that two em-dashes makes a ligature, which is assigned to U+F0554 by LuaTeX.
Oh, I confused a horizontal bar (U+2015, ―) and an em-dash (U+2014, ―).
If I configure with \ltjdefcharrange{4}{—} , then the two em dashes do not have the same width as two characters do. Actually I am using luatexja in a Chinese document (with SourceHanSansCN of course) , and that is why I use U+2014 instead of U+2015.
% !TeX program = LuaLaTeX
% !TeX encoding = UTF-8
\documentclass{article}
\usepackage{luatexja}
\usepackage{luatexja-ruby}
\usepackage[no-math]{luatexja-fontspec}
\defaultjfontfeatures{
YokoFeatures={JFM=prop},
Script=CJK
}
\setmainjfont{SourceHanSansJP}[
UprightFont=*-Normal,
BoldFont=*-Medium,
Language=Japanese
]
\title{Test}
\begin{document}
\maketitle
文字二つの幅です。(JAChar)
——ダッシュの幅です。(JAChar)
\ltjdefcharrange{4}{`—}
——ダッシュの幅です。(ALChar)
\end{document}
Oh, I see. I added new character classes for U+2014, U+2E3A (two-em dash), U+2E3B (three-em dash). So commit 1a54137 should fix the issue, I hope.
I uploaded new version (20200517.0) to CTAN, so I close this ticket.
Comment out the line "YokoFeatures={JFM=prop}," and the ruby will be placed correctly. This behavior is not inspected in the default font. The bug seems to have been introduced since texlive 2020.
Here are the correct output and incorrect output:
https://i.loli.net/2020/04/21/8ylSbJMIVAcHTDL.png https://i.loli.net/2020/04/21/5LOxbIFU6vWYmnr.png
% !TeX program = LuaLaTeX % !TeX encoding = UTF-8 \documentclass{article} \usepackage{luatexja} \usepackage{luatexja-ruby} \usepackage[no-math]{luatexja-fontspec} \usepackage[a5paper]{geometry} \defaultjfontfeatures{ YokoFeatures={JFM=prop}, Script=CJK } \setmainjfont{SourceHanSansJP}[ UprightFont=*-Normal, BoldFont=*-Medium, Language=Japanese ] \title{Test} \begin{document} \maketitle \begin{abstract} \ruby{明日}{あした} \end{abstract} \ruby{明日}{あした} \end{document}