latex3 / fontspec

Font selection in LaTeX for XeTeX and LuaTeX
http://latex3.github.io/fontspec/
LaTeX Project Public License v1.3c
277 stars 34 forks source link

Wishlist: baseline adjustments for FakeBold #447

Closed callegar closed 3 years ago

callegar commented 3 years ago

Description

FakeBold is an artificial font transformation and as such it will always represent a compromise. However, it can be quite useful when you miss a real bold version of the font you are using. There is usefulness also with unicode math fonts, since only XITS has a bold math version (e.g., if you need to put math in headings, abstracts typeset in bold or if you have some special notation that uses bold).

The issue with fake bold is that as a side effect of how it operates, it affects the font size and the baseline: the font becomes bigger and the baseline gets pushed down a bit. Would be great to have a way to tune the scale and baseline positioning to improve the visual aspect of faked bold.

Check/indicate

Minimal example demonstrating the issue

\documentclass[a4paper,12pt]{article}
\usepackage[a4paper,body={17cm,25cm},nohead]{geometry}
\usepackage{amsmath}
\usepackage[mathup=sym]{unicode-math}
\setmainfont{Stix Two Text}
\setmathfont{Stix Two Math}[Scale=MatchLowercase,
  BoldFont=*, BoldFeatures={FakeBold=4, FakeStretch=1.15, Scale=0.95}]
\begin{document}
sin$\sin$\textbf{sin}$\boldsymbol{\sin}$ 

sin$\sin$\textbf{sin}\raisebox{0.3pt}{$\boldsymbol{\sin}$} 
\end{document}

As it can be seen below, with FakeBold there is significant baseline misalignment. There is also a scale error, but as shown in the example above it can be corrected with the scale=0.95 option. By also fixing the baseline, the faking of a bold font (in this case a bold math font) gets much better. Would be great to have a baselineadj=... option.

image

wspr commented 3 years ago

Sorry, fontspec is only an interface to features offered by the xetex and LuaTeX engines. There’s no way from a macro level for fontspec to make changes like this (although luaotfload would be a good place to start in luatex).