Skip to content
Snippets Groups Projects
Commit 63fd1abd authored by George Nachman's avatar George Nachman
Browse files

Fix assertion in FontSizeEstimator.

parent a063ce8c
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -61,27 +61,26 @@ static double Brightness(NSColor* c) {
osBound.height = MAX(size.height, charSize.height);
}
}
return osBound;
}
 
- (NSImage *)imageForString:(NSString*)s withFont:(NSFont*)aFont
{
// TODO: sometimes ctx is null but I haven't caught it yet.
CGContextRef ctx = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
assert(ctx);
CGContextSetShouldAntialias(ctx, NO);
NSSize osSize = [self osEstimate:aFont];
NSSize estimate = osSize;
estimate.width *= 4;
estimate.height *= 4;
NSImage *image = [[[NSImage alloc] initWithSize:NSMakeSize(estimate.width, estimate.height)] autorelease];
[image lockFocus];
CGContextRef ctx = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
assert(ctx);
CGContextSetShouldAntialias(ctx, NO);
[[NSColor whiteColor] set];
NSRectFill(NSMakeRect(0, 0, estimate.width, estimate.height));
NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
aFont, NSFontAttributeName,
[NSColor blackColor], NSForegroundColorAttributeName,
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment