Merge pull request #3716 from dreampiggy/bugfix/sd_svg_macos

Fix the detection of SVGImageRep on macOS AppKit
This commit is contained in:
DreamPiggy 2024-05-30 14:33:42 +08:00 committed by GitHub
commit 5f599018b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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;