[Solved] SVG files bundled into BinaryData different on Windows and Mac

SVG files get bundled into BinaryData with slightly different sizes on Windows and macOS. The difference is only a few pixels/points. The SVG data itself seems to work just fine, but when using version control, this is quite annoying, as every time i export from Projucer on a diffrent platform, i get unintended modifications to the BinaryData.h and BinaryData.cpp files.

Is there anything i can do to make Projucer stick to one export size?

This is confusing, and I am interested in the final answer. The binary data should not be manipulated in any way when getting bundled.

The whole point of the binary data mechanism is that you don’t check it into your version control - you use the Projucer or CMake to generate it when you generate your targets.

When using the Projucer, I always put Build/ and JuceLibraryCode/ in my .gitignore (and with CMake add whatever build folder I specify - usually build/).

That makes sense. Thanks @ImJimmi !

That being said, it is odd that the different platforms would produce different results… What are the differences OOI? Is it maybe just line endings and/or formatting?

I’m surprised that the Projucer is modifying the SVG files at all when adding them to the BinaryData. The project for the Projucer in the JUCE repo contains SVG files which are included in the binary data, and I’ve never noticed unnecessary modifications to the binary data there.

In the binary data source files, it looks like the contents of the SVG file are included as a quoted string directly in the C++ source - I don’t think the Projucer modifies the file as it writes the BinaryData.

Are you absolutely sure that the SVG files you’re writing are the same on both your Windows and macOS machines? Are the SVG files checked into the same version control system as the rest of your project?

Just guessing, but since svg is a text format, git might choose to use different endline characters.
This would increase the size on windows \r\n by one byte per endline.

This change would be visible in the generated BinaryData.

Maybe try to add to your .gitattributes:

*.svg	text eol=lf
# or better
*.svg	-text
1 Like

@ImJimmi @reuk I may have been mistaken about the size being the diff. Line endings definitely are different. I already removed the files and never committed any Windows versions, so can’t check back. ATM the only diff seems to be line endings. The SVG files were in Git and have definitely been identical on both platforms, but i may have very well misinterpreted based on git diff and falsely concluded that the sizes had changed.

Sorry for the trouble.

@daniel That also happened but i was talking specifically the size attributes like in

<svg width=\"26px\" height=\"26px\" viewBox=\"0 0 26 26\" 

I did see git showing diffs in the numbers, but i suspect i may have had changed the order of the SVGs at that time or something. Ended up thinking its always the size changing when the files had some changes every time. Can’t reproduce it now.

Ah sorry, I thought you meant file sizes.