Fix the detection of SVGImageRep on macOS AppKit

This commit is contained in:
DreamPiggy 2024-05-30 11:34:53 +08:00
parent a936e64ab1
commit 095fc63f8a
1 changed files with 3 additions and 1 deletions

View File

@ -143,6 +143,7 @@
- (BOOL)sd_isVector {
NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height);
// This may returns a NSProxy, so don't use `class` to check
NSImageRep *imageRep = [self bestRepresentationForRect:imageRect context:nil hints:nil];
if ([imageRep isKindOfClass:[NSPDFImageRep class]]) {
return YES;
@ -150,7 +151,8 @@
if ([imageRep isKindOfClass:[NSEPSImageRep class]]) {
return YES;
}
if ([NSStringFromClass(imageRep.class) hasSuffix:@"NSSVGImageRep"]) {
Class NSSVGImageRepClass = NSClassFromString([NSString stringWithFormat:@"_%@", SD_NSSTRING(NSSVGImageRep)]);
if ([imageRep isKindOfClass:NSSVGImageRepClass]) {
return YES;
}
return NO;