diff --git a/ChangeLog b/ChangeLog index c92571aff..8c99dd7ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-06-29 17:37 Alexander Malmberg + + * Source/NSStringDrawing.m (-drawAtPoint:, -drawAtRect:, -size): + Automatically turn off screen fonts in the layout manager if the + ctm for the current context isn't the identity matrix (possibly + flipped vertically). + 2003-06-28 Richard Frith-Macdonald * Tools/make_services.m: Alter format of filter info. diff --git a/Source/NSStringDrawing.m b/Source/NSStringDrawing.m index d9e910f24..cb16f6bac 100644 --- a/Source/NSStringDrawing.m +++ b/Source/NSStringDrawing.m @@ -29,7 +29,9 @@ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include +#include "AppKit/NSAffineTransform.h" #include "AppKit/NSLayoutManager.h" #include "AppKit/NSTextContainer.h" #include "AppKit/NSTextStorage.h" @@ -83,6 +85,7 @@ glyphs to be drawn upside-down, so we need to tell NSFont to flip the fonts. { NSRange r; NSGraphicsContext *ctxt = GSCurrentContext(); + NSAffineTransform *ctm = GSCurrentCTM(ctxt); init_string_drawing(); @@ -91,6 +94,16 @@ glyphs to be drawn upside-down, so we need to tell NSFont to flip the fonts. [textContainer setContainerSize: NSMakeSize(1e8, 1e8)]; + if (ctm->matrix.m11 != 1.0 || ctm->matrix.m12 != 0.0 || + ctm->matrix.m21 != 0.0 || fabs(ctm->matrix.m22) != 1.0) + { + [layoutManager setUsesScreenFonts: NO]; + } + else + { + [layoutManager setUsesScreenFonts: YES]; + } + [textStorage replaceCharactersInRange: NSMakeRange(0, 0) withAttributedString: self]; @@ -132,6 +145,7 @@ glyphs to be drawn upside-down, so we need to tell NSFont to flip the fonts. BOOL need_clip; NSRect used; NSGraphicsContext *ctxt = GSCurrentContext(); + NSAffineTransform *ctm = GSCurrentCTM(ctxt); init_string_drawing(); @@ -145,6 +159,16 @@ glyphs to be drawn upside-down, so we need to tell NSFont to flip the fonts. */ [textContainer setContainerSize: NSMakeSize(rect.size.width, 1e8)]; + if (ctm->matrix.m11 != 1.0 || ctm->matrix.m12 != 0.0 || + ctm->matrix.m21 != 0.0 || fabs(ctm->matrix.m22) != 1.0) + { + [layoutManager setUsesScreenFonts: NO]; + } + else + { + [layoutManager setUsesScreenFonts: YES]; + } + [textStorage replaceCharactersInRange: NSMakeRange(0, 0) withAttributedString: self]; @@ -211,6 +235,7 @@ glyphs to be drawn upside-down, so we need to tell NSFont to flip the fonts. withString: @""]; [textContainer setContainerSize: NSMakeSize(1e8, 1e8)]; + [layoutManager setUsesScreenFonts: YES]; [textStorage replaceCharactersInRange: NSMakeRange(0, 0) withAttributedString: self];