• 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
Re: How to perform zooming on text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to perform zooming on text


  • Subject: Re: How to perform zooming on text
  • From: Douglas Davidson <email@hidden>
  • Date: Thu, 31 Oct 2002 09:19:45 -0800

On Thursday, October 31, 2002, at 12:30 AM, Arnaud Forgiel wrote:

I'm currently trying to implement some text viewer/editor features in my app, at different scale (or zooming factor). Despite all the information available on NSMutableAttributedString, NSLayoutManager, NSTextStorage, etc., I didn't find a (easy) way to draw formatted text in a rectangle with a scaling factor not equal to 1. The cocoa documentation mentions an attribute named "ViewZoom" but changing it doesn't work.

Does anybody know how to perform such a task? One obvious solution would be to parse the attributes and to change the font size information "on the fly". This is still a "heavy" solution in contradiction with the MVC model (it changes the model info for the view).

BTW, I'm using the NSLayoutManager drawing methods, without a NSTextView. It follows the same approach as in the Sketch cocoa example from Apple.

You don't see this documented with the text system because it is in no way specific to text. In the Quartz drawing model, any drawing can be zoomed (or rotated, or generally affine transformed). All you have to do is change the CTM.

There are several ways you can do this; probably the simplest is to just change the coordinate system of your view. See the TextEdit sources for an example of this--to zoom, basically you can just change the coordinate system of the view by setting its bounds independently of its frame. See the NSView documentation for a detailed discussion.

If you wish to scale only a portion of a view, you can apply a particular affine transformation to that portion of your drawing code, using NSAffineTransform's concat method. You will probably want to set it back, though, if you have more drawing to do in that view after that, perhaps by applying the inverse transformation (possibly inexact), or by saving and restoring the graphics state around that drawing.

The ViewZoom document attribute is stored with RTF text. It is not a character attribute; it is an attribute associated with the entire document. It indicates the magnification the user was using for the document when it was saved. TextEdit, for example, uses this information to decide what magnification to use when displaying a newly opened document. See the TextEdit code for an example.

Douglas Davidson
_______________________________________________
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.

References: 
 >How to perform zooming on text (From: Arnaud Forgiel <email@hidden>)

  • Prev by Date: Re: [ot] file menu ordering
  • Next by Date: Newbie Locating Fonts Question
  • Previous by thread: Re: How to perform zooming on text
  • Next by thread: spaces in pahts
  • Index(es):
    • Date
    • Thread