is the kindle reader app's page-content recalculation after font-size change possible in a browser app?

139 Views Asked by At

Is it possible for javascript in the web-browser to (re)calculate exactly how much text will fit on a page of a given dimension, when the text is justified and the font-size is known, similar to how the Kindle reader app works? The goal would be to create a reader app that justifies the text properly and, when the user moves to the next page, that page would begin with correct word.

1

There are 1 best solutions below

1
On

Yes. The easiest (and quickest) is to assume equal character widths and estimate the number of characters per line, number of lines per page, and estimate the remaining characters. You may be one or two pages off for really large text, but you'll get close enough for everyday books.