From afff3b44df67a20845559eb33e723039fa501afe Mon Sep 17 00:00:00 2001 From: "Eevee (Lexy Munroe)" Date: Wed, 8 Jun 2016 16:48:10 -0700 Subject: Fix fonts extension under Python 3, and fix expected output --- scss/extension/fonts.py | 10 +++++----- scss/tests/files/fonts/fonts.css | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scss/extension/fonts.py b/scss/extension/fonts.py index b772ceb..bc06e42 100644 --- a/scss/extension/fonts.py +++ b/scss/extension/fonts.py @@ -260,7 +260,7 @@ def font_sheet(g, **kwargs): height = float(m.group(1)) else: height = None - _glyph = tempfile.NamedTemporaryFile(delete=False, suffix=".svg") + _glyph = tempfile.NamedTemporaryFile(delete=False, suffix=".svg", mode='w') _glyph.file.write(svgtext) _glyph.file.close() yield _glyph.name, width, height @@ -294,7 +294,7 @@ def font_sheet(g, **kwargs): try: if type_ == 'eot': ttf_path = asset_paths['ttf'] - with open(ttf_path) as ttf_fh: + with open(ttf_path, 'rb') as ttf_fh: contents = ttf2eot(ttf_fh.read()) if contents is not None: with open(asset_path, 'wb') as asset_fh: @@ -304,7 +304,7 @@ def font_sheet(g, **kwargs): if type_ == 'ttf': contents = None if autohint: - with open(asset_path) as asset_fh: + with open(asset_path, 'rb') as asset_fh: contents = ttfautohint(asset_fh.read()) if contents is not None: with open(asset_path, 'wb') as asset_fh: @@ -330,7 +330,7 @@ def font_sheet(g, **kwargs): contents = None if type_ == 'eot': ttf_path = asset_paths['ttf'] - with open(ttf_path) as ttf_fh: + with open(ttf_path, 'rb') as ttf_fh: contents = ttf2eot(ttf_fh.read()) if contents is None: continue @@ -338,7 +338,7 @@ def font_sheet(g, **kwargs): _tmp = tempfile.NamedTemporaryFile(delete=False, suffix='.' + type_) _tmp.file.close() font.generate(_tmp.name) - with open(_tmp.name) as asset_fh: + with open(_tmp.name, 'rb') as asset_fh: if autohint: if type_ == 'ttf': _contents = asset_fh.read() diff --git a/scss/tests/files/fonts/fonts.css b/scss/tests/files/fonts/fonts.css index b6d3215..77ce3a9 100644 --- a/scss/tests/files/fonts/fonts.css +++ b/scss/tests/files/fonts/fonts.css @@ -1,10 +1,10 @@ @font-face { font-family: 'FontSheet'; src: url(static/assets/fontsheet-g7MrCA_HKKgVf2zD68L54g.eot); - src: url(static/assets/fontsheet-g7MrCA_HKKgVf2zD68L54g.svg?#iefix&#fontsheet) format('svg'), + src: url(static/assets/fontsheet-g7MrCA_HKKgVf2zD68L54g.eot) format('embedded-opentype'), url(static/assets/fontsheet-g7MrCA_HKKgVf2zD68L54g.woff) format('woff'), url(static/assets/fontsheet-g7MrCA_HKKgVf2zD68L54g.ttf) format('truetype'), - url(static/assets/fontsheet-g7MrCA_HKKgVf2zD68L54g.eot) format('embedded-opentype'); + url(static/assets/fontsheet-g7MrCA_HKKgVf2zD68L54g.svg?#iefix&#fontsheet) format('svg'); font-weight: normal; font-style: normal; } -- cgit v1.2.1