@@ -900,7 +900,44 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
900900 NSString *name = [[NSString alloc ]
901901 initWithBytes: (void *)bytes length: len
902902 encoding: NSUTF8StringEncoding];
903- NSFont *font = [NSFont fontWithName: name size: size];
903+ NSFont *font = nil ;
904+ if ([name hasPrefix: MMSystemFontAlias]) {
905+ #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_15
906+ if (@available (macos 10.15 , *)) {
907+ NSFontWeight fontWeight = NSFontWeightRegular ;
908+ if (name.length > MMSystemFontAlias.length ) {
909+ const NSRange cmpRange = NSMakeRange (MMSystemFontAlias.length , name.length - MMSystemFontAlias.length );
910+ if ([name compare: @" UltraLight" options: NSCaseInsensitiveSearch range: cmpRange] == NSOrderedSame)
911+ fontWeight = NSFontWeightUltraLight ;
912+ else if ([name compare: @" Thin" options: NSCaseInsensitiveSearch range: cmpRange] == NSOrderedSame)
913+ fontWeight = NSFontWeightThin ;
914+ else if ([name compare: @" Light" options: NSCaseInsensitiveSearch range: cmpRange] == NSOrderedSame)
915+ fontWeight = NSFontWeightLight ;
916+ else if ([name compare: @" Regular" options: NSCaseInsensitiveSearch range: cmpRange] == NSOrderedSame)
917+ fontWeight = NSFontWeightRegular ;
918+ else if ([name compare: @" Medium" options: NSCaseInsensitiveSearch range: cmpRange] == NSOrderedSame)
919+ fontWeight = NSFontWeightMedium ;
920+ else if ([name compare: @" Semibold" options: NSCaseInsensitiveSearch range: cmpRange] == NSOrderedSame)
921+ fontWeight = NSFontWeightSemibold ;
922+ else if ([name compare: @" Bold" options: NSCaseInsensitiveSearch range: cmpRange] == NSOrderedSame)
923+ fontWeight = NSFontWeightBold ;
924+ else if ([name compare: @" Heavy" options: NSCaseInsensitiveSearch range: cmpRange] == NSOrderedSame)
925+ fontWeight = NSFontWeightHeavy ;
926+ else if ([name compare: @" Black" options: NSCaseInsensitiveSearch range: cmpRange] == NSOrderedSame)
927+ fontWeight = NSFontWeightBlack ;
928+ }
929+ font = [NSFont monospacedSystemFontOfSize: size weight: fontWeight];
930+ }
931+ else
932+ #endif
933+ {
934+ // Fallback to Menlo on older macOS versions that don't support the system monospace font API
935+ font = [NSFont fontWithName: @" Menlo-Regular" size: size];
936+ }
937+ }
938+ else {
939+ font = [NSFont fontWithName: name size: size];
940+ }
904941 if (!font) {
905942 // This should only happen if the system default font has changed
906943 // name since MacVim was compiled in which case we fall back on
0 commit comments