Revision: 3901
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3901&view=rev
Author: jouni
Date: 2007-09-30 13:08:50 -0700 (Sun, 30 Sep 2007)
Log Message:
---
use_tex in pdf backend: don't use AFM files,
which are not there in some TeX distros
Modified Paths:
--
trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
trunk/matplotlib/lib/matplotlib/dviread.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
===
--- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-09-28
15:57:49 UTC (rev 3900)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-09-30
20:08:50 UTC (rev 3901)
@@ -500,70 +500,15 @@
finally:
fh.close()
-fh = open(fontinfo.afmfile, 'rb')
-matplotlib.verbose.report(
-'Reading metrics from ' + fontinfo.afmfile, 'debug')
-try:
-afmdata = AFM(fh)
-finally:
-fh.close()
-
font = FT2Font(filename)
-font.attach_file(fontinfo.afmfile)
widthsObject, fontdescObject, fontdictObject, fontfileObject = \
[ self.reserveObject(n) for n in
('font widths', 'font descriptor',
'font dictionary', 'font file') ]
-_, _, fullname, familyname, weight, italic_angle, fixed_pitch, \
-ul_position, ul_thickness = font.get_ps_font_info()
-
-if fontinfo.encodingfile is not None:
-enc = dviread.Encoding(fontinfo.encodingfile)
-widths = []
-for ch in enc:
-try:
-widths.append(afmdata.get_width_from_char_name(ch))
-except KeyError:
-matplotlib.verbose.report(
-'No width for %s in %s' % (ch, fullname),
'debug-annoying')
-widths.append(0)
-
-differencesArray = [ Name(ch) for ch in enc ]
-differencesArray = [ 0 ] + differencesArray
-firstchar = 0
-lastchar = len(differencesArray) - 2
-else:
-widths = [ None for i in range(256) ]
-for ch in range(256):
-try:
-widths[ch] = afmdata.get_width_char(ch, isord=True)
-except KeyError:
-pass
-not_None = [ch for ch in range(256)
-if widths[ch] is not None]
-firstchar = not_None[0]
-lastchar = not_None[-1]
-widths = widths[firstchar:lastchar+1]
-for i,w in enumerate(widths):
-if w is None: widths[i] = 0
-
-differencesArray = [ ]
-need_idx = True
-for ch in range(firstchar, lastchar+1):
-try:
-name = afmdata.get_name_char(ch, isord=True)
-if need_idx:
-differencesArray.append(ch)
-need_idx = False
-differencesArray.append(Name(name))
-except KeyError:
-matplotlib.verbose.report(
-'No name for glyph %d in %s' % (ch, fullname),
-'debug-annoying')
-need_idx = True
-
+firstchar = 0
+lastchar = len(fontinfo.widths) - 1
fontdict = {
'Type': Name('Font'),
@@ -575,15 +520,22 @@
'FontDescriptor': fontdescObject,
}
-fontdict.update({
-'Encoding': { 'Type': Name('Encoding'),
- 'Differences': differencesArray },
-})
+if fontinfo.encodingfile is not None:
+enc = dviread.Encoding(fontinfo.encodingfile)
+differencesArray = [ Name(ch) for ch in enc ]
+differencesArray = [ 0 ] + differencesArray
+fontdict.update({
+'Encoding': { 'Type': Name('Encoding'),
+ 'Differences': differencesArray },
+})
+_, _, fullname, familyname, weight, italic_angle, fixed_pitch, \
+ul_position, ul_thickness = font.get_ps_font_info()
+
flags = 0
if fixed_pitch: flags |= 1 << 0 # fixed width
if 0: flags |= 1 << 1 # TODO: serif
-if 1: flags |= 1 << 2 # TODO: symbolic
+if 1: flags |= 1 << 2 # TODO: symbolic (most TeX fonts
are)
else: flags |= 1 << 5 # non-symbolic
if italic_angle: flags |= 1 << 6 # italic
if 0: flags |= 1 << 16 # TODO: all caps
@@ -598,33 +550,17 @@
'ItalicAngle': italic_angle,
'Ascent': font.ascender,
'Descent': font.descender,
-'CapHeight': 1000, # default guess if missing from AFM file
-'X