Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b11cf22

Browse files
committed
More work on supporting Type 1 fonts in PDF. Sort of works now.
svn path=/trunk/matplotlib/; revision=3779
1 parent 1952847 commit b11cf22

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2007-09-04 Embedding Type 1 fonts in PDF, and thus usetex support
2+
via dviread, sort of works. To test, enable it by
3+
renaming _draw_tex to draw_tex. - JKS
4+
15
2007-09-03 Added ability of errorbar show limits via caret or
26
arrowhead ends on the bars; patch by Manual Metz. - EF
37

lib/matplotlib/backends/backend_pdf.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ def embedType1(self, filename, fontinfo):
581581
'CapHeight': 1000, # default guess if missing from AFM file
582582
'XHeight': afmdata.get_xheight(),
583583
'FontFile': fontfileObject,
584-
'FontFamily': Name(familyname),
584+
'FontFamily': familyname,
585585
#'FontWeight': a number where 400 = Regular, 700 = Bold
586586
}
587587
try:
@@ -1422,7 +1422,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
14221422
self.file.output(Op.grestore)
14231423

14241424
def _draw_tex(self, gc, x, y, s, prop, angle):
1425-
# Rename to draw_tex to enable, but it doesn't work at the moment
1425+
# Rename to draw_tex to enable
14261426

14271427
texmanager = self.get_texmanager()
14281428
fontsize = prop.get_size_in_points()
@@ -1606,6 +1606,19 @@ def draw_text_woven(chunks):
16061606
return draw_text_woven(chunks)
16071607

16081608
def get_text_width_height_descent(self, s, prop, ismath):
1609+
if rcParams['text.usetex']:
1610+
texmanager = self.get_texmanager()
1611+
fontsize = prop.get_size_in_points()
1612+
dvifile = texmanager.make_dvi(s, fontsize)
1613+
dvi = dviread.Dvi(dvifile, 72)
1614+
text, boxes = iter(dvi).next()
1615+
# TODO: better bounding box -- this is not quite right:
1616+
l = min(p[0] for p in text+boxes)
1617+
r = max(p[0] for p in text+boxes) + fontsize
1618+
b = min(p[1] for p in text+boxes)
1619+
t = max(p[1] for p in text+boxes) + fontsize
1620+
# (not to even mention finding the baseline)
1621+
return r-l, t-b, t-b
16091622
if ismath:
16101623
w, h, d, glyphs, rects, used_characters = \
16111624
self.mathtext_parser.parse(s, 72, prop)

lib/matplotlib/dviread.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
...
1616
"""
1717

18+
# TODO: support for TeX virtual fonts (*.vf) which are a dvi-like format
19+
1820
import matplotlib
1921
import matplotlib.cbook as mpl_cbook
2022
import os

0 commit comments

Comments
 (0)