Skip to content

Some Microsoft fonts produce unreadable EPS #5862

Closed

Description

@petebachant

Using Arial as font.sans-serif in a figure will produce an EPS file that can't be opened or converted to PDF. In my case, using any other font, e.g. Bitstream Vera Sans or Liberation Sans produces a valid EPS.

Activity

  1. petebachant commented on Jan 17, 2016

    @petebachant
    ContributorAuthor

    Looks like the EPS file is leaving in lines that should be commented:

    %!PS-Adobe-3.0 EPSF-3.0
    %%Title: Figures/perf_re_dep.eps
    %%Creator: matplotlib version 1.5.1, http://matplotlib.org/
    %%CreationDate: Sat Jan 16 20:17:39 2016
    %%Orientation: portrait
    %%BoundingBox: 36 270 576 522
    %%EndComments
    %%BeginProlog
    /mpldict 10 dict def
    mpldict begin
    /m { moveto } bind def
    /l { lineto } bind def
    /r { rlineto } bind def
    /c { curveto } bind def
    /cl { closepath } bind def
    /box {
    m
    1 index 0 r
    0 exch r
    neg 0 r
    cl
    } bind def
    /clipbox {
    box
    clip
    newpath
    } bind def
    %!PS-Adobe-3.0 Resource-Font
    %%Title: Arial
    %%Copyright: © 2015 The Monotype Corporation. All Rights Reserved. 
    Hebrew OpenType Layout logic copyright © 2003 & 2007, Ralph Hancock & John Hudson. This layout logic for Biblical Hebrew is open source software under the MIT License; see embedded license description for details.
    %%Creator: Converted from TrueType to type 3 by PPR
    
  2. petebachant commented on Jan 17, 2016

    @petebachant
    ContributorAuthor

    Something going wrong with the carriage returns right before Hebrew?:

    b'%%Copyright: \xa9 2015 The Monotype Corporation. All Rights Reserved. \r\rHebrew OpenType Layout logic copyright \xa9 2003 & 2007, Ralph Hancock & John Hudson. This layout logic for Biblical Hebrew is open source software under the MIT License; see embedded license description for details.\r\n'
    b'/Notice (\xa9 2015 The Monotype Corporation. All Rights Reserved. \r\rHebrew OpenType Layout logic copyright \xa9 2003 & 2007, Ralph Hancock & John Hudson. This layout logic for Biblical Hebrew is open source software under the MIT License; see embedded license description for details. Arial is a trademark of The Monotype Corporation.) def\r\n'
    
  3. added this to the milestone on Jan 17, 2016
  4. tacaswell commented on Jan 17, 2016

    @tacaswell
    Member

    I assume this on windows?

  5. petebachant commented on Jan 17, 2016

    @petebachant
    ContributorAuthor

    Indeed. FWIW, the EPS wouldn't open on Linux either. I removed the carriage returns from \r\r\Hebrew and they work now.

  6. tacaswell commented on Jan 17, 2016

    @tacaswell
    Member

    I meant generated on windows.

    On Sun, Jan 17, 2016, 09:06 Pete Bachant notifications@github.com wrote:

    Indeed. FWIW, the EPS wouldn't open on Linux either. I removed the
    carriage returns from \r\r\Hebrew and they work now.

    —
    Reply to this email directly or view it on GitHub
    #5862 (comment)
    .

  7. mdboom commented on Jan 18, 2016

    @mdboom
    Member

    That line comes directly from the arial.ttf file in the conversion from TTF to Type 3 in ttconv. I suspect that ttconv needs to escape/sanitize/normalize those newlines rather than just copying it over blindly. Does setting ps.fonttype to 42 work as a workaround (at the expense of some file size)?

    #5414 will hopefully someday address this by replacing the font-subsetting code.

  8. petebachant commented on Jan 18, 2016

    @petebachant
    ContributorAuthor

    Nope, unfortunately, setting rcParams["ps.fonttype"] = 42 has the same issue.

  9. MMCMA commented on Mar 16, 2016

    @MMCMA

    I suppose there is no fix yet to the problem?

  10. petebachant commented on Mar 16, 2016

    @petebachant
    ContributorAuthor

    I used this as a workaround for now:

    def fix_eps(fpath):
        """Fix carriage returns in EPS files caused by Arial font."""
        txt = b""
        with open(fpath, "rb") as f:
            for line in f:
                if b"\r\rHebrew" in line:
                    line = line.replace(b"\r\rHebrew", b"Hebrew")
                txt += line
        with open(fpath, "wb") as f:
            f.write(txt)
  11. MMCMA commented on Mar 16, 2016

    @MMCMA

    Great, thanks.

  12. MMCMA commented on Mar 18, 2016

    @MMCMA

    If this adds anything to solving the problem, I don't face the problem on win7 (only on win8.1). Can't check win10 at the moment.

  13. tacaswell commented on Mar 18, 2016

    @tacaswell
    Member

    @mdboom Can you point me to where this code is?

    Is this something we can report upstream against windows (or who ever the source of that font file is)?

  14. MMCMA commented on Mar 21, 2016

    @MMCMA

    FYI, the problem appears on win10 as well.

  15. mdboom commented on Mar 21, 2016

    @mdboom
    Member

    @tacaswell: The new font subsetting code lives in freetypy -- not done yet, but it already might do better on this particular problem. https://github.com/matplotlib/freetypy/blob/master/lib/freetypy/subset.py

    I believe Microsoft releases Arial, but I doubt we'll convince them to fix it -- I think more likely we'll have to work around it, even if it's to hardcode a workaround to particular non-standard fonts like this.

  16. modified the milestones: , on May 16, 2016
  17. changed the title [-]Arial font produces unreadable EPS[/-] [+]Some Microsoft fonts produce unreadable EPS[/+] on Jun 1, 2016
  18. QuLogic commented on Jun 1, 2016

    @QuLogic
    Member

    #6525 has pointed out that this occurs with Calibri as well.

  19. self-assigned this
    on Jun 1, 2016
  20. modified the milestones: , on Jun 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions