1

I'm trying the example from How to use Chinese with lualatex? (TexLive 2014, updated to frozen):

\documentclass{article}
\usepackage{luatexja-fontspec}
\setmainjfont{FandolSong}
\begin{document}

在 Lua\TeX{} 中正常地使用中文。获得自动的\textbf{字体选择},标点“压缩”,以及正确的断行处理等特性。

\end{document}

I try to compile this with lualatex test.tex - but cannot, as it fails with:

...
(/media/texlive/2014/texmf-dist/tex/luatex/luatexja/ltj-rmlgbm.lua)
! LuaTeX error ...xlive/2014/texmf-dist/tex/luatex/luatexja/ltj-rmlgbm.lua:90: b
ad argument #1 to 'open' (string expected, got nil).
l.172 }

? 
(/media/texlive/2014/texmf-dist/tex/luatex/luatexja/ltj-base.sty)
! LuaTeX error [\directlua]:1: attempt to index field 'stack' (a nil value).
l.249   }
       %
? 
(/media/texlive/2014/texmf-dist/tex/luatex/luatexja/ltj-latex.sty
(/media/texlive/2014/texmf-dist/tex/luatex/luatexja/patches/lltjfont
.sty (/media/texlive/2014/texmf-dist/tex/latex/ms/everysel.sty)
ABD: EverySelectfont initializing macros)
...

What am I missing?

sdaau
  • 17,079

2 Answers2

1

Well, I think I got it. First, I added a print line to texmf-dist/tex/luatex/luatexja/ltj-rmlgbm.lua:90:

   local function open_cmap_file(name, inc, cid_dec, mke)
      print("open_cmap_file: name " .. name) -- added
      fh = io.open(kpse.find_file(name, 'cmap files'), "r")
      ....

... and realized it prints out: open_cmap_file: name UniJIS2004-UTF32-H. So I looked up:

$ tlmgr search --global --file UniJIS2004
...
adobemapping:
    texmf-dist/fonts/cmap/adobemapping/aj16/CMap/UniJIS2004-UTF16-H
    texmf-dist/fonts/cmap/adobemapping/aj16/CMap/UniJIS2004-UTF16-V
    texmf-dist/fonts/cmap/adobemapping/aj16/CMap/UniJIS2004-UTF32-H
    texmf-dist/fonts/cmap/adobemapping/aj16/CMap/UniJIS2004-UTF32-V
    texmf-dist/fonts/cmap/adobemapping/aj16/CMap/UniJIS2004-UTF8-H
    texmf-dist/fonts/cmap/adobemapping/aj16/CMap/UniJIS2004-UTF8-V
texworks:
    tlpkg/texworks/share/poppler/cMap/Adobe-Japan1/UniJIS2004-UTF16-H
    tlpkg/texworks/share/poppler/cMap/Adobe-Japan1/UniJIS2004-UTF16-V
    tlpkg/texworks/share/poppler/cMap/Adobe-Japan1/UniJIS2004-UTF32-H
    tlpkg/texworks/share/poppler/cMap/Adobe-Japan1/UniJIS2004-UTF32-V
    tlpkg/texworks/share/poppler/cMap/Adobe-Japan1/UniJIS2004-UTF8-H
    tlpkg/texworks/share/poppler/cMap/Adobe-Japan1/UniJIS2004-UTF8-V

... so I installed adobemapping with: tlmgr install adobemapping.

Now with this, compilation fails with:

luaotfload | db : Reload initiated (formats: otf,ttf,ttc,dfont); reason: "Font IPAExMincho not found.".
! Font \JY3/mc/m/n/10=IPAExMincho:jfm=ujis at 9.62219pt not loadable: metric dat
a not found or bad.
<to be read again>
relax
l.34 \kanjiencoding{JY3}\selectfont
                                 \adjustbaseline

... so I have a font problem now. I'm on Ubuntu 11.04, and have no idea which specifically Chinese fonts I'd have. Via texdoc luatexja, I realized the default for this package is indeed \def\ltj@stdmcfont{IPAExMincho} - but also, that one could include a luatexja.cfg file in the same directory as the .tex file; these contents are recommended in the manual:

\def\ltj@stdmcfont{psft:Ryumin-Light}
\def\ltj@stdgtfont{psft:GothicBBB-Medium}

... and with this - and without a \setmainjfont statement - the example compiles, although it seems some characters may be missing.

I had worked with simsun.ttc font before, so I wanted to try it. Note, if the font name is simsun.ttc, and it is not installed system-wide, but merely present (even as a symlink) in the same directory as the .tex file, then it can not be read in with a \setmainjfont{SimSun}, only with \setmainjfont{simsun}. However, for my particular version of simsun.ttc, I get this compile error:

luaotfload | db : Reload initiated (formats: otf,ttf,ttc,dfont); reason: 
"Font simsun not found.".(compiling luc: /media/texlive/2014/texmf-var/luatex
-cache/generic/fonts/otf/simsun.luc)(compiling luc: /home/user/.texlive
2014/texmf-var/luatex-cache/generic/fonts/otf/simsun.luc)(save: /media/
texlive/2014/texmf-var/luatex-cache/generic/fonts/otf/simsun.lua)(save: /media
/texlive/2014/texmf-var/luatex-cache/generic/fonts/otf/simsun.luc)
...
LaTeX Font Warning: Font shape `JY3/simsun(0)/bx/n' undefined
(Font)              using `JY3/simsun(0)/m/n' instead on input line 8.

[1{/media/texlive/2014/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./testb.aux)
...
</media/texlive/2014/texmf-dist/fonts/opentype/public/lm/lmroman10-re
gular.otf><./simsun.ttc(bad-fontname-simsun:-1)Invalid TTC index number

So, even if I had no problem with this font with pdflatex/{CJKutf8}, here simsun.ttc fails with Invalid TTC index number. Wish I knew a fix for this (maybe it's this bug: [NTG-context] Latest beta stops loading some ttc fonts)...

Then I found SimSun.ttf somewhere for download; removed simsun.ttc from the directory, and downloaded SimSun.ttf in the same directory (as the .tex file). Then I used \setmainjfont{SimSun} in the code instead -- and the example finally compiled, and all characters were apparently present in the PDF.

Not sure if this was all of it, but it looks like it so far...

sdaau
  • 17,079
1

I think it is a bug of luaotfload. You can update to TeX Live 2015 (in a few days) and the problem should have been fixed.

Leo Liu
  • 77,365