I have developed a mac app with cocos2d 1.0.1 for mac.
Text display (CCLabelTTF) doesn't work on iMac 5K with Catalina.
Mac pro, iMac, & MacBook are no problem.
I think this code is problem.
CCTexture2D.m:
elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
-(id)initWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment attributedString:(NSAttributedString*)stringWithAttributes { NSAssert( stringWithAttributes, @"Invalid stringWithAttributes");
NSUInteger POTWide = ccNextPOT(dimensions.width);
NSUInteger POTHigh = ccNextPOT(dimensions.height);
unsigned char* data;
NSSize realDimensions = [stringWithAttributes size];
//Alignment
float xPadding = 0;
// Mac crashes if the width or height is 0
if( realDimensions.width > 0 && realDimensions.height > 0 ) {
switch (alignment) {
case CCTextAlignmentLeft: xPadding = 0; break;
case CCTextAlignmentCenter: xPadding = (dimensions.width-realDimensions.width)/2.0f; break;
case CCTextAlignmentRight: xPadding = dimensions.width-realDimensions.width; break;
default: break;
}
//Disable antialias
[[NSGraphicsContext currentContext] setShouldAntialias:NO];
NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize(POTWide, POTHigh)];
[image lockFocus];
[stringWithAttributes drawAtPoint:NSMakePoint(xPadding, POTHigh-dimensions.height)]; // draw at offset position
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithFocusedViewRect:NSMakeRect (0.0f, 0.0f, POTWide, POTHigh)];
[image unlockFocus];
data = (unsigned char*) [bitmap bitmapData]; //Use the same buffer to improve the performance.
NSUInteger textureSize = POTWide*POTHigh ;
for(int i = 0; i<textureSize; i++) //Convert RGBA8888 to A8
{
data[i] = data[i*4+3];
}
data = [self keepData:data length:textureSize];
self = [self initWithData:data pixelFormat:kCCTexture2DPixelFormat_A8 pixelsWide:POTWide pixelsHigh:POTHigh contentSize:dimensions];
[bitmap release];
[image release];
} else {
[self release];
return nil;
}
return self;
}
endif // __MAC_OS_X_VERSION_MAX_ALLOWED
please help me
OH yeah~~ solved~
fixed - CCTexture2D.m -
-(id) initWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment attributedString:(NSAttributedString*)stringWithAttributes { NSAssert(stringWithAttributes, @"Invalid stringWithAttributes");
}