I got a weird problem with the fontspec package and the graphicx package. Let's see the MWE first.
%!TEX program = xelatex
\documentclass{article}
\usepackage{graphicx}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\newfontfamily\test[AutoFakeBold = 5]{Times New Roman}
\begin{document}
\test
Test
\textbf{Bold Test}
\includegraphics[scale = 0.1]{photo}
Words that shouldn't be bolded. Even if \textmd{textmd-ed}.
\end{document}
In the preamble, I loaded the graphicx package and the fontspec package, then I set Times New Roman as the default font of the text as well as the font of the test command. In the definition of \test, I enabled AutoFakeBold. In the document body, between the two chains of text, I inserted a photo with the \includegraphics command.
It's a normal manuscript, except that AutoFakeBold was set to 5 to make the abnormal output more remarkable. After the compilation, however, the later line of text presented an unexpected output. That is, this line of text shouldn't be bolded.
Even more surprising is that, if one
\includegraphics,\textbf{},the problem will go away.
After some deep analyses by qingkuan@bbs.ctex.org, it seems to be a bug of XeTeX. See the new MWE.
% !TeX program = xetex
\font\x="[cmunrm.otf]"
\font\bx="[cmunrm.otf]:embolden=5;"
\x Test
{\bx Bold Test}
\XeTeXpicfile "example-image.png" width 1cm\relax
Words that shouldn't be bolded.
\tracingoutput=1
\showboxbreadth=\maxdimen
\showboxdepth=\maxdimen
\bye
Anonymous
This turned out to be a dvipdfmx bug and should be fixed in the next TeX Live release.
Khaled, did this actually get fixed? It seems to still be around: https://tex.stackexchange.com/q/446622/2693