gpt4 book ai didi

macos - macOS 10.14 Mojave 上 GTK# 中的字体看起来很粗

转载 作者:行者123 更新时间:2023-12-02 04:27:30 25 4
gpt4 key购买 nike

macOS Mojave 开始出现一些奇怪的情况。我有一个在 macOS 上使用单声道的 GTK# 应用程序,它运行良好多年。现在应用程序中的所有字体都开始显示为粗体。我创建了一个小型测试应用程序来测试造成这种情况的可能原因,但我不会进一步研究它。

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 和它附带的最新单声道版本 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 中的字体。

最佳答案

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

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

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

关于macos - macOS 10.14 Mojave 上 GTK# 中的字体看起来很粗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52700341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com