From 92f471c4764b59c66b88e76bdfc18f96cbc9dffc Mon Sep 17 00:00:00 2001 From: daboe01 Date: Sun, 10 May 2015 15:19:26 +0200 Subject: [PATCH] move fontHeight to where it is needed --- AppKit/CPStringDrawing.j | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/AppKit/CPStringDrawing.j b/AppKit/CPStringDrawing.j index 23b27e403..8095e6542 100644 --- a/AppKit/CPStringDrawing.j +++ b/AppKit/CPStringDrawing.j @@ -65,15 +65,11 @@ CPStringSizeCachingEnabled = YES; var cssString = [aFont cssString], cacheKey = self + cssString + aWidth, - size = CPStringSizeWithFontInWidthCache[cacheKey], - fontHeight = CPStringSizeWithFontHeightCache[cssString]; + size = CPStringSizeWithFontInWidthCache[cacheKey]; if (size !== undefined) return CGSizeMakeCopy(size); - if (fontHeight === undefined) - fontHeight = CPStringSizeWithFontHeightCache[cssString] = [aFont defaultLineHeightForFont]; - if (!CPStringSizeMeasuringContext) CPStringSizeMeasuringContext = CGBitmapGraphicsContextCreate(); @@ -92,6 +88,11 @@ CPStringSizeCachingEnabled = YES; if (CPStringSizeMeasuringContext.font !== aFont) CPStringSizeMeasuringContext.font = cssString; + var fontHeight = CPStringSizeWithFontHeightCache[cssString]; + + if (fontHeight === undefined) + fontHeight = CPStringSizeWithFontHeightCache[cssString] = [aFont defaultLineHeightForFont]; + size = CGSizeMake(CPStringSizeMeasuringContext.measureText(self).width, fontHeight); }