Index: NSStringDrawing.m =================================================================== RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSStringDrawing.m,v retrieving revision 1.46 diff -u -r1.46 NSStringDrawing.m --- NSStringDrawing.m 11 Jul 2003 01:38:39 -0000 1.46 +++ NSStringDrawing.m 30 Oct 2003 11:40:30 -0000 @@ -76,6 +76,62 @@ [textContainer release]; } +#include +#include +#include +#include +static int ignore,d_index=0; + +static FILE *string_log; +static void init_string_log(void) +{ + char path[512]; + if (string_log) + return; + snprintf(path,sizeof(path),"%s/NSStringDrawing/%@.%i", + getenv("HOME"),[[NSProcessInfo processInfo] processName],getpid()); + string_log=fopen(path,"at"); + if (!string_log) + { + NSLog(@"Unable to open NSStringDrawing log at '%s': %m",path); + string_log=fopen("/dev/null","a"); + } + fprintf(string_log,"*** started logging %@\n",[NSDate date]); +} + +static void handle_draw_string(NSString *str,NSDictionary *attr,NSSize size) +{ + d_index++; +/* if (d_index>=atoi(getenv("D_INDEX")?:"-1")) + raise(SIGINT); + printf("%i draw string |%@| %08x %10.4fx%10.4f\n", + d_index,str,[attr hash],size.width,size.height);*/ + + init_string_log(); + fprintf(string_log,"DS %5i %08x %3i %08x %15.2fx%15.2f", + d_index,[str hash],[str length],[attr hash],size.width,size.height); + ignore=1; +} + +static void handle_draw_attr_string(NSAttributedString *str,NSSize size) +{ + if (ignore) + { + ignore=0; + return; + } + d_index++; +/* if (d_index>=atoi(getenv("D_INDEX")?:"-1")) + raise(SIGINT); + printf("%i draw attr string |%@| %08x %10.4fx%10.4f\n", + d_index,[str string],[str hash],size.width,size.height);*/ + + init_string_log(); + fprintf(string_log,"DA %5i %08x %3i %15.2fx%15.2f", + d_index,[[str string] hash],[[str string] length],size.width,size.height); +} + + /* This is an ugly hack to get text to display correctly in non-flipped views. @@ -97,6 +153,8 @@ init_string_drawing(); + handle_draw_attr_string(self,NSMakeSize(LARGE_SIZE,LARGE_SIZE)); + [textStorage replaceCharactersInRange: NSMakeRange(0, [textStorage length]) withString: @""]; @@ -145,6 +203,11 @@ DPSscale(ctxt, 1, -1); [NSFont _setFontFlipHack: NO]; } + + { + NSRect rect = [layoutManager usedRectForTextContainer: textContainer]; + fprintf(string_log," size %10.4fx%10.4f\n",rect.size.width,rect.size.height); + } } - (void) drawInRect: (NSRect)rect @@ -157,6 +220,8 @@ init_string_drawing(); + handle_draw_attr_string(self,rect.size); + [textStorage replaceCharactersInRange: NSMakeRange(0, [textStorage length]) withString: @""]; @@ -230,6 +295,7 @@ /* Restore the original clipping path. */ DPSgrestore(ctxt); } + fprintf(string_log,"\n"); } - (NSSize) size @@ -239,6 +305,8 @@ init_string_drawing(); + handle_draw_attr_string(self,NSMakeSize(LARGE_SIZE,LARGE_SIZE)); + [textStorage replaceCharactersInRange: NSMakeRange(0, [textStorage length]) withString: @""]; @@ -251,6 +319,7 @@ r = NSMakeRange(0, [layoutManager numberOfGlyphs]); rect = [layoutManager usedRectForTextContainer: textContainer]; + fprintf(string_log," size %10.4fx%10.4f\n",rect.size.width,rect.size.height); return rect.size; } @@ -266,6 +335,8 @@ { NSAttributedString *a; + handle_draw_string(self,attrs,NSMakeSize(LARGE_SIZE,LARGE_SIZE)); + a = [[NSAttributedString allocWithZone: NSDefaultMallocZone()] initWithString: self attributes: attrs]; @@ -277,6 +348,8 @@ { NSAttributedString *a; + handle_draw_string(self,attrs,rect.size); + a = [[NSAttributedString allocWithZone: NSDefaultMallocZone()] initWithString: self attributes: attrs]; @@ -288,6 +361,8 @@ { NSAttributedString *a; NSSize s; + + handle_draw_string(self,attrs,NSMakeSize(LARGE_SIZE,LARGE_SIZE)); a = [[NSAttributedString allocWithZone: NSDefaultMallocZone()] initWithString: self