• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
fontWithName:matrix: (REPOST)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: NSAcceptMisspelledSelectors and - (void)performMethodsUsingFuzzyM ethodNameMatching
  • Next by Date: Detecting keyDown in a NSTextField?
  • Previous by thread: [SOLVED] Re: NSTextField responder chain question...
  • Next by thread: Detecting keyDown in a NSTextField?
  • Index(es):
    • Date
    • Thread