The text justification and/or pagination?

Good day. That's the problem I have. Let's say we have the book in fb2 format. It is necessary for example to open this book on my phone with a small resolution. Question: are there any libraries (js, php Ali) that allow you to split a large text into pages depending on the height/width of the page? In addition, I would like that this library has processed the moment the word seems to be necessary to move it, but if it is to move, the line will remain blank. so the word should properly be divided into two parts using a hyphen (-). In short, to implement the transfer of the syllables. For Russian and English languages (although I think the transfer rule by syllables no significant differences for different languages)...

I read on the wiki article, but there is no transfer of the syllables en.wikipedia.org/wiki/Justification_(typesetting)

In short, in order for example of this:

"

The rows of teeth repeated Oh my God — Just rows, you know? By the way who is this tooth fairy?

-Oh now she can often be seen, ' said Susan. Or rather them. They work under license. Take the stairs, the money belt, pliers and go at night!

-Pliers?

-If there's no tooth fairy stuff, he pulls out one or more teeth, not to break records.

"

It turned out this:

"

The rows of teeth repeated Oh my God — Just rows,

you know? By the way who is this tooth fairy?

-Oh now she can often be seen, said

Susan. Or rather them. They work under license.

Take the stairs, the money belt, mites and VPE-

red at night!

-Pliers?

-If there's no tooth fairy stuff, she pulls

one or more teeth in order not to violate

reporting.

"

Vyschla bad, but I think you get the gist...


Of course the width of the text to center nefig to do, and the syllables may not be much time to spend, but I would like to know — suddenly there are ready-made solutions... Saw this example in the app ZXReader for Simba... More like anywhere else.
October 8th 19 at 03:54
2 answers
October 8th 19 at 03:56
Solution
code.google.com/p/hyphenator/
Checked, works well. Supports many languages, including Russian.

> (although I think the transfer rule by syllables no significant differences for different languages)
The rules of hyphenation in Russian and English are radically different.
What you need! Thank you! - shawn commented on October 8th 19 at 03:59
October 8th 19 at 03:58
PHP and JS not so well with text. + (then I could be wrong) in my program reader the text "paint" the text, get the width and height of the row based on the font which to draw, and then use figures.
Thought about it but didn't want to believe) - shawn commented on October 8th 19 at 04:01

Find more questions by tags Text processingNode.jsJavaScript