Closed ronaldtse closed 3 years ago
Add a README section to describe how the repair mode works.
There are files that do not have initial viewport setup (#1, #5) and files that do have initial viewport setup(#6). EMF specification does not have any requirement related to initial viewport setup so technically speaking all files are correct.
There were 2 issues and 2 fixes: 1) libemf2svg wrongly processed files with missed initial viewport setup (#1). The fix was just copied from libqemf and it is not specific for Enterprise Architect
2) Enterprise Architect generates files with wrong transformation applied (#5). I implemented autodetect and autocorrection in libemf2svg as you asked: "We could add a command line parameter but we actually want to use this library directly via FFI The goal here is to auto detect this condition" . "EA compatibility mode" is not exposed.
I did not see any specific problems with the file from #6 and there is no specific fix for it. I understand that you may have generated this file in another environment but it did not make it worse or better.
The Windows EMFs specify the positions using origin ([0,0] point) in the upper-left corner of the window; x-coordinates increase to the right; y-coordinates increase from bottom to top. Default SVG coordinate system uses the same origin ([0,0] point) in the upper left corner of the window with the same behavior of x-coordinate and y-coordinates increasing from top to bottom.
Some tools under certain circumstances (possibly on Wine) generate EMF files with malformed coordinates. They have origin ([0,0] point) in the top left corner, x-coordinates increase to the right; y-coordinates are inverted (multiplied by -1) to simulated normal EMF look. Furthermore, this inversion is not real mirroring if complex objects are considered. For example, text boxes have only y-coordinate of its anchor point mirrored but text direction is not changed. Because of its specific layout problem described above cannot be fixed by single svg/css transformation operation.
@maxirmx I've added this description to the README with some modifications: 47924e6 . Please directly change if any description is incorrect. Thanks!
So far the fixes have been in two categories:
These are valid EMF files but could not load properly without the bug fix.
These are "invalid" EMF files generated by Enterprise Architect on Wine (works on Windows, but broken via Wine). These files technically needed "repair" to be loadable, so this is a "compatibility mode for Wine generated EMF files".