John Levon wrote:
To improve further, consider the insets in the paragraph by having a default size for each type and take that into account. Now, we are linear

There's no such thing as a linear size for figures, so this is guaranteed to go wrong in the worst possible cases (very large figures).

I believe it is monotoneously better to estimate all figures at say 200x200 pixels, rather than at 0x0 pixels like it does now.


The linear bit in my sentence refers to the time it takes to estimate the height of a paragraph: The algorithm is roughly something like this:

  int x = 0;
  int y = average-character-height;
  for (int i = 0; i != numberOfInsets-in-paragraph; ++i) {
        // First estimate size of the text
        x += average-character-width
                * number-of-characters-in-paragraph
                /   numberOfInsets-in-paragraph;
        y += (x / width-available) * average-character-height;
        x = x % width-available;

        // Next estimate size of the insets
        x += average-width-of-inset-at-position(i);

        if (x > width-available) {
                y += average-height;
                x = x % width-available;
        }
  }

Notice small constant factors and linear time in number of insets. That should be fast enough, and improve tremendously on a totally static estimate.

My point is that this estimation routine can be continuously refined until it represents a complete rendering of the paragraph. We need to try and find out how fine-grained the estimate has to be in order for the scroll bar to be usable.

Regards,
Asger

Reply via email to