CIRDLES / Topsoil

Community-driven replacement for Isoplot
Apache License 2.0
28 stars 35 forks source link

SVG file unable to be opened by Illustrator on Mac #26

Closed pfif closed 10 years ago

pfif commented 10 years ago

Nevermind that fact that the SVG documents produced by Topsoil are passing W3C validation, illustrator refuse to open them. It yield the error The operation cannot complete because of an unknown error. [CANT].

johnzeringue commented 10 years ago

From @spenchristoph in issue #25:

John, Same problem with the svg on Mac Illustrator ([CANT] error) using v0.0.2. This svg works fine: http://en.wikipedia.org/wiki/File:Bitmap_VS_SVG.svg Chris

johnzeringue commented 10 years ago

Thanks, Chris. I came across this Adobe forum which suggests that it might just be an unfixed Illustrator bug in CS6 on Mac: https://forums.adobe.com/thread/1326594

However, when Dr. Bowring's in the office tomorrow (and I have a copy of CS6 to test on), I'll try a few more things and see if I can't make it work.

johnzeringue commented 10 years ago

I added this to milestone v0.2.0, because I'm hoping that we'll either have a working fix or confirmation that it's an unavoidable Illustrator bug by next Friday, and will then be able to close it.

spenchristoph commented 10 years ago

Perhaps an alternative solution would be to export the vector format directly to pdf?

johnzeringue commented 10 years ago

We will have an export to PDF option in the coming months, but we're going to come up with a temporary fix for this issue next week and complain to Adobe (it seems to be an Illustrator bug).

Just to confirm my suspicions, has anyone experienced this bug with anything other than Illustrator CS6 on Mavericks?

johnzeringue commented 10 years ago

I think CS5 might also have the same issue on Mavericks.

spenchristoph commented 10 years ago

I am using CS4 on Mavericks with the same issue.

On Sat, May 24, 2014 at 5:57 PM, John Zeringue notifications@github.comwrote:

I think CS5 might also have the same issue on Mavericks.

— Reply to this email directly or view it on GitHubhttps://github.com/CIRDLES/topsoil/issues/26#issuecomment-44093022 .

noahmclean commented 10 years ago

You CIRDLErs have made a great start with the plotting and svg output! Before we get too far with this, perhaps we should take a step back and ask exactly what the users want out of an exported svg. I'll start a new thread and suggest some broad user-focused objectives, and hopefully some other users can join in. The resulting re-design may solve many of the specific issues with compatibility.

I've written a couple MATLAB codes that create svg files from scratch. My experience was that the online W3C svg validation would accept most anything, even files with bad errors (unclosed quote marks, etc), and Illustrator, as you're finding, is much more picky. There are also lots of ways to code the same result in .svg, and Illustrator doesn't seem to like some of them. To try and get around this, I made a qualitative sketch of my ideal plot in Illustrator, complete with correct grouping/layers, line widths, label rotations, etc, then exported this file to .svg. The Illustrator-produced svg had a pretty simple, extensible structure that I could then duplicate in my own code with the correct, quantitatively calculated curve, data point, axis label, etc locations.

pfif commented 10 years ago

@noahmclean, thanks for the great suggestions! We'll investigate the issue this week, it should be fixed in a future hotfix release.

johnzeringue commented 10 years ago

So I've identified the issue and it's a pretty terrible Illustrator bug. The problem stems from font-family values that contain uninstalled fonts.

A quick lesson on the font-family attribute:

font-family="Times"

sets the font to Times for whatever scope it's applied to.

font-family="Times, Arial"

tries to do the same thing, but if it can't find Times it falls back to Arial.

There are also a few special generic fonts, most notably serif and sans-serif, which should be supported by any SVG viewer. For example:

font-family="Verdana, Arial, sans-serif"

is a fairly common way to specify acceptable fonts in order of preference, but at the least come away with a sans-serif font instead of a serif font.

So, trying this in CS6 Illustrator on Mavericks, I found that the following line worked:

<text font-family="Verdana">hello world</text>

while adding any of these lines would cause the file not to open:

<text font-family="sans-serif">hello world</text>
<text font-family="Verdana, sans-serif">hello world</text>
<text font-family="sans-serif, Verdana">hello world</text>
<text font-family="serif">hello world</text>

So it's bad that uninstalled fonts would cause Illustrator to crash as it gets to them in the list, but the examples above show that even unnecessary fonts in the font-family string that "aren't installed" (generic fonts should also be recognized regardless of environment) will cause the file not to open.

Given that working around this bug not only means changing uncommon fonts to common ones but also excluding commonly used generic fonts from the font-family attribute entirely, I don't think that this is something that we should support in our SVG conversion code. This leaves a few other options:

  1. Change the font used in our chart to whatever Redux uses, since most Macs seem to have that.
  2. Encourage people to switch to Inkscape/upgrade to the newest version of Illustrator where this bug is apparently fixed/complain to Adobe.
  3. Provide a tool independent of Topsoil that changes all the font-family attributes to values that Illustrator should like.

None of these are long-term solutions, but I'm interested to hear what you all think of these options, particularly @noahmclean and @bowring.

As an aside, I have filed a bug report with Adobe, but who knows how long that could take?

noahmclean commented 10 years ago

Illustrator comes with quite a few nice installed fonts--it is safe to assume that 99.5% of our users (the Illustrator users) will have these. For instance, the Myriad Pro that I used here: https://dl.dropboxusercontent.com/u/38811323/UThPlot_v3.svg .

Subscripts and superscripts can be difficult to place correctly for arbitrary fonts. Check out my formatting of the axes labels above--I did that by formatting it in Illustrator, exporting, then using the same inter-element distances.

There are lots of fonts available now that are both pretty and free. Can we include a few with Topsoil, install them to the font directory, then have Topsoil utilize those? Then we can just name a specific font and get the formatting right.

pfif commented 10 years ago

No that's not stable enough. If someone ever tinker with its font folder and remove our font. It could cause our dear friend Illustrator to crash and make the user loose some time. Plus, these SVG files yielded by Topsoil could be exchanged by email and the font would not necessarily be on the recipient computer.

You can consider we have two code bases in this project :

John stated it : we don't want the SVG converter to be changed only because of some malfunction in an old version of Illustrator. Our SVG converter is generic, it could quickly be turned into a a converter that would work for any interface in JavaFX, it would be too bad to change that.

What we could have is an option "Create Illustrator-compatible SVG files" in our Topsoil code base. If that option is enabled, the production of the SVG file would be in two steps :

  1. Production of the SVG file by our generic converter
  2. Changing any sans-serif to Verdanna

This way, we keep our SVG Converter code base clean, and we don't damage too much our Topsoil code base.

noahmclean commented 10 years ago

I think of the svg file as a useful way to import vector drawings into Illustrator, and pdf output as a useful way to share those drawings with others. Topsoil will support an export to pdf, correct? If so, I don't think we need to worry about trading svg files. I find the scenario of accidental font deletion to be a bit unlikely--I don't think we need to worry too much about it, though I appreciate that you want to build robust code.

johnzeringue commented 10 years ago

@noahmclean, is that how everyone is using Redux right now, or is that just your workflow? Would an "open in Illustrator" feature be widely useful?

Perhaps that would be the best resolution of this issue: an export to SVG feature that wouldn't accommodate any particular program and an open in Illustrator feature that would create a temporary SVG file, hack it to work with Illustrator as long as the bug persists, and open it in the program for the user.

I think this project will find users outside of geochronology given enough time (which would be a win-win for everyone), so I don't think it's wise to make assumptions about how future users will need the SVGs.

Just as Topsoil will be filling an open niche in its realm, the JavaFX to SVG code we have is the only software of its kind that I've come across. Keeping it untainted by this Illustrator mess and spinning it off into a new, small project would give CIRDLES extra page views here on GitHub (and hopefully extra contributors) and would add significant merit to our work, in addition to helping a relatively young JavaFX community.

Obviously, this is a relatively minor issue and hopefully Adobe will fix their mess within a few months, but it seems strange to introduce unnecessary platform dependence into a project that was born out of it.

Topsoil will also support export to PDF, likely before Adobe fixes squat.

ryanickert commented 10 years ago

FYI, opening a Topsoil .svg using v0.1.0 running on a Win7PC with CS6 yields the following error message: "System: Certain alternate glyphs are not available in this version of Illustrator."

After clicking through, the files opens fine. The file seems perfectly usable as-is, no clipping masks or odd groups, and as far as I can tell no extraneous objects. The fonts are a mixture of mainly "system" and a small amount of "myriad pro". By the way, this or similar problems (such as uninstalled fonts) is/are a problem that almost always crops up for me when opening a file in AI that I didn't produce myself.

(By the way, if I was able to fix the scale of the x-y plot via a numerical input, this version of Topsoil would be usable for me right away)

johnzeringue commented 10 years ago

@ryanickert, glad to hear the issue's contained to the Mac version of Illustrator.

What do you mean by "fixing the scale of the x-y plot"?

If you mean adjusting the tick positions, you're able to do this manually by unchecking "autoticking" for the appropriate axis and changing the tick interval and anchor tick. The anchor tick is simply a base value from which you form the other ticks by adding integer multiples of the tick interval.

If you mean the ability to exactly adjust the min and max values for each axis, create a new issue and we should be able to make it happen fairly quickly (if not by this Friday). (EDIT Issue created now : #35)

noahmclean commented 10 years ago

@johnzeringue, "is that how everyone is using Redux right now, or is that just your workflow? Would an "open in Illustrator" feature be widely useful?"

"Perhaps that would be the best resolution of this issue: an export to SVG feature that wouldn't accommodate any particular program and an open in Illustrator feature that would create a temporary SVG file, hack it to work with Illustrator as long as the bug persists, and open it in the program for the user."

johnzeringue commented 10 years ago

@noahmclean, in the first question I was really just curious if these SVGs were only/mainly used for passing data into Illustrator. If that's the case, it makes sense to streamline this operation.

pfif commented 10 years ago

This is our plan of attack to tackle that bug and keep our code base clean : #38.

pfif commented 10 years ago

Yet another strategy to make SVG work on Illustrator : #43

pfif commented 10 years ago

We had a little temporary hack in our latest release (Commit 6167c5970596922ffcf710c3b5f6befdc02f8653) that allow the produced SVG files to be opened in Ilustrator.

sylvainaerni commented 9 years ago

big thanks to @johnzeringue :)