On 22/9/00 1:51 am, Geoff Canyon <[EMAIL PROTECTED]> wrote:

> I'm wondering if anyone here has experience writing pagination routines in
> MetaCard. I'm considering writing a routine that would take a 50-100k block
> of text, a font, a font size, a field size, and figure out where the page
> breaks should occur from beginning to end.
> 
> The actual goal is to be able to go to an arbitrary chunk of the text, and
> know what page number to put under it.
> 
> My first instinct is to use the height of the field and the formattedHeight
> function on chunks of text, finding page-sized chunks and counting them
> until I get to the chunk I want to display. but this is fairly slow across
> perhaps hundreds of pages. By slow I mean more than a second on a fast
> computer.

That sounds quite fast: how fast do you need it to be?  The print field
script in mctools must do something like this - did you take a look at that
to see how they did it?

> But my second instinct is to figure out how many lines will fit onto one
> page, figure out how tall those lines are individually, and then just search
> for the largest n such that n*(the number of lines that will fit on a page)
> is still less than the chunk I want to display, and then use n+1 for a page
> number. I'm sure that's not clear, but if someone's done it, I'm betting it
> will be clear to them. This might be much faster, but will it work?

We have done a fair number of text calculations based on the scroll position
vs. the height of the line.  Set and use the textHeight property of the
field.  Note that the property does not always save (for historical reasons
unless you are setting other text font properties on the field you may need
to set this on preOpenCard each time to make it persist).  And don't forget
the margins in your calculations (a small adjustment).  This system will
however, only work if you have the fixedLineHeight of the field set to true.
Otherwise lines may differ in height and this calculation becomes useless.

Regards,

Kevin

> Thanks to anyone who has a suggestion,
> 
> Geoff

Kevin Miller <[EMAIL PROTECTED]> <http://www.runrev.com/>
Runtime Revolution Limited (formerly Cross Worlds Computing).
Tel: +44 (0)131 672 2909.  Fax: +44 (0)1639 830 707.


Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to