# Why doesn't my Chinese character display properly?

I'm trying to produce the character 𡰞, which is in unicode and as far as I'm able to ascertain included in my font HanaMinA. The character displays properly in Firefox as well as when I copy it into the .tex document. But in the PDF output, it's replaced by a square. Does anyone know what I'm doing wrong?

I've also tried with HanaMinB and with the font Han Nom A; still a square.

MWE:

\documentclass[utf8,12pt,letterpaper]{article}
\usepackage{xeCJK}
\setCJKmainfont{HanaMinA}
\begin{document}
這些字打的出來，問題是： %These character appear properly

𡰞 %This one does not
\end{document}

I'm compiling with xelatex.

-

The Unicode of the character 𡰞 is U+21C1E. So it is in font HanaMinB rather than HanaMinA.

There are two mechanisms to deal with such problems in xeCJK.

The first one is the fallback font feature. Say

\documentclass[12pt,letterpaper]{article}
\usepackage{xeCJK}

%% enable fallback font feature
\xeCJKsetup{AutoFallBack}

\setCJKmainfont{HanaMinA}

% set fallback fonts to HanaMinA'
\setCJKmainfont[FallBack]{HanaMinB}

\begin{document}
這些字打的出來，問題是： %These character appear properly

𡰞 % This one too
\end{document}

Another mechanism is more efficient. But it seems a little complicated. This mechanism can be specify particular fonts to some Unicode block.

\documentclass[12pt,letterpaper]{article}
\usepackage{xeCJK}

% declare a Unicode block for Supplementary Ideographic Plane (U+20000 - U+2FFFF)
% Font HanaMinB support CJK Ext-B, Ext-C and Ext-D.
\xeCJKDeclareSubCJKBlock{SIP}
{
"20000 -> "2A6DF , % CJK Unified Ideographs Extension B
"2A700 -> "2B73F , % CJK Unified Ideographs Extension C
"2B740 -> "2B81F   % CJK Unified Ideographs Extension D
}

\setCJKmainfont{HanaMinA}

% set fonts to block SIP' declared above
\setCJKmainfont[SIP]{HanaMinB}

\begin{document}
這些字打的出來，問題是： %These character appear properly

𡰞 % This one too
\end{document}
-
That works! Yeah I need the fallback for my Korean font. Thank you so much! – Mårten May 1 '14 at 11:15
Can we use this trick in LuaLaTeX somehow (without xeCJK)? – Malipivo May 7 '14 at 8:22

The xeCJK package provides a fallback option, so that characters not present in a "main" font can be taken from a "fallback" font:

\documentclass{article}
\usepackage[fallback]{xeCJK}
\setCJKmainfont{HanaMinA}
\setCJKfallbackfamilyfont{rm}{HanaMinB}
\begin{document}

𡰞 %This one too!
\end{document}

Here's the output I got:

-

The character is not in HanaMinA, but it is present in HanaMinB. Here's my experiment:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{HanaMinA}
\newfontfamily{\hanaminb}{HanaMinB}
\begin{document}
這些字打的出來，問題是： %These character appear properly

𡰞 %This one does not

{\hanaminb 𡰞} %This one does
\end{document}

Due to my lack of knowledge of Chinese, I can't understand how to make it available with xeCJK.

You see it in Firefox because it examines the system fonts to see which one contains the requested glyph. Indeed, after installing the two fonts, I can see the character in Safari; but if I copy paste it in UnicodeChecker, it correctly says it's from HanaMinB.

-
I see. It works for me too if I don't load xeCJK. Unfortunately, I need to load that package to sort out other font stuff, so this is kind of a conundrum... Thanks a lot though! – Mårten May 1 '14 at 10:28

I'm sorry I'm not an expert on CJKV typesetting, but I've tried to solve it anyway.

• I've installed HanaMinA.ttf, HanaMinB.ttf and HanaMinPlus.ttf from http://sourceforge.jp/projects/hanazono-font/releases/ among my system fonts.
• Using FontForge or FontLab Studio I am discovering that HanaMinPlus.ttf doesn't have such a glyph, HanaMinA.ttf does have some unassigned glyphs (there are several thousands of them), but I cannot say which, if any, it is. I haven't found it by simple browsing. In case you would find it, we only need to know the slot/index of that glyph, XeTeX has its command to display it (\XeTeXglyph). I don't know how to load a glyph in LuaTeX using its slot number/index which is outside regular Unicode ranges. It would be an interesting question on TeX.SX, I guess.
• I've found your glyph in HanaMinB.ttf, but the xeCJK package is somehow blocking/limiting the glyph ranges, so I used fontspec package directly.

I am enclosing a result of my efforts: how to display a glyph using its index/slot (\XeTeXglyph; plus a preview of that glyph in FontForge), its Unicode number (\char) and putting that glyph in the TeX document directly (we will see a rectangle in the source code as that glyph is not present in the used font at TeX.SX).

We run xelatex:

% run: xelatex mal-hanamin.tex
\documentclass[a4paper]{article}
\pagestyle{empty}
%\usepackage{xeCJK}
%\setCJKmainfont{HanaMinA}
\usepackage{xltxtra}
\usepackage{fontspec}
\setmainfont{HanaMinA}
\begin{document}
這些字打的出來，問題是：\par% These are common CJKV characters.
\XeTeXglyph35897\ % Here we use an index number to display a glyph.
{\setmainfont{HanaMinB}\char"021C1E% This is a Unicode number in use.
\ 𡰞} % And finally we are typesetting a character directly.
\end{document}

-
Thanks, that's really helpful for me in the future; I couldn't figure out how to verify whether a glyph was present or not, but now I know! But as the other answer showed, the whole thing unfortunately leaves me with a bigger problem. – Mårten May 1 '14 at 10:31