metanorma / libemf2svg

Microsoft (MS) EMF to SVG conversion library
GNU General Public License v2.0
11 stars 2 forks source link

`viewBox` attribute #33

Closed maxirmx closed 2 years ago

maxirmx commented 2 years ago

Please add the attribute viewBox to correct svg rendering. Currently, even in the browser, svg doesn't render properly (cropped and wrong scale): image (from: https://github.com/metanorma/iso-15926-6/pull/1#issuecomment-1103680097)

Originally posted by @Intelligent2013 in https://github.com/metanorma/emf2svg-ruby/issues/30#issuecomment-1103734838

maxirmx commented 2 years ago

@Intelligent2013 @ronaldtse
Is this file generated by SparxSystem Enterprise Architect ?

ronaldtse commented 2 years ago

@maxirmx Probably not? I don't know where this file is generated from...

maxirmx commented 2 years ago

It has EA fix applied I will look at these two files but it won't be fast and I am sceptical. As far as I remeber EA files missed viewport record and this flaw made impossible to calculate scaling factors

ronaldtse commented 2 years ago

Interestingly it opens fine in Adobe Illustrator 2022:

Screenshot 2022-04-20 at 7 38 30 PM
maxirmx commented 2 years ago

It can be false positive for EA patch.

While this may be a weak assumption, nothing better came to mind -- the comment says

maxirmx commented 2 years ago

These files miss U_EMR_SETVIEWPORTEXTEX emf records so it is better comparing to EA output but still not 100%-specified emf

In SVG terms it implies initial coordinate system (https://www.w3.org/TR/SVG2/coords.html#InitialCoordinateSystem) and no optional viewBox attribute I will change the code to generate SVG similar to sample at https://www.w3.org/TR/SVG2/coords.html#ViewportSpace, i.e.: with width and height attributes.
viewBox is optional and I would like to avoid it.

ronaldtse commented 2 years ago

Thanks @maxirmx !

FYI @Intelligent2013 regarding viewbox being optional.