I am a dedicated user of Donald Arsenau's dchem package, which has
been distributed privately for a long time but which he has never felt
was sufficiently developed to be released publicly (or, if that is no
longer true, a public release has apparently not floated high enough on his
priority list to get done.)
I am now trying to switch to xelatex/mathspec. Unfortunately I find that this change has broken the main \ch command of the dchem package. I wrote to D. Arsenau privately, and have asked on c.t.t., but I also thought I might try here to find advice.
I have tried to reduce the problem to an absolute minimum. I therefore extracted a single line of dchem.sty, and renamed it gchem.sty:
\newcommand\ch{\fam\z@\everymath{\fam\z@}}
% like \rm but don't have to repeat
This command is typically used like $\ch H_2O$ to produce chemical formulas set in roman (more accurately, mathrm) type.
This line falls within some complex conditionals in dchem.sty that try to determine
something about the current latex environment and its \everymath, and the implementation is somewhat different depending on the conditional branches, but I believe that this single line is the essence of all versions of the \ch command.
Now, I write a simple test file using the Fourier package:
\documentclass{article}
\usepackage{fourier}
\usepackage{gchem}
\begin{document}
$\rm CH_2O$, $\ch CH_2O$
\end{document}
When I process this package with pdflatex, both the formula produced with \rm and the formula produced with \ch come out in Utopia as expected.
I then modify the test file to use xelatex/mathspec:
\documentclass{article}
\usepackage{mathspec}
\setmainfont{Minion Pro}
\setmathsfont(Digits,Latin,Greek){Minion Pro}
\setmathrm{Minion Pro}
\usepackage{gchem}
\begin{document}
$\rm CH_2O$, $\ch CH_2O$
\end{document}
When I process this file with xelatex (This is XeTeX, Version 3.1415926-2.3-0.9997.5 (MiKTeX 2.9), the \rm formula comes out in Minion Pro as expected but the \ch version comes out in Computer Modern except for the subscript 2 which is Minion Pro.
I have log files, including ones with tracing turned on, that show distinct differences between the behavior of \rm and \ch, and I can post or forward them if needed.
But I think these examples get the point across: it seems that the short \fam\z@ command used by dchem does effect a switch to \mathrm in pdflatex but does not do so in xelatex. Is this expected? If not, where is the problem? If so, how should the \ch command be modified to be compatible with xetex?

:)usually we neither sign questions nor greet fellow users. This is not rude, we just try to focus on the essence of the questions. If you are happy with the answer and wish to thank for it, upvote and/or accept good answers. Another thing: code can be highlighted (by adding 4 spaces before a code line or use the 'curly braces' icon on top of the editor field or use backticks if the code is part of a line), making your question much more readable. Happy TeXing!:)– Count Zero Feb 5 '12 at 7:40dchemdoes not seem to be using the NFSS properly. Newer font packages, particularly those for XeLaTeX/LuaLaTeX, do, and so if you don't through the official interface you are in trouble. – Joseph Wright♦ Feb 5 '12 at 9:36