Files
RobustToolbox/Robust.Client/Interop/MacOS/AppKit.cs
Pieter-Jan Briers f3a3f564e1 System font API (#5393)
* System font API

This is a new API that allows operating system fonts to be loaded by the engine and used by content.

Fonts are provided in a flat list exposing all the relevant metadata. They are loaded from disk with a Load call.

Initial implementation is only for Windows DirectWrite.

* Load system fonts as memory mapped files if possible.

This allows sharing the font file memory with other processes which is always good.

* Use ArrayPool to reduce char array allocations

* Disable verbose logging

* Implement system font support on Linux via Fontconfig

* Implement macOS support

* Add "FREEDESKTOP" define constant

This is basically LINUX || FREEBSD. Though FreeBSD currently gets detected as LINUX too. Oh well.

* Compile out Fontconfig and CoreText system font backends when not on those platforms

* Don't add Fontconfig package dep on Mac/Windows

* Allow disabling system font support via CVar

Cuz why not.
2025-10-28 22:07:55 +01:00

25 lines
806 B
C#

// ReSharper disable InconsistentNaming
#if MACOS
namespace Robust.Client.Interop.MacOS;
/// <summary>
/// Binding to macOS AppKit.
/// </summary>
internal static class AppKit
{
// Values pulled from here:
// https://chromium.googlesource.com/chromium/src/+/b5019b491932dfa597acb3a13a9e7780fb6525a9/ui/gfx/platform_font_mac.mm#53
public const double NSFontWeightUltraLight = -0.8;
public const double NSFontWeightThin = -0.6;
public const double NSFontWeightLight = -0.4;
public const double NSFontWeightRegular = 0;
public const double NSFontWeightMedium = 0.23;
public const double NSFontWeightSemiBold = 0.30;
public const double NSFontWeightBold = 0.40;
public const double NSFontWeightHeavy = 0.56;
public const double NSFontWeightBlack = 0.62;
}
#endif