Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Forcing Mathematica to use standard fonts

782 views
Skip to first unread message

Greg Egan

unread,
Jul 27, 2010, 7:53:13 AM7/27/10
to
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.

Greg Egan

unread,
Jul 28, 2010, 2:54:22 AM7/28/10
to
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.

John Fultz

unread,
Jul 28, 2010, 2:54:44 AM7/28/10
to
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
jfu...@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

AES

unread,
Jul 29, 2010, 6:45:20 AM7/29/10
to
In article <i2ok7k$808$1...@smc.vnet.net>, John Fultz <jfu...@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

Uayeb

unread,
Aug 2, 2010, 7:04:57 AM8/2/10
to
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...@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...@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 =

John Fultz

unread,
Aug 3, 2010, 6:37:54 AM8/3/10
to
If you can reproduce the problem with Acrobat Reader, send me an example
and I'll run it down. But if the problem is only reproducible with
Illustrator, I'm afraid there's not much I can do.

One would certainly think that since Adobe made both the PDF specification
and the reference PDF renderer, that it ought to be a slam dunk for
Adobe to embed a full importer into Illustrator. Maybe.

But I know from hard experience that another format which Adobe invented,
EPS, is *not* fully supported for import into Illustrator. Perhaps not
coincidentally, one of the big areas of breakage we know about is font
embedding. The docs clearly indicate that they support a subset of EPS,
but I haven't been able to find *which* subset. So, Mathematica EPS
tends to be broken when imported into Illustrator.

Quite possibly, the same is true with PDF. I don't know and I
haven't tried it. But if that is the case, I can't consider it a bug.
We're not disinterested in supporting Illustrator, but it must be noted
that supporting Illustrator is *not* the same as supporting EPS or,
possibly, PDF. It's more like a new export format. And if we decided
to do support this new format, I'm not sure the information we need is
available to do so properly.

Sincerely,

John Fultz
jfu...@wolfram.com
User Interface Group
Wolfram Research, Inc.

On Mon, 2 Aug 2010 07:05:10 -0400 (EDT), Uayeb wrote:
> 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...@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...@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 ==

0 new messages