[Drawkit] Another text issue in non-flipped drawings

Allan Daly allandaly at me.com
Wed Jun 3 19:32:07 PDT 2009


Graham,

I found another one for you to take a look at when you get a chance.

Here's a simple method I added to your DKSimpleDemo app.

// simple text object creation method for testing / demonstration
- (IBAction)	createText:(id) sender	
{
	NSFont *font = [NSFont fontWithName:@"Helvetica" size:24.0];
	NSDictionary *attrsDictionary = [NSDictionary  
dictionaryWithObject:font forKey:NSFontAttributeName];
	NSAttributedString *attrString = [[NSAttributedString alloc]  
initWithString:@"1st Line\n2nd Line\n3rd Line"  
attributes:attrsDictionary];	

	NSSize stringSize = [attrString size];
	NSPoint stringOrigin = NSMakePoint(200, 200);
	NSRect stringRect = { stringOrigin, stringSize };
	
	DKTextShape * newText = [DKTextShape textShapeWithString:@"" inRect:  
stringRect ];
	[newText setVerticalAlignment: kDKTextShapeVerticalAlignmentTop];
	[newText setText:attrString];
	
	// create a new object drawing layer
	DKObjectDrawingLayer* newLayer = [[DKObjectDrawingLayer alloc] init];
	
	// name the new layer
	NSString *layerName = @"TextLayer";
	[newLayer setName:layerName];
	
	// add it to the drawing and make it active - this triggers  
notifications which update the UI
	[[mDrawingView drawing] addLayer:newLayer andActivateIt:YES];
	
	// add the drawable object to the new layer
	if ([newLayer respondsToSelector:@selector(objects)])
	{
		[(DKObjectOwnerLayer *)newLayer addObject:newText];
	}
}

As you can see, I'm creating a text string with line breaks and then  
sending it to a new DKTextShape to be added to a drawing. What happens  
is that in a not-flipped drawing the text gets displayed bottom line  
at the top and top line at the bottom. The text is readable and  
displays correctly, just wrong-way top to bottom. Check out the  
attached PDF.


Any thoughts on this one? Thanks.

-Allan



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.apptree.net/pipermail/drawkit-apptree.net/attachments/20090603/d8f20884/attachment-0002.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DK text top to bottom.pdf
Type: application/pdf
Size: 118828 bytes
Desc: not available
URL: <http://lists.apptree.net/pipermail/drawkit-apptree.net/attachments/20090603/d8f20884/attachment-0001.pdf>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.apptree.net/pipermail/drawkit-apptree.net/attachments/20090603/d8f20884/attachment-0003.htm>


More information about the Drawkit mailing list