latex3 / fontspec

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

Fake bold text followed by graphics affects rest of the content #420

Closed zepinglee closed 4 years ago

zepinglee commented 4 years ago

Description

The fake bold text followed by graphics (\includegraphics or \resizebox) affects rest of the content.

Check/indicate

Minimal example demonstrating the issue

\documentclass{article}
\usepackage{fontspec}
\usepackage{graphics}
\setmainfont{lmroman10-regular.otf}[FakeBold=10]
\begin{document}
\textbf{Fake bold}
\resizebox{.2cm}{!}{\rule{1cm}{1cm}}
Test
\end{document}
Screen Shot 2020-04-12 at 2 40 58 PM

Further details

XeTeX, Version 3.14159265-2.6-0.999992 (TeX Live 2020)
LuaHBTeX, Version 1.12.0 (TeX Live 2020)
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-03-06>
fontspec 2020/02/21 v2.7i
graphics 2019/11/30 v1.4a
u-fischer commented 4 years ago

Your syntax is wrong, you are only defining a regular font and make it bold. If you look in the log you will see a warning that bold is actually not defined:

LaTeX Font Warning: Font shape `TU/lmroman10-regular.otf(0)/b/n' undefined
(Font)              using `TU/lmroman10-regular.otf(0)/m/n' instead on input lin

With

\documentclass{article}
\usepackage{fontspec}
\usepackage{graphics}
\setmainfont{lmroman10-regular.otf}[BoldFont={lmroman10-regular.otf},BoldFeatures={FakeBold=10}]
\begin{document}
\textbf{Fake bold}
\resizebox{.2cm}{!}{\rule{1cm}{1cm}}
Test
\end{document}

It works as expected for me.

zepinglee commented 4 years ago

Your syntax is wrong, you are only defining a regular font and make it bold. If you look in the log you will see a warning that bold is actually not defined:

LaTeX Font Warning: Font shape `TU/lmroman10-regular.otf(0)/b/n' undefined
(Font)              using `TU/lmroman10-regular.otf(0)/m/n' instead on input lin

With

\documentclass{article}
\usepackage{fontspec}
\usepackage{graphics}
\setmainfont{lmroman10-regular.otf}[BoldFont={lmroman10-regular.otf},BoldFeatures={FakeBold=10}]
\begin{document}
\textbf{Fake bold}
\resizebox{.2cm}{!}{\rule{1cm}{1cm}}
Test
\end{document}

It works as expected for me.

My mistake. Thanks!

khaledhosny commented 4 years ago

There is AutoFakeBold for this.