在macOS 10.14 Mojave上,GTK#中的字体看起来加粗

3
有些奇怪的事情开始发生在macOS Mojave上。我有一个使用mono的GTK#应用程序在macOS上运行良好,已经运行了多年。现在应用程序中的所有字体都开始出现粗体。我创建了一个小型测试应用程序来测试可能的原因,但是没有进展。
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;
        }
    }
}

我正在使用最新的Visual Studio Community for macOS版本7.6.8和随附的最新mono版本5.12.0.309。如果我构建应用程序并使用命令行运行它,使用 " mono GtkKeyScan.exe ",应用程序将如下所示:

App normal look

但是如果我从Visual Studio运行它,应用程序看起来像这样:

App bold fonts look

该应用程序在终端中使用旧版本的Mono(如4.2.4或4.6.2)运行时,字体会以粗体显示。
我的猜测是Visual Studio做了一些准备工作,类似于将应用程序打包成.macOS的.app文件,这部分在新的macOS中会破坏字体。
1个回答

0

看起来问题与Mojave是最后一个支持32位应用程序的macOS有关。我尝试的项目是以32位构建的,因为在Windows上,GTK#只能在32位模式下工作。在新的Mono版本中,GTK#似乎也可以在64位模式下工作。

所以当我从命令行启动应用程序时,它以某种方式在64位模式下运行,尽管该应用程序是以32位模式构建的。而在macOS上的Visual Studio则以32位模式运行该应用程序。

在32位模式下运行时,macOS第一次显示该应用程序未针对此macOS进行优化,并以任何方式运行它。但在负责文本呈现的Pango部分内部出现了一些问题。我不确定具体是什么问题,但在编译项目时切换到64位模式使其正常工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接