0

Is it possible to approximate fake "optical sizes" with fontspec using a font which doesn't have this feature (in my case, Cambria)?

The use case here is that I'm writing a scientific text with lots of in-text \textsuperscript and \textsubscript which would really benefit from being slightly bolder.

  • 1
    The short answer is: "no" :) – Will Robertson May 8 '18 at 7:48
  • 1
    The slightly longer answer is that MAYBE with adjusting weight and width just a little you could create something that wasn't terribly ugly on first glance. – Will Robertson May 8 '18 at 7:49
  • Thanks, that's what I suspected, but for some reason I can't get a minimal working example for FakeBold with Cambria. Is this expected? – Mathieu May 8 '18 at 8:15
  • See my comment to Henri Menke's answer below: the current default macOS PDF engine fails to render FakeBold. Oh well... – Mathieu May 8 '18 at 11:56
  • Update: the PDFkit bug appears to have been fixed in the latest macOS update (10.13.4, 17E199). – Mathieu May 12 '18 at 13:07
4

If it is only about the super and subscript, you could redefine those macros to add boldening using PDF literals.

\documentclass{article}
\usepackage{letltxmacro}
\usepackage{fontspec}

\LetLtxMacro\oldtextsuperscript\textsuperscript
\LetLtxMacro\oldtextsubscript\textsubscript

\newcommand\embolden[1]{%
  \special{pdf:literal 2 Tr 1.0 w}% adjust the 1.0
  #1%
  \special{pdf:literal 0 Tr 0 w}%
}
\DeclareRobustCommand\textsuperscript[1]{%
  \oldtextsuperscript{\embolden{#1}}%
}
\DeclareRobustCommand\textsubscript[1]{%
  \oldtextsubscript{\embolden{#1}}%
}

\begin{document}

Hello\textsuperscript{Hello}
World\textsubscript{World}

\end{document}

enter image description here

  • Wow, thanks, that solves quite nicely my original issue. On the flip side, I've discovered that macOS High Sierra's Preview.app completely fails to render your emboldened sub/superscripts as intended. The fault lies with Preview, though, not with XeLaTeX, because Adobe Reader renders everything correctly. – Mathieu May 8 '18 at 11:55
  • @Mathieu — oh, that's a real shame. I'd heard the new PDF rendering engine in macOS was a step backwards... – Will Robertson May 8 '18 at 13:38
  • Amazingly, this bug appears to have been fixed in the latest macOS update (10.13.4, 17E199). Thanks again. – Mathieu May 12 '18 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.