Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

DLL Issues on Mac OS

Discussion in 'Scripting' started by Cyber-Dog, Apr 28, 2019.

  1. Cyber-Dog

    Cyber-Dog

    Joined:
    Sep 12, 2018
    Posts:
    352
    Hey All,

    Bit of a pickle here. I am porting my project to Mac and have an issue with System.Drawing.
    The library must be present on the Mac somewhere because when I add a reference to the mcs.rsp file, visual studio can pickup on sub classes of the library like System.Drawing.FONT.
    Code (CSharp):
    1. //mcs.rsp file
    2. -r:System.Drawing.dll
    3. //Tried
    4. -r:/Library/Frameworks/Mono.framework/Versions/5.16.0/lib/libgdiplus.0.dylib -target:framework System.Drawing
    5.  
    The error is related to libgdiplus.dylib, which to my knowledge is the mono port of system.drawing.
    I have tried adding references to the gdiplus lib, even installed with HomeBrew. Nothing has worked.

    For the sake of not fully understanding the problem Im facing, below is a code snip of what causes the error, and the error itself. Sorry for a big error dump, but its just there as Im not sure whats going wrong :confused:

    Code (CSharp):
    1. private void LoadFontFile(string path){
    2.     fontCollection = new System.Drawing.Text.PrivateFontCollection();
    3.     fontCollection.AddFontFile(path);
    4.     font = new System.Drawing.Font(fontCollection.Families[0], fontRenderSize);
    5.     ...
    6. }
    Code (CSharp):
    1. DllNotFoundException: /Users/builduser/buildslave/mono/build/external/buildscripts/add_to_build_results/monodistribution/lib/libgdiplus.dylib
    2. System.Drawing.GDIPlus..cctor () (at <db84b41d92194c43bc99091ea8fb22ce>:0)
    3. Rethrow as TypeInitializationException: The type initializer for 'System.Drawing.GDIPlus' threw an exception.
    4. System.Drawing.Text.PrivateFontCollection..ctor () (at <db84b41d92194c43bc99091ea8fb22ce>:0)
    5. CatalogueItemManager_Font.LoadFontFile (System.String path) (at Assets/Scripts/CatalogueItemManager_Font.cs:265)
    6. ..........
    7.  
    Note: I have also tried copying libgdiplus.dylib into the plugins folder and that didn't do anything.

    Im only borrowing a mates Mac, so I need to fix this today so I can build the app before having to give it back :(:(
     
  2. Cyber-Dog

    Cyber-Dog

    Joined:
    Sep 12, 2018
    Posts:
    352
    Kurt-Dekker likes this.
  3. Umresh

    Umresh

    Joined:
    Oct 14, 2013
    Posts:
    56
    I'm trying to do something like this. Can you tell me how you fixed this? LINK
     
  4. Cyber-Dog

    Cyber-Dog

    Joined:
    Sep 12, 2018
    Posts:
    352
    Hey, following the steps in the solution I linked kinda fixed the issue. Just gott do it correctly. Keep in mind Mono has not done the best port, I submitted a bug but never got a reply.

    So I got the dll ported, and could do the above. But when I went on to rendering text it would always default Ariel no matter what font I chose
     
  5. Umresh

    Umresh

    Joined:
    Oct 14, 2013
    Posts:
    56
    I tried your steps but its not woking for WebGl or Mobile Devices. I want to load some fonts to render mathml and its
    loaded using System.Drawing.Text.PrivateFontCollection which is in .net version of system.drawing.text.
    How do I solve this ?
     
  6. Cyber-Dog

    Cyber-Dog

    Joined:
    Sep 12, 2018
    Posts:
    352
    Hey, do you have a mac you can test to see if it works on desktop? I have not done it for WebGL so I cannot give you any advice really. It may be possible that WebGl does not support it or needs steps to get working.