• 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: slow text drawing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: slow text drawing


  • Subject: Re: slow text drawing
  • From: Douglas Davidson <email@hidden>
  • Date: Fri, 21 Feb 2003 14:47:50 -0800

On Friday, February 21, 2003, at 1:11 PM, Simon Olsberg wrote:

I am trying to look for ways to speed up text drawing for a
spreadsheet-type view in my application but do not seem to be getting
very good results.

I have abstracted the problem into the simple example below which draws
a series of random strings in a grid. If you size the window quite
large to about a grid of 20 x 40 or around 800 strings there is a
significant wait for the view to redraw - a couple of seconds.

I can't believe that this is the fastest that Cocoa can manage and
would appreciate any tips on how to speed things up. I have also tried
to use NSLayoutManager & NSTextStorage directly but this seems to do no
better.

Your example alters the strings every time the view is drawn, which places you in the worst possible case--all of the text must be laid out at every iteration. If this is really what you intend, it limits the sort of optimizations you can use; one might be to use a monospaced font, in particular Courier or Monaco.

If you expect some of your strings to remain the same from one drawing iteration to the next, then you can employ some caching using NSLayoutManager. I would suggest placing each string on a separate line in the text storage, then using NSLayoutManager to draw them, somewhat along the lines of the CircleView example.

There are other optimizations that can be used--check the archives for some of my previous posts on this topic--but these are the ones I would probably try first in this case.

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: 
 >slow text drawing (From: Simon Olsberg <email@hidden>)

  • Prev by Date: Re: NSURL proxy request error for http://localhost?
  • Next by Date: Re: NSURL proxy request error for http://localhost?
  • Previous by thread: slow text drawing
  • Next by thread: [ANN]: Weak linking/Availability Macros technote updated
  • Index(es):
    • Date
    • Thread