There is something strange that started happening with macOS Mojave. I have a GTK# app that uses mono on macOS and it was running fine for years. Now all fonts in the application started to appear as bold. I have created a small test app to test the possible reasons for this but I am not going much further with it.
using System;
using Gtk;
namespace GtkKeyScan
{
class Program
{
private static Label lblCount;
private static DateTime? scanStart;
static void Main (string [] args)
{
if (Environment.OSVersion.Platform != PlatformID.Unix)
GLib.Thread.Init ();
Application.Init ();
var dlg = new Dialog { WindowPosition = WindowPosition.CenterAlways, WidthRequest = 200 };
lblCount = new Label { Text = "Press key to see the code" };
dlg.VBox.PackStart (lblCount, true, true, 10);
var btnClear = new Button { Label = "Clear", WidthRequest = 110, HeightRequest = 34, CanFocus = false };
btnClear.Clicked += btnClear_Clicked;
dlg.VBox.PackStart (btnClear, false, true, 10);
dlg.KeyPressEvent += ent_KeyPressEvent;
dlg.ShowAll ();
dlg.Run ();
}
static void btnClear_Clicked (object sender, EventArgs e)
{
lblCount.Text = "";
scanStart = null;
}
[GLib.ConnectBefore]
static void ent_KeyPressEvent (object o, KeyPressEventArgs args)
{
if (!string.IsNullOrWhiteSpace (lblCount.Text))
lblCount.Text += "\n";
lblCount.Text += args.Event.Key.ToString ();
if (scanStart == null)
scanStart = DateTime.Now;
else
lblCount.Text += " +" + (int) (DateTime.Now - scanStart.Value).TotalMilliseconds + "ms";
args.RetVal = true;
}
}
}
I am using the latest Visual Studio Community for macOS version 7.6.8 and the latest mono that comes with it version 5.12.0.309.
If I build the application and run it from the command line using
mono GtkKeyScan.exe
This is how the application looks:
But if I run it from Visual Studio the app looks like this:
The application shows with bold fonts also if I run the application from the terminal with an older version of Mono like 4.2.4 or 4.6.2.
My guess is that Visual Studio does some preparation similar to when the app is bundled for macOS into an .app and this part breaks the fonts somehow in the new macOS.