Skip to content

Commit af0f269

Browse files
committed
Revert some changes to PDF Type 3 generation to make text placement exactly the same as in Matplotlib 1.0.x
1 parent a74a66d commit af0f269

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,13 @@ def get_char_width(charcode):
809809
charprocDict['Type'] = Name('XObject')
810810
charprocDict['Subtype'] = Name('Form')
811811
charprocDict['BBox'] = bbox
812+
# Each glyph includes bounding box information,
813+
# but xpdf and ghostscript can't handle it in a
814+
# Form XObject (they segfault!!!), so we remove it
815+
# from the stream here. It's not needed anyway,
816+
# since the Form XObject includes it in its BBox
817+
# value.
818+
stream = stream[stream.find(b"d1") + 2:]
812819
charprocObject = self.reserveObject('charProc')
813820
self.beginStream(charprocObject.id, None, charprocDict)
814821
self.currentstream.write(stream)

src/_ttconv.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -179,27 +179,10 @@ class PythonDictionaryCallback : public TTDictionaryCallback
179179

180180
virtual void add_pair(const char* a, const char* b)
181181
{
182-
const char *p;
183-
184-
/* Each glyph includes bounding box information, but xpdf and
185-
ghostscript can't handle it in a Form XObject (they
186-
segfault!!!), so we remove it from the stream here. It's
187-
not needed anyway, since the Form XObject includes it in
188-
its BBox value. */
189-
p = b;
190-
for (p = b; *p != 0; ++p) {
191-
if (*p == 'd') {
192-
if (*(p + 1) == '1') {
193-
p += 2;
194-
break;
195-
}
196-
}
197-
}
198-
199182
#if PY3K
200-
PyObject* value = PyBytes_FromString(p);
183+
PyObject* value = PyBytes_FromString(b);
201184
#else
202-
PyObject* value = PyString_FromString(p);
185+
PyObject* value = PyString_FromString(b);
203186
#endif
204187
if (value)
205188
{

0 commit comments

Comments
 (0)