diff --git a/ChangeLog b/ChangeLog index c80d69031..6ddfdf72a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-07-10 03:37 Alexander Malmberg + + * Source/NSStringDrawing.m, Source/NSTextView.m: Adjust "really large" + sizes to ensure accuracy to a whole point. + 2003-07-10 Benhur Stein * Source/NSSavePanel.m: added new private method diff --git a/Source/NSStringDrawing.m b/Source/NSStringDrawing.m index cb16f6bac..a084a2160 100644 --- a/Source/NSStringDrawing.m +++ b/Source/NSStringDrawing.m @@ -49,6 +49,14 @@ This might be a common case if lots of calls to -size... and -draw... are paired. */ + +#define LARGE_SIZE 8e6 +/* +8e6 is not as arbitrary as it seems. 8e6 is chosen because it's close to +1<<23-1, the largest number that can be stored in a 32-bit float with an +ulp of 0.5, which means things should round to the correct whole point. +*/ + static NSTextStorage *textStorage; static NSLayoutManager *layoutManager; static NSTextContainer *textContainer; @@ -92,7 +100,7 @@ glyphs to be drawn upside-down, so we need to tell NSFont to flip the fonts. [textStorage replaceCharactersInRange: NSMakeRange(0, [textStorage length]) withString: @""]; - [textContainer setContainerSize: NSMakeSize(1e8, 1e8)]; + [textContainer setContainerSize: NSMakeSize(LARGE_SIZE, LARGE_SIZE)]; if (ctm->matrix.m11 != 1.0 || ctm->matrix.m12 != 0.0 || ctm->matrix.m21 != 0.0 || fabs(ctm->matrix.m22) != 1.0) @@ -153,11 +161,11 @@ glyphs to be drawn upside-down, so we need to tell NSFont to flip the fonts. withString: @""]; /* - TODO: Use rect.size.heigth instead of 1e8? Should make things faster, + TODO: Use rect.size.heigth instead of LARGE_SIZE? Should make things faster, since we'll only typeset what fits, but lines that used to fit partially won't fit at all. */ - [textContainer setContainerSize: NSMakeSize(rect.size.width, 1e8)]; + [textContainer setContainerSize: NSMakeSize(rect.size.width, LARGE_SIZE)]; if (ctm->matrix.m11 != 1.0 || ctm->matrix.m12 != 0.0 || ctm->matrix.m21 != 0.0 || fabs(ctm->matrix.m22) != 1.0) @@ -234,7 +242,7 @@ glyphs to be drawn upside-down, so we need to tell NSFont to flip the fonts. [textStorage replaceCharactersInRange: NSMakeRange(0, [textStorage length]) withString: @""]; - [textContainer setContainerSize: NSMakeSize(1e8, 1e8)]; + [textContainer setContainerSize: NSMakeSize(LARGE_SIZE, LARGE_SIZE)]; [layoutManager setUsesScreenFonts: YES]; [textStorage replaceCharactersInRange: NSMakeRange(0, 0) diff --git a/Source/NSTextView.m b/Source/NSTextView.m index 09618f3c8..7a1ed9ac3 100644 --- a/Source/NSTextView.m +++ b/Source/NSTextView.m @@ -137,7 +137,8 @@ static BOOL noLayoutManagerException(void) /* The shared notification center */ static NSNotificationCenter *notificationCenter; -/* Default max. size. */ +/* Default max. size. Don't change this without understanding and checking +for roundoff issues. Whole points should be representable. */ #define HUGE 1e7