fsharp / fsharp

Please file issues or pull requests here: https://github.com/dotnet/fsharp
https://fsharp.org
MIT License
2.17k stars 319 forks source link

fsharpi -- gui gives an exception #40

Closed funnelweb closed 11 years ago

funnelweb commented 11 years ago

Starting up fsharpi with --gui gives an exception with Mono 3.0 on MacOS, looks like it is DefaultFont

Microsoft (R) F# 3.0 Interactive version (Mono build) Copyright (c) Microsoft Corporation. All Rights Reserved. For help type #help;;

Exception by fsi.exe:

System.ArgumentException: The requested FontFamily could not be found [GDI+ status: FontFamilyNotFound]

at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in :0

at System.Drawing.FontFamily..ctor (GenericFontFamilies genericFamily) [0x00000] in :0

at (wrapper remoting-invoke-with-check) System.Drawing.FontFamily:.ctor (System.Drawing.Text.GenericFontFamilies)

at System.Drawing.FontFamily.get_GenericSansSerif () [0x00000] in :0

at System.Drawing.Font.CreateFont (System.String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte charSet, Boolean isVertical) [0x00000] in :0

at System.Drawing.Font..ctor (System.String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont) [0x00000] in :0

at System.Drawing.Font..ctor (System.String familyName, Single emSize, System.String systemName) [0x00000] in :0

at (wrapper remoting-invoke-with-check) System.Drawing.Font:.ctor (string,single,string)

at System.Drawing.SystemFonts.get_DefaultFont () [0x00000] in :0

at System.Windows.Forms.Theme.get_DefaultFont () [0x00000] in :0

at System.Windows.Forms.Control.get_DefaultFont () [0x00000] in :0

at System.Windows.Forms.Control.get_Font () [0x00000] in :0

at System.Windows.Forms.Form..ctor () [0x00000] in :0

at (wrapper remoting-invoke-with-check) System.Windows.Forms.Form:.ctor ()

at Microsoft.FSharp.Compiler.Interactive.Shell+DummyForm..ctor () [0x00000] in :0

at (wrapper remoting-invoke-with-check) Microsoft.FSharp.Compiler.Interactive.Shell/DummyForm:.ctor ()

at Microsoft.FSharp.Compiler.Interactive.Shell+WinFormsEventLoop..ctor (Microsoft.FSharp.Compiler.Interactive.FsiConsoleOutput fsiConsoleOutput, Microsoft.FSharp.Core.FSharpOption`1 lcid) [0x00000] in :0

at Microsoft.FSharp.Compiler.Interactive.Shell+FsiEvaluationSession.Run () [0x00000] in :0

at Microsoft.FSharp.Compiler.Interactive.Main.MainMain (System.String[] argv) [0x00000] in :0

funnelweb commented 11 years ago

This is a Mono 3.0 bug in System.Windows.Forms.Form().

Submitted https://bugzilla.xamarin.com/show_bug.cgi?id=7962

Will look for a workaround for F#. --gui is used to have an event loop and do graphics etc. from the F# REPL.

migueldeicaza commented 11 years ago

It might be useful to have an equivalent command line option to start other popular toolkits, like MonoMac or Gtk#

funnelweb commented 11 years ago

Is the WindowsForms bug in Mono 3.0 likely to get fixed?

Do the event loops of the different toolkits interoperate in any way (can you use a Gt# widget with a MonoMac widget etc.?)

I think you can install an even loop after the fact with fsi.EventLoop

funnelweb commented 11 years ago

workaround this as best as possible in https://github.com/fsharp/fsharp/commit/85b2663b3ba081780becaa885b4c9f80e6bf71dd

Maybe someone can blog how to set up the event loop for Gtk# and MonoMac?

Hopefully the Mono bug can be fixed.

migueldeicaza commented 11 years ago

I wonder if this is a problem with modern builds of GDI+ that fail to find the system fonts.

funnelweb commented 11 years ago

It sure looks like that would explain it