XeLaTex 不顯示 unicode 符號

XeLaTex 不顯示 unicode 符號

當使用 TexShop 和 XeLaTex 引擎排版時,為什麼我的 Unicode 西洋棋騎士符號沒有出現在產出中?

在 TexShop 我有

\documentclass[12pt]{article}
\begin{document}
1.  ♘ df5 
\end{document}

當我使用 XeLaTeX 引擎點擊「排版」按鈕時,我沒有收到任何錯誤訊息,但 pdf 檔案沒有國際象棋騎士符號 ♘,它只有「1.df5」。我正在使用 MacTex 2022。

答案1

xelatex報告

Missing character: There is no ♘ (U+2658) in font [lmroman12-regular]:mapping=t
ex-text;!

而拉丁現代則沒有這個特色。

 albatross U+2658

將列出您與該角色一起安裝的字體

在此輸入影像描述

\documentclass[12pt]{article}
\usepackage{fontspec}
\setmainfont{Segoe UI Symbol}
\begin{document}
1.  ♘ df5 
\end{document}

答案2

您可以使用您喜歡的字體,不一定是具有該字元的字體。

例如,該字元出現在 Menlo(一種 macOS 字體)中。

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}

\setmainfont{Libertinus Serif} % or whatever font you like

\newfontface{\chesspiecesfont}{Menlo}
\NewDocumentCommand{\chesspiece}{m}{{\chesspiecesfont#1}}

\newunicodechar{♔}{\chesspiece{♔}}
\newunicodechar{♕}{\chesspiece{♕}}
\newunicodechar{♖}{\chesspiece{♖}}
\newunicodechar{♗}{\chesspiece{♗}}
\newunicodechar{♘}{\chesspiece{♘}}
\newunicodechar{♙}{\chesspiece{♙}}
\newunicodechar{♚}{\chesspiece{♚}}
\newunicodechar{♛}{\chesspiece{♛}}
\newunicodechar{♜}{\chesspiece{♜}}
\newunicodechar{♝}{\chesspiece{♝}}
\newunicodechar{♞}{\chesspiece{♞}}
\newunicodechar{♟}{\chesspiece{♟}}

\begin{document}

1. ♘ df5

2. ♚ df5

♔♕♖♗♘♙♚♛♜♝♞♟

\end{document}

在此輸入影像描述

如果你用 Apple Symbols 取代 Menlo,你會得到

在此輸入影像描述

你明白我為什麼要間接進行。我們希望將這些部分移動到基線上,而不是低於它,並稍微減少字體大小。

將相關行更改為

\newfontface{\chesspiecesfont}{Apple Symbols}[Scale=0.9]
\NewDocumentCommand{\chesspiece}{m}{\raisebox{\depth}{\chesspiecesfont#1}}

輸出將是

在此輸入影像描述

相關內容