Opened 7 years ago
Closed 7 years ago
#14664 closed enhancement (fixed)
Enable type1 fonts in matplotlib
Reported by: | ppurka | Owned by: | jason, was |
---|---|---|---|
Priority: | major | Milestone: | sage-5.11 |
Component: | graphics | Keywords: | |
Cc: | Merged in: | sage-5.11.beta0 | |
Authors: | Punarbasu Purkayastha | Reviewers: | Volker Braun |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | #14640 | Stopgaps: |
Description (last modified by )
Essentially what the ticket title says. Some publications require all the fonts to be embedded in the document and require the use of type-1 fonts. It is not very hard to enable these fonts.
Apply trac_14664-type1-fonts.patch to devel/sage
Attachments (1)
Change History (24)
comment:1 Changed 7 years ago by
- Description modified (diff)
- Status changed from new to needs_review
comment:2 Changed 7 years ago by
comment:3 Changed 7 years ago by
It is about type 1 fonts, as far as I can tell. The first thing publications tell is that type 3 fonts should not be present in the document. Some of them silently fail when you try to upload your document - the upload website just says that the upload didn't succeed.
As for references, I found these links earlier:
- http://nerdjusttyped.blogspot.sg/2010/07/type-1-fonts-and-matplotlib-figures.html
- http://matplotlib.1069221.n5.nabble.com/Type-1-font-in-figures-needed-td10294.html
- http://brainlogging.wordpress.com/2011/11/16/type-1-vs-3-fonts/
About using latex=bool
:
Unless someone knows that matplotlib has its own math renderer and doesn't use latex by default for rendering math, it will not be clear that something like latex=True
will switch fonts to type 1 fonts.
comment:4 Changed 7 years ago by
rcParams['text.usetex'] = False
means that you disable TeX entirely, right? Maybe we want separate plot(usetex=<bool>, type1_fonts=<bool>)
? Or plot(tex=[None(default)|True|False|"type1"])
?
comment:5 Changed 7 years ago by
False
is the default. You can try the following in your sage installation
sage: from matplotlib import rcParams sage: rcParams['text.usetex'] False
matplotlib does not require latex to render math fonts.
comment:6 follow-up: ↓ 8 Changed 7 years ago by
What I'm saying is: Whether or not to use LaTeX is completely orthogonal to which fonts to use. But your patch links type1_fonts
to both. You should be a able to use LaTeX without Type1 and the built-in renderer with Type1 fonts.
comment:7 follow-up: ↓ 9 Changed 7 years ago by
The following setting might be relevant:
sage: matplotlib.rcParams['pdf.fonttype'] 3
comment:8 in reply to: ↑ 6 Changed 7 years ago by
- Status changed from needs_review to needs_work
Replying to vbraun:
What I'm saying is: Whether or not to use LaTeX is completely orthogonal to which fonts to use. But your patch links
type1_fonts
to both. You should be a able to use LaTeX without Type1 and the built-in renderer with Type1 fonts.
I am not sure if the latter is possible.
But you are right about decoupling latex from type1. I will make that change.
comment:9 in reply to: ↑ 7 Changed 7 years ago by
Replying to vbraun:
The following setting might be relevant:
sage: matplotlib.rcParams['pdf.fonttype'] 3
From an initial reading, I believe this is something completely different and is only used with the internal matplotlib tex engine.
comment:10 Changed 7 years ago by
- Status changed from needs_work to needs_review
I changed the option to font_style
. It take three strings now, "type1", "latex" and "default". In my limited testing just turning on "latex" by itself gives me embedded type 1 fonts, but maybe there are cases where this is not true.
comment:11 Changed 7 years ago by
Font style means serif/sans serif. How about typeset="latex"
?
comment:12 Changed 7 years ago by
Thanks. I have changed it to typeset
.
comment:13 Changed 7 years ago by
I get fuzz 2 with sage-5.10.rc0
comment:14 follow-up: ↓ 15 Changed 7 years ago by
- can we get a ValueError if
typeset
is not one of the allowed values? - If you change matplotlib rcParams then you should switch it back when you are finished
comment:15 in reply to: ↑ 14 Changed 7 years ago by
Replying to vbraun:
- can we get a ValueError if
typeset
is not one of the allowed values?
I will do that in a day or two. I need to compile 5.10rc0 first.
- If you change matplotlib rcParams then you should switch it back when you are finished
Not resetting the rcParams actually affects only those plots which are a mixture of Sage and (direct) matplotlib calls. Currently, there is nothing in Sage that actually does this. I will make the change nevertheless because there might be someone doing this manually.
comment:16 Changed 7 years ago by
Updated the patch. The "default" does not mess with the settings at all now.
comment:17 Changed 7 years ago by
- Dependencies set to #14640
Looks good but unfortunately conflicts with #14640. The latter has already positive review, so you'll have to rebase your patch.
comment:18 Changed 7 years ago by
Done. Thanks.
comment:19 Changed 7 years ago by
You are restoring rc_backup
before saving it; The fuzz 2 ended up inserting a hunk at the wrong place.
comment:20 Changed 7 years ago by
So sorry. I should have checked the git diff. Thanks for catching this.
comment:21 Changed 7 years ago by
ok. Now it should be done.
comment:22 Changed 7 years ago by
- Reviewers set to Volker Braun
- Status changed from needs_review to positive_review
Looks good to me
comment:23 Changed 7 years ago by
- Merged in set to sage-5.11.beta0
- Resolution set to fixed
- Status changed from positive_review to closed
This isn't really about type 1 fonts, right? You are switching TeXing labels on/off. How about calling it
plot(latex=bool)
.It would be nice if we could autodetect the prerequisites and default to the right thing.