From: Greg Egan on
Suppose I embed some text in a graphic using:

Style[
Text["The (quick+brown) fox = the lazy-dog", coords],
FontFamily->"Times"]

If I export this graphic (e.g. to PDF or SVG), Mathematica will put
most of the text in Times, but the characters "(+)=-" will all be in
special Mathematica fonts, generally with their own special encodings.

I appreciate that Mathematica has good reasons for substituting its
own fonts when it typesets mathematical expressions, but in some
situations I'd like to be able to create output that uses only
standard fonts.

Is there any way to force Mathematica to stop this character-by-
character font-substitution, and output all characters unchanged in a
single, specified font? There's a tantalising claim in the
documentation (tutorial/TextAndFontOptions):

"For a given text font, Mathematica tries to choose the special
character font that matches it best. You can help Mathematica to make
this choice by giving rules for "FontSerifed" and "FontMonospaced" in
the setting for the FontProperties option. You can also give rules for
"FontEncoding" to specify explicitly from what font each character is
to be taken."

.... but there's no proper documentation of this feature, if it even
still exists in v7; the documentation for FontProperties warns that
"This function has not been fully integrated into the long-term
Mathematica system, and is subject to change."

Thanks for any help people can offer.

From: Greg Egan on
On Jul 27, 7:53 pm, I wrote:

> Suppose I embed some text in a graphic using:
>
> Style[
> Text["The (quick+brown) fox = the lazy-dog", coords],
> FontFamily->"Times"]

I was looking for ways to ensure that all the text was rendered and
exported in the chosen font, Times.

Someone very kindly gave me two solutions by email. The most general
one is to add:

PrivateFontOptions->{"OperatorSubstitution"->False}

to the Style[] wrapper.

From: John Fultz on
If what you're exporting is really text with no embedded math, then you can use
TextCell...

Graphics[{Style[
Text[TextCell["The (quick+brown) fox == the lazy-dog"], {0, 0}],
FontFamily -> "Times"]}]

This will also fix various other things like the line-wrapping behavior to be
more appropriate for straight text.

If you have embedded math, but still don't want to use the Mathematica fonts,
you can use the "OperatorSubstitution" option, which I've mentioned a few times
before in this group:

Graphics[{Style[Text["The (quick+brown) fox == the lazy-dog", {0, 0}],
FontFamily -> "Times",
PrivateFontOptions -> {"OperatorSubstitution" -> False}]}]

In both cases, Mathematica fonts will still be used for things like Greek
characters and special mathematical symbols, but they won't be used for routine
operators such as (){}[]#+==-*/, which I think is what you're mainly interested
in.

Sincerely,

John Fultz
jfultz(a)wolfram.com
User Interface Group
Wolfram Research, Inc.


On Tue, 27 Jul 2010 07:53:00 -0400 (EDT), Greg Egan wrote:
> Suppose I embed some text in a graphic using:
>
> Style[
> Text["The (quick+brown) fox == the lazy-dog", coords],
> FontFamily->"Times"]
>
> If I export this graphic (e.g. to PDF or SVG), Mathematica will put
> most of the text in Times, but the characters "(+)==-" will all be in
> special Mathematica fonts, generally with their own special encodings.
>
> I appreciate that Mathematica has good reasons for substituting its
> own fonts when it typesets mathematical expressions, but in some
> situations I'd like to be able to create output that uses only
> standard fonts.
>
> Is there any way to force Mathematica to stop this character-by-
> character font-substitution, and output all characters unchanged in a
> single, specified font? There's a tantalising claim in the
> documentation (tutorial/TextAndFontOptions):
>
> "For a given text font, Mathematica tries to choose the special
> character font that matches it best. You can help Mathematica to make
> this choice by giving rules for "FontSerifed" and "FontMonospaced" in
> the setting for the FontProperties option. You can also give rules for
> "FontEncoding" to specify explicitly from what font each character is
> to be taken."
>
> ... but there's no proper documentation of this feature, if it even
> still exists in v7; the documentation for FontProperties warns that
> "This function has not been fully integrated into the long-term
> Mathematica system, and is subject to change."
>
> Thanks for any help people can offer.


From: AES on
In article <i2ok7k$808$1(a)smc.vnet.net>, John Fultz <jfultz(a)wolfram.com>
wrote:

>
> If you have embedded math, but still don't want to use the Mathematica fonts,
> you can use the "OperatorSubstitution" option, which I've mentioned a few
> times
> before in this group:
>
> Graphics[{Style[Text["The (quick+brown) fox == the lazy-dog", {0, 0}],
> FontFamily -> "Times",
> PrivateFontOptions -> {"OperatorSubstitution" -> False}]}]
>
> In both cases, Mathematica fonts will still be used for things like Greek
> characters and special mathematical symbols, but they won't be used for
> routine
> operators such as (){}[]#+==-*/, which I think is what you're mainly
> interested
> in.
>

John,

A secondary but nonetheless significant part of your (very helpful)
reply above is the parenthetical comment, "which I've mentioned before a
few times in this group".

Try pretending that you're an ordinary or occasional user of Mathematica
(i.e. not a Mathematica programmer by trade) who reads the above reply
(or one of your earlier mentions); makes a mental note of it but fails
to capture and file it; sometime later runs into the particular (and
admittedly fairly minor) "gotcha" that the default behavior of
OperatorSubstitution creates; and attempts to bring back this
information.

OperatorSubstitution is a moderately arcane term in Mathematica's
immense vocabulary, and easily forgotten; PrivateFontOptions even more
so. You can't search the Mathematica documentation for terms you can't
remember -- and I believe those two terms are essentially unmentioned
anywhere in the Mathematica documentation outside their own definitions.

It could help a lot to add just some brief mentions or pointers to these
terms in the definitions or tutorials for Style[], Text[], various
Font-related commands, Export[], and elsewhere.

It might even be argued that the default value of OperatorSubstitution
ought to be False -- but I doubt that's likely at this point.

--AES

From: Uayeb on
A related problem (which was my guess as to why this question was
posed in the first place) is how does one deal with the Mathematica
fonts embeded into PDF files of plots saved/Exported from Mathematica.

Opening a PDF in e.g. Adobe Illustrator gives an error Font
"Mathematica2" not found, or something similar.

I then installed the Mathematica Fonts on my system (from
http://support.wolfram.com/technotes/fonts/windows/latestfonts.html).
This eliminates the error, but the glyphs are still not correct. (e.g.
a lowercase sigma becomes capital sigma, some characters are replaced
by a box with an "x" in it, etc)

Of course a strategy such as that suggested with "PrivateFontOptions"
is helpful, but breaks down again as soon as one incorperates a greek
letter...

Cheers,
Andy Green

PS Actually, I find the structure of PDF files exported from
Mathematica infuriating, not to mention the (seeming) considerable
inconsistencies in how they are exported. But that's a discussion for
another thread.

On Jul 28, 4:54 pm, John Fultz <jfu...(a)wolfram.com> wrote:
> If what you're exporting is really text with no embedded math, then you c=
an use
> TextCell...
>
> Graphics[{Style[
> Text[TextCell["The (quick+brown) fox == the lazy-dog"], {0, 0}=
],
> FontFamily -> "Times"]}]
>
> This will also fix various other things like the line-wrapping behavior t=
o be
> more appropriate for straight text.
>
> If you have embedded math, but still don't want to use the Mathematica fo=
nts,
> you can use the "OperatorSubstitution" option, which I've mentioned a few=
times
> before in this group:
>
> Graphics[{Style[Text["The (quick+brown) fox == the lazy-dog", {0, 0}]=
,
> FontFamily -> "Times",
> PrivateFontOptions -> {"OperatorSubstitution" -> False}]}]
>
> In both cases, Mathematica fonts will still be used for things like Greek
> characters and special mathematical symbols, but they won't be used for r=
outine
> operators such as (){}[]#+==-*/, which I think is what you're mainly =
interested
> in.
>
> Sincerely,
>
> John Fultz
> jfu...(a)wolfram.com
> User Interface Group
> Wolfram Research, Inc.
>
> On Tue, 27 Jul 2010 07:53:00 -0400 (EDT), Greg Egan wrote:
> > Suppose I embed some text in a graphic using:
>
> > Style[
> > Text["The (quick+brown) fox == the lazy-dog", coords],
> > FontFamily->"Times"]
>
> > If I export this graphic (e.g. to PDF or SVG), Mathematica will put
> > most of the text in Times, but the characters "(+)==-" will all be =
in
> > special Mathematica fonts, generally with their own special encodings.
>
> > I appreciate that Mathematica has good reasons for substituting its
> > own fonts when it typesets mathematical expressions, but in some
> > situations I'd like to be able to create output that uses only
> > standard fonts.
>
> > Is there any way to force Mathematica to stop this character-by-
> > character font-substitution, and output all characters unchanged in a
> > single, specified font? There's a tantalising claim in the
> > documentation (tutorial/TextAndFontOptions):
>
> > "For a given text font, Mathematica tries to choose the special
> > character font that matches it best. You can help Mathematica to make
> > this choice by giving rules for "FontSerifed" and "FontMonospaced" in
> > the setting for the FontProperties option. You can also give rules for
> > "FontEncoding" to specify explicitly from what font each character is
> > to be taken."
>
> > ... but there's no proper documentation of this feature, if it even
> > still exists in v7; the documentation for FontProperties warns that
> > "This function has not been fully integrated into the long-term
> > Mathematica system, and is subject to change."
>
> > Thanks for any help people can offer.