macOS: Fix text color in visual window select ignoring the color theme

Fixes #8579
This commit is contained in:
Kovid Goyal 2025-04-27 19:49:51 +05:30
parent 598f9b9dac
commit 01415eb84c
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 1 deletions

View file

@ -134,6 +134,8 @@ Detailed list of changes
- Single instance: Reset OS Window class and name in new single instance OS
windows (:disc:`8567`)
- macOS: Fix text color in visual window select ignoring the color theme (:iss:`8579`)
0.41.1 [2025-04-03]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -20,6 +20,7 @@
#include <CoreText/CoreText.h>
#import <Foundation/NSString.h>
#import <Foundation/NSDictionary.h>
#import <AppKit/AppKit.h>
#define debug debug_fonts
static inline void cleanup_cfrelease(void *__p) { CFTypeRef *tp = (CFTypeRef *)__p; CFTypeRef cf = *tp; if (cf) { CFRelease(cf); } }
@ -958,7 +959,8 @@ cocoa_render_line_of_text(const char *text, const color_type fg, const color_typ
CGContextSetRGBFillColor(ctx, ((fg >> 16) & 0xff) / 255.f, ((fg >> 8) & 0xff) / 255.f, (fg & 0xff) / 255.f, 1.f);
CGContextSetRGBStrokeColor(ctx, ((fg >> 16) & 0xff) / 255.f, ((fg >> 8) & 0xff) / 255.f, (fg & 0xff) / 255.f, 1.f);
NSAttributedString *str = [[NSAttributedString alloc] initWithString:@(text) attributes:@{(NSString *)kCTFontAttributeName: (__bridge id)window_title_font}];
NSColor *color = [NSColor colorWithCalibratedRed:((fg >> 16) & 0xff) / 255.f green:((fg >> 8) & 0xff) / 255.f blue:(fg & 0xff) / 255.f alpha:1.0];
NSAttributedString *str = [[NSAttributedString alloc] initWithString:@(text) attributes:@{(NSString *)kCTFontAttributeName: (__bridge id)window_title_font, NSForegroundColorAttributeName: color}];
if (!str) { CGContextRelease(ctx); return false; }
CTLineRef line = CTLineCreateWithAttributedString((CFAttributedStringRef)str);
[str release];