8

I want to use phoenician letters (unicode range 0x10900 to 0x1091F) as variable names. (If your browser font supports them, these are the characters: 𐀂,𐀁,𐀀, and so on.)

I am using LuaTeX with unicode-math, but the phoenician script is not supported.

I have two fonts installed on my system that have phoenician characters, but I cannot get them to show up in math mode.

Here is a minimal (non-)working example:

\documentclass{article}
\usepackage{unicode-math}

\setmathfont{latinmodern-math.otf}
\setmathfont{Noto Sans Phoenician}[range={"10900}]
\newcommand\alf{{\fontspec{Noto Sans Phoenician}𐀀}} % this is the literal aleph character

\begin{document}
Getting an \alf to show up in text is easy.
However, a math mode \(-\alf-\) does not work.
\end{document}

This produces no errors, but the following pdf output, because it tries to typeset the math mode aleph in latin modern, finds out that the font does not have it, and substitutes it with nothing. TeX output

The same happens with

\newcommand\alf{{\fontspec{Noto Sans Phoenician}\symbol{"10900}}} 

and with

\usepackage{phoenician}
\newcommand\alf{{\phncfamily\MAaleph}}

I figured that since LaTeX does not understand that I want to use these as math symbols, I would make them math symbols via

\DeclareSymbolFont{phoenician}{T1}{phnc}{m}{n}
\Umathcode"10900=0 \csname symphoenician\endcsname\space "10900

which compiles fine and then of course does nothing because phnc is a T1 font and has nothing in the 0x10900 slot.

Is there some way for me to assign a math code to the symbols that phnc provides? Or is that simply not possible and I would have to design my own math font containing these glyphs?

Of course, there is always the hack of wrapping the symbol inside a \textup{}, but as far as I understand, that messes with spacing. Is that correct?

3 Answers 3

6

You could probably convince unicode-math that this is a mathematical symbol in some way, but the alternative is to go down your \DeclareSymbolFont / \Umathcode path with the OpenType font (these use the TU encoding):

\documentclass{article}
\usepackage{unicode-math}

% First for the text case. Not needed if it shouldn't be used for text
\newfontfamily\phoenicianfamily[
  Renderer=HarfBuzz, % Could be omitted or replaced by = Node, shouldn't matter that much
  Script=Phoenician, % Always specify the right script.
  % Language= % I have no idea which language you are using.
]{Noto Sans Phoenician}
\newcommand\textalf{{\phoenicianfamily 𐀀}} % this is the literal aleph character

% Now for the math case
\setmathfont{latinmodern-math.otf}
\newfontfamily\thisNameWontBeUsedAnyway[
  Renderer=Base, % Required for Math fonts
  Script=Phoenician, % would be Script=Math if this were a math font
  NFSSFamily=nsphoenician, % Which name to use for the NFSS font
]{Noto Sans Phoenician}
\DeclareSymbolFont{phoenician}{TU}{nsphoenician}{m}{n}% Here you find the NFSS name again
\Umathcode"10900=0 \csname symphoenician\endcsname\space "10900

\begin{document}
Getting an \textalf\ to show up in text is easy.
However, a math mode \(-𐀀-\) does not work.
\end{document}

enter image description here

1
  • This is exactly what I was looking for, thank you! For anyone coming across this in the future, note that there is a neat code snippet in this other texexchange question to automate the process for an entire unicode range. Commented May 3, 2022 at 21:36
3

Wrap the text-mode commands in \textnormal, which works in both text and math mode.

\documentclass{article}
\usepackage{unicode-math}

\setmathfont{latinmodern-math.otf}
% Availabe for free at:
% https://fonts.google.com/noto/specimen/Noto+Sans+Phoenician
\newfontface\phoenicianfont{Noto Sans Phoenician}
\newcommand\alf{\textnormal{\phoenicianfont\symbol{"10900}}} % Alf, 𐀀

\begin{document}
Getting an \alf to show up in text is easy.
However, a math mode \(-\alf-\) does now work.
\end{document}

Noto Sans Phoenician sample

Note that you either want to write {\alf} in text mode, or define it with xspace, or it will gobble the space after it, as it does here.

If you wanted different commands for text and math mode (for example, to use the current weight and shape setting in text mode but not math mode), you would define the separate versions using \ifmmode.

Finally, to be able to use the literal Unicode 𐀀 character, define it with newunicodechar:

\documentclass{article}
\usepackage{unicode-math}
\usepackage{newunicodechar}

\setmathfont{latinmodern-math.otf}
% Availabe for free at:
% https://fonts.google.com/noto/specimen/Noto+Sans+Phoenician
\newfontface\phoenicianfont{Noto Sans Phoenician}
\newcommand\alf{\textnormal{\phoenicianfont\symbol{"10900}}} % Alf, 𐀀

\newunicodechar{𐀀}{\alf}

\begin{document}
Getting an 𐀀 to show up in text is easy.
However, a math mode \(- 𐀀 -\) does now work.
\end{document}
1

In alternative to the \DeclareSymbolFont strategy, you can use newunicodechar:

\documentclass{article}
\usepackage{unicode-math}
\usepackage{amsmath}
\usepackage{newunicodechar}

\setmathfont{latinmodern-math.otf}
\newfontface\phoenician{Noto Sans Phoenician}

\newunicodechar{𐀀}{\text{\phoenician 𐀀}}
\newcommand{\alf}{𐀀}

\begin{document}

Getting an 𐀀 to show up in text is easy. Also \alf.

However, a math mode \(𐀀-x_{𐀀}\) does not work. Also \(\alf\).

\end{document}

enter image description here

1
  • 2
    In this case, it’s fine because \newfontface doesn’t come in multiple weights or shapes, but you don’t normally want to use \text in math mode. The formatting of the surrounding text, such as italics in a theorem statement, will bleed through.
    – Davislor
    Commented May 3, 2022 at 23:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .