1

I'm re-asking an unanswered question from 2015. Here's what I'm using:

  • NOTO for normal, sans, and mono types via fontspec, aka \setmainfont
  • STIX Two for math via unicode-math, aka \setmathfont
  • siunitx with mode=match to avoid \qty causing a grotesque switch to STIX Two in the middle of a sentence.

NOTO text fonts lack a minus sign by design, so \qty{1}{\joule\per\meter} results in a rectangle before m.

Is there a way to substitute add a missing glyph (minus sign) to my serif font? unicode-math has a range= option to \setmathfont, but I can't pass that to \setmainfont.


Note: I'd like to use NOTO Sans Math for a consistent style, but I run into this problem.

  • Have you tried something like \usepackage{newunicodechar} and \newunicodechar{−}{\ensuremath{-}} and \renewcommand{\textminus}{\ensuremath{-}}? – frabjous May 31 '22 at 04:59
  • 1
    Can you add an example of your input: if I try to put something together, I do get the minus sign with the current siunitx release (2022-05-03 v3.1.1). – Joseph Wright May 31 '22 at 06:27

1 Answers1

1

I hope I understood you correctly. This code uses \setmainfont and \setmathfont. It also specifies that XITS Math (but could be any other font) is to be used for MINUS SIGN (U+2212), should it be missing from your main font:

\documentclass{article}

\usepackage{fontspec} \usepackage{unicode-math} \usepackage{newunicodechar}

\setmainfont{Noto Sans} \setmathfont{XITS Math} \newfontface{\xits}{XITS Math}

\iffontchar\font "2212\relax % do nothing if font has required glyph \else \newunicodechar{^^^^2212}{{\xits −}} % use double braces to limit the scope \fi

\begin{document}

\noindent HYPHEN-MINUS (U+002D) shown in \textbf{Noto Sans}: - \ MINUS SIGN (U+2212) shown in \textbf{XITS Math} (Text mode) −

\end{document}

Ingmar
  • 6,690
  • 5
  • 26
  • 47
  • 1
    Awesome, it works pretty well! I did the same for 2032 (prime). But it breaks for 00B1 (±); some error in \newunicodechar{^^^^00B1}{\stixmath ±}: "^^^^ needs four hex digits". Using ^^B1 didn't work either. Any idea? – Douglas Myers-Turnbull Jun 01 '22 at 06:00
  • Try lowercase b … That said, both ′ and ± seem to be part of Noto Sans already. Note: I also modified my code above slightly (added double braces to limit the scope of the font). – Ingmar Jun 01 '22 at 06:46