# Using LuaLaTeX + a custom font … How to let (non-spaced) Chinese characters break across lines

This question has a follow-up question, namely: "Change letter-spacing / tracking for punctuation marks (luatexja-fontspec)".

Imagine you are working in LuaLaTeX, and you want to use Chinese texts (often featuring long series of characters without spaces) to break across lines, so that the end-user can actually still read them. How would you do this?

According to an answer to the OP "How to use Chinese with lualatex?", one can simply use:

\usepackage{luatexja-fontspec}


However. This seems to overrule the use of a user-specified font, as would normally be customized by:

\setmainfont{...}

So my question is, in LuaLaTeX, how to both be able to:

• specify a custom font for the whole document,
• let the Chinese text line-break so as to make it readable?

# MWE (to be compiled with LuaLaTeX)

\documentclass[a4paper, fontsize=30pt]{scrreprt}

\usepackage{fontspec}
\setmainfont{HanWangKaiMediumChuIn_wp010-08}

\begin{document}

\end{document}


• Note: This MWE uses a custom font, namely HanWangKaiMediumChuIn_wp010-08.ttf, so one needs to to download it and install it in case one wishes to use the same.

P.S.: According to the luatexja-package documentation, changing the default fonts should be possible (e.g. using \def\ltj@stdmcfont{psft:...}), but I have not been able to do so. Perhaps this option is restricted to fonts which are part of the luatexja-package?

P.P.S: \usepackage{seqsplit} (see e.g. this answer to the OP "Automatic line breaking of long lines of text?") also doesn't seem to work for Chinese text.

• Please provide a compilable answer for potential answer writers to play with. Also, which non-default font would you like to use? – Mico Oct 1 '17 at 6:32
• @Mico Let me make a MWE then. I would like to use the font HanWangKaiMediumChuIn_wp010-08.ttf, so one needs to to download it in case one wishes to use the same. – Vincent Mia Edie Verheyen Oct 1 '17 at 6:35
• And, just for clarification: The title of your posting refers to Chinese characters, whereas the luatexja package is set to deal with Japanese text. Japanese texts, almost invariably, contain a mixture of kanjis (Chinese characters) and hiragana and katakana glyphs. Are you looking for a solution that deals exclusively with Chinese glyphs/characters, or will it be a mixture of kanji and kana glyphs? – Mico Oct 1 '17 at 6:37
• My particular purpose is to come up with a solution for Chinese characters only. I have just mentioned the luatexja package as per the mentioned answer to another OP, in which it was (simplistically) argued that: "the tools designed for Chinese and Japanese usually work the same." – Vincent Mia Edie Verheyen Oct 1 '17 at 6:39
• \usepackage{luatexja-fontspec}\setmainjfont{Microsoft YaHei} as suggested by @Mico works fine for me (at least I get line breaks, but I have no idea if they are sensible). – Ulrike Fischer Oct 1 '17 at 10:08

I don't have your font. But with another one \setmainjfont works fine. The spacing between the glyph can be extended with \ltjsetparameter{kanjiskip=...} (see 4.2 kanjiskip and xkanjiskip in the documentation):

\documentclass[a4paper, fontsize=30pt]{scrreprt}
\usepackage{luatexja-fontspec}
\setmainjfont{Microsoft YaHei}

\begin{document}

\ltjsetparameter{kanjiskip=20pt}

\end{document}


• However, it does not increase the inter-spacing of punctuation marks. Any solution there? Perhaps I could make a manual list of the necessary punctuation marks and thus automatically increase the spacing around them? – Vincent Mia Edie Verheyen Oct 2 '17 at 1:36
• Additionally, using your solution, the ability to switch fonts mid-document using \newfontfamily\myfont{...} seems to have been lost, but that is of course easily fixed by adding a j to end up with \newjfontfamily\myfont{...}. – Vincent Mia Edie Verheyen Oct 2 '17 at 2:13
• But a big problem remains, which is the spacing around punctuation marks, which is currently unaffected by your change in tracking. One can clearly notice this by using a large value, e.g. \ltjsetparameter{kanjiskip=100pt}. I have asked a follow-up question here. – Vincent Mia Edie Verheyen Oct 2 '17 at 2:58