mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-16 03:30:42 +00:00
Merge pull request #2508 from daboe01/fix-sizing-issue
Fixed: text-sizing by canvas and via DOM sizing differed by 1px
This commit is contained in:
commit
6aea0160df
2 files changed
+11
-3
No files matched your search
@@ -68,7 +68,7 @@ CPStringSizeCachingEnabled = YES;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (CGSize)sizeWithFont:(CPFont)aFont inWidth:(float)aWidth
|
||||
- (CGSize)_sizeWithFont:(CPFont)aFont inWidth:(float)aWidth
|
||||
{
|
||||
var size;
|
||||
|
||||
@@ -81,6 +81,9 @@ CPStringSizeCachingEnabled = YES;
|
||||
if (sizeCacheForFont === undefined)
|
||||
sizeCacheForFont = CPStringSizeWithFontInWidthCache[self] = [];
|
||||
|
||||
if (!aWidth)
|
||||
aWidth = '0';
|
||||
|
||||
var cssString = [aFont cssString],
|
||||
cacheKey = cssString + '_' + aWidth;
|
||||
|
||||
@@ -111,4 +114,10 @@ CPStringSizeCachingEnabled = YES;
|
||||
return CGSizeMakeCopy(size);
|
||||
}
|
||||
|
||||
- (CGSize)sizeWithFont:(CPFont)aFont inWidth:(float)aWidth
|
||||
{
|
||||
var size = [self _sizeWithFont:aFont inWidth:aWidth];
|
||||
return CGSizeMake(CEIL(size.width), size.height);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* CPTypesetter.j
|
||||
* AppKit
|
||||
@@ -319,7 +318,7 @@ var CPSystemTypesetterFactory,
|
||||
measuringRange.length++;
|
||||
|
||||
var currentCharCode = theString.charCodeAt(glyphIndex), // use pure javascript methods for performance reasons
|
||||
rangeWidth = [theString.substr(measuringRange.location, measuringRange.length) sizeWithFont:currentFont inWidth:NULL].width + currentAnchor;
|
||||
rangeWidth = [theString.substr(measuringRange.location, measuringRange.length) _sizeWithFont:currentFont inWidth:NULL].width + currentAnchor;
|
||||
|
||||
switch (currentCharCode) // faster than sending actionForControlCharacterAtIndex: called for each char.
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user