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

Skip to content

Commit 45bc22e

Browse files
committed
Merge remote-tracking branch 'upstream/v1.3.x'
2 parents 23a8a47 + 3b8412d commit 45bc22e

File tree

9 files changed

+47
-10
lines changed

9 files changed

+47
-10
lines changed

lib/matplotlib/backends/backend_pgf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ def draw_path(self, gc, path, transform, rgbFace=None):
450450
# if present, draw pattern on top
451451
if gc.get_hatch():
452452
writeln(self.fh, r"\begin{pgfscope}")
453+
self._print_pgf_path_styles(gc, rgbFace)
453454

454455
# combine clip and path for clipping
455456
self._print_pgf_clip(gc)

lib/matplotlib/backends/backend_ps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def set_font(self, fontname, fontsize, store=1):
284284
if (fontname,fontsize) != (self.fontname,self.fontsize):
285285
out = ("/%s findfont\n"
286286
"%1.3f scalefont\n"
287-
"setfont\n" % (fontname,fontsize))
287+
"setfont\n" % (fontname.decode('ascii'), fontsize))
288288

289289
self._pswriter.write(out)
290290
if store: self.fontname = fontname
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

lib/matplotlib/tests/test_backend_pgf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def create_figure():
6767
plt.figure()
6868
x = np.linspace(0, 1, 15)
6969
plt.plot(x, x**2, "b-")
70+
plt.fill_between([0., .4], [.4, 0.], hatch='//', facecolor="lightgray", edgecolor="red")
7071
plt.plot(x, 1-x**2, "g>")
7172
plt.plot([0.9], [0.5], "ro", markersize=3)
7273
plt.text(0.9, 0.5, u'unicode (ü, °, µ) and math ($\\mu_i = x_i^2$)', ha='right', fontsize=20)

src/ft2font.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,9 @@ FT2Font::get_glyph_name(const Py::Tuple & args)
16211621

16221622
if (!FT_HAS_GLYPH_NAMES(face))
16231623
{
1624-
snprintf(buffer, 128, "uni%04x", glyph_number);
1624+
/* Note that this generated name must match the name that
1625+
is generated by ttconv in ttfont_CharStrings_getname. */
1626+
PyOS_snprintf(buffer, 128, "uni%08x", glyph_number);
16251627
} else {
16261628
if (FT_Get_Glyph_Name(face, glyph_number, buffer, 128))
16271629
{
@@ -1745,9 +1747,10 @@ FT2Font::get_sfnt(const Py::Tuple & args)
17451747
key[1] = Py::Int(sfnt.encoding_id);
17461748
key[2] = Py::Int(sfnt.language_id);
17471749
key[3] = Py::Int(sfnt.name_id);
1748-
names[key] = Py::String((char *) sfnt.string,
1749-
(int) sfnt.string_len,
1750-
"latin-1");
1750+
1751+
names[key] = Py::asObject
1752+
(PyBytes_FromStringAndSize(
1753+
(const char *)sfnt.string, sfnt.string_len));
17511754
}
17521755
return names;
17531756
}

ttconv/pprdrv_tt.cpp

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "pprdrv.h"
3232
#include "truetype.h"
3333
#include <sstream>
34+
#include <Python.h>
3435

3536
/*==========================================================================
3637
** Convert the indicated Truetype font file to a type 42 or type 3
@@ -166,6 +167,13 @@ BYTE *GetTable(struct TTFONT *font, const char *name)
166167

167168
} /* end of GetTable() */
168169

170+
static void utf16be_to_ascii(char *dst, char *src, size_t length) {
171+
++src;
172+
for (; *src != 0 && length; dst++, src += 2, --length) {
173+
*dst = *src;
174+
}
175+
}
176+
169177
/*--------------------------------------------------------------------
170178
** Load the 'name' table, get information from it,
171179
** and store that information in the font structure.
@@ -311,6 +319,21 @@ void Read_name(struct TTFONT *font)
311319
font->PostName[length]=(char)NULL;
312320
replace_newlines_with_spaces(font->PostName);
313321

322+
#ifdef DEBUG_TRUETYPE
323+
debug("font->PostName=\"%s\"",font->PostName);
324+
#endif
325+
continue;
326+
}
327+
328+
/* Microsoft-format PostScript name */
329+
if ( platform == 3 && nameid == 6 )
330+
{
331+
free(font->PostName);
332+
font->PostName = (char*)calloc(sizeof(char),length+1);
333+
utf16be_to_ascii(font->PostName, (char *)strings+offset, length);
334+
font->PostName[length/2]=(char)NULL;
335+
replace_newlines_with_spaces(font->PostName);
336+
314337
#ifdef DEBUG_TRUETYPE
315338
debug("font->PostName=\"%s\"",font->PostName);
316339
#endif
@@ -967,6 +990,20 @@ const char *ttfont_CharStrings_getname(struct TTFONT *font, int charindex)
967990
char *ptr;
968991
ULONG len;
969992

993+
Fixed post_format;
994+
995+
/* The 'post' table format number. */
996+
post_format = getFixed( font->post_table );
997+
998+
if ( post_format.whole != 2 || post_format.fraction != 0 )
999+
{
1000+
/* We don't have a glyph name table, so generate a name.
1001+
This generated name must match exactly the name that is
1002+
generated by FT2Font in get_glyph_name */
1003+
PyOS_snprintf(temp, 80, "uni%08x", charindex);
1004+
return temp;
1005+
}
1006+
9701007
GlyphIndex = (int)getUSHORT( font->post_table + 34 + (charindex * 2) );
9711008

9721009
if ( GlyphIndex <= 257 ) /* If a standard Apple name, */
@@ -1011,11 +1048,6 @@ void ttfont_CharStrings(TTStreamWriter& stream, struct TTFONT *font, std::vector
10111048
/* The 'post' table format number. */
10121049
post_format = getFixed( font->post_table );
10131050

1014-
if ( post_format.whole != 2 || post_format.fraction != 0 )
1015-
{
1016-
throw TTException("TrueType fontdoes not have a format 2.0 'post' table");
1017-
}
1018-
10191051
/* Emmit the start of the PostScript code to define the dictionary. */
10201052
stream.printf("/CharStrings %d dict dup begin\n", glyph_ids.size());
10211053

0 commit comments

Comments
 (0)