From d5f8b0d6e56542e88a55202699f8c779cfe342d4 Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Wed, 31 Aug 2022 17:02:44 -0400 Subject: [PATCH] feat: support for monospace system font Provides support for the `monospacedSystemFontOfSize` method from `NSFont`. Refer: https://developer.apple.com/documentation/appkit/nsfont/3042659-monospacedsystemfontofsize?language=objc --- src/text/font.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/text/font.rs b/src/text/font.rs index 17ef473..2a38d39 100644 --- a/src/text/font.rs +++ b/src/text/font.rs @@ -40,6 +40,14 @@ impl Font { Font(unsafe { ShareId::from_ptr(msg_send![class!(NSFont), boldSystemFontOfSize: size]) }) } + + /// Creates and returns a monospace system font at the specified size and weight + pub fn monospace(size: f64, weight: f64) -> Self { + let size = size as CGFloat; + let weight = weight as CGFloat; + + Font(unsafe { ShareId::from_ptr(msg_send![class!(NSFont), monospacedSystemFontOfSize: size weight: weight]) }) + } } impl Deref for Font {