JuliaInterop / MATLAB.jl

Calling MATLAB in Julia through MATLAB Engine
MIT License
270 stars 63 forks source link

How to suppress the warning messages at the beginning of the MATLAB.jl processing? #193

Closed Leon6j closed 2 years ago

Leon6j commented 2 years ago

I keep getting the below warnings that take so much of my screen. Is there a way to suppress them?

CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2021-10-23 19:46:28.336 MATLAB_maci64[21412:7079194] CoreText note: Set a breakpoint on CTFontLogSystemFontNameRequest to debug.
2021-10-23 19:46:28.341 MATLAB_maci64[21412:7079194] CoreText note: Client requested name ".SFNS-Bold", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2021-10-23 19:46:28.487 MATLAB_maci64[21412:7079194] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2021-10-23 19:46:28.487 MATLAB_maci64[21412:7079194] CoreText note: Client requested name ".SFNS-Bold", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
musm commented 2 years ago

Looks unrelated to the library itself. Do you get these warnings when the file is run within matlab itself?

versionbayjc commented 2 years ago

For me these warnings are also shown when starting MATLAB with -nodesktop on macOS from Terminal, independently of Julia or MATLAB.jl:

❯ /Applications/MATLAB_R2021b.app/bin/matlab -nodesktop

                                                             < M A T L A B (R) >
                                                   Copyright 1984-2021 The MathWorks, Inc.
                                              R2021b Update 2 (9.11.0.1837725) 64-bit (maci64)
                                                              December 14, 2021

To get started, type doc.
For product information, visit www.mathworks.com.

>> 2022-02-19 13:14:59.006 MATLAB_maci64[4290:1478515] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2022-02-19 13:14:59.007 MATLAB_maci64[4290:1478515] CoreText note: Set a breakpoint on CTFontLogSystemFontNameRequest to debug.
2022-02-19 13:14:59.013 MATLAB_maci64[4290:1478515] CoreText note: Client requested name ".SFNS-Bold", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2022-02-19 13:14:59.024 MATLAB_maci64[4290:1478515] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2022-02-19 13:14:59.024 MATLAB_maci64[4290:1478515] CoreText note: Client requested name ".SFNS-Bold", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].

A workaround for calling it from terminal is to add another flag: "-nodisplay", but this will also block using figures in MATLAB. If that's ok for you, you can start a MATLAB session with MATLAB.jl with this additional flag like so:

using MATLAB
MATLAB.default_msession_ref[] = MSession(flags="-nodisplay");
musm commented 2 years ago

Thanks for that. It looks like then this is unrelated to MATLAB.jl. Might want to poke around matlab and see why these fonts are missing and why matlab is complaining about them.

versionbayjc commented 2 years ago

Ah yes, forgot to add another comment. This is actually coming from the Oracle JRE that is provided as part of MATLAB. If you change the JRE to one from (a newer) OpenJDK, the warnings are also no longer shown. Info on changing the JRE can be found here for recent MATLAB's: https://www.mathworks.com/help/matlab/ref/matlab_jenv.html For older versions I believe you can set the MATLAB_JAVA environment variable or replace the "jre" subdir of the MATLAB install folder under /sys/java/jre/{arch}/jre On my Mac I installed JRE from OpenJDK with homebrew:

brew install openjdk@8

and then I configured MATLAB to use that JRE with:

/Applications/MATLAB_R2021b.app/bin/matlab_jenv /usr/local/opt/openjdk@8/libexec/openjdk.jdk/Contents/Home/jre
musm commented 2 years ago

Interesting. I wonder why they are using a dated JVM on the 2021 release.