move fontHeight to where it is needed

This commit is contained in:
daboe01 committed 2015-05-10 15:19:26 +02:00
1 parent 4c7ce97650
commit 92f471c476
1 file changed
+6 -5
+6 -5
View File
@@ -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);
}