fontWithName:matrix: (REPOST)
fontWithName:matrix: (REPOST)
- Subject: fontWithName:matrix: (REPOST)
- From: "Bryson, Stuart" <email@hidden>
- Date: Wed, 8 Oct 2003 11:08:45 +1000
Hi All,
I am trying to use the NSAttributedString drawAtPoint method to draw
some text in a view. I need to scale the font in x only so it looks
squished.
I thought the best way to do it would be the NSFont fontWithName:
matrix: method. The matrix is a "standard 6-element transformation
matrix as used in the PostScript language". According to the postscript
language the elements are:
1 and 4 - scale x and y
2 and 3 - rotation
5 and 6 - translation
However I can't produce useful results if the matrix is anything other
than [x 0 0 y 0 0] where x = y.
If anyone who can help me or is interested please download this project
file
http://wyvern.com.au/~stuart/fontmatrix.tar and run the program to
see what I am talking about or look at the code below.
ANY HELP WOULD BE MOST APPRECIATED!
// Declare an attributed string...
NSDictionary *atts = [NSDictionary dictionaryWithObject: [NSColor
blueColor] forKey: NSForegroundColorAttributeName];
NSMutableAttributedString *attString = [[NSMutableAttributedString
alloc] initWithString:@"Blah" attributes:atts];
// this one works
float myMatrix[6] = {100,0,0,100,0,0};
// this one doesn't
// float myMatrix[6] = {100,0,0,50,0,0};
NSFont *myMatrixFont = [NSFont fontWithName:@"Times-Roman"
matrix:myMatrix];
[attString addAttribute:NSFontAttributeName value:myMatrixFont
range:NSMakeRange(0,3)];
[subView lockFocus];
[attString drawAtPoint:NSMakePoint(100,120)];
[subView unlockFocus];
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.