I need to resolve absolute path to fonts:
\setmainjfont[
Path = \currfileabsdir,
UprightFont = fonts/HGS_Mincho/HGRMB.ttc,
BoldFont = fonts/HGS_Mincho/HGRME.ttc
]{HGS Mincho}
The solution \usepackage[abspath]{currfile} requires -recorder option, but I don't use console, and setup -recorder option is potentially unnecessary routine.
Other solution based on lfs library, but if we just use it as shown below, error will occur (at least, in Windows):
\edef\currfileabsdir{\directlua{tex.sprint(lfs.currentdir())}/}
! Undefined control sequence.
l.1 C:\Users
\i\Documents\TeX\LuaLaTeX_Development
l.6 ...sdir{\directlua{tex.sprint(lfs.currentdir())}
/}
It was recommended to use catcodes as shown below:
\edef\currfileabsdir{\directlua{tex.sprint(-2, lfs.currentdir())}/}
What really will be is backslashes will be removed from absolute path, so
C:Users/i/Documents/TeX/LuaLaTeX_Development/fonts/HGS_Mincho/HGRMB.ttc
becomes to
C:UsersmeDocumentsTeXLuaLaTeX_Development/fonts/HGS_Mincho/HGRMB.ttc
How I get correct absolute path to font?
Update: MWE with first suggested solution
\documentclass[a4paper, twoside]{ltjsarticle}
\usepackage{luatexja-fontspec}
\makeatletter
\edef\currfileabsdir{\directlua{tex.sprint(\the\catcodetable@string, lfs.currentdir())}/}
\makeatother
\setmainjfont[
Path = \currfileabsdir,
UprightFont = fonts/HGS_Mincho/HGRMB.ttc,
BoldFont = fonts/HGS_Mincho/HGRME.ttc
]{HGS Mincho}
\setsansjfont[
Path = \currfileabsdir,
UprightFont = fonts/HGS_Gothic/HGRGM.ttc,
BoldFont = fonts/HGS_Gothic/HGRGE.ttc,
]{HGS Gothic}
\begin{document}
日本語文字 Latin letters Кириллица
\end{document}
Error:
luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: "File not found: C:UsersiDocumentsTeXLuaLaTeX_Development/fonts/HGS_Mincho/HGRMB.ttc.".
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "fonts/HGS_Mincho/HGRMB.ttc" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
l.13 ]{HGS Mincho}

-2is hardcoded: https://github.com/TeX-Live/luatex/blob/eafe6e149e78c13abb435e5c1e06bb49aa59e414/source/texk/web2c/luatexdir/tex/textoken.h#L123 – Henri Menke Apr 01 '19 at 09:01