V
V
Vitaly Petrov2012-01-24 17:48:06
JavaScript
Vitaly Petrov, 2012-01-24 17:48:06

Text alignment and/or pagination?

Good afternoon. This is the problem I have. Let's say we have a book in fb2 format. It is necessary, for example, to open this book on a mobile phone with a small resolution. Question: are there libraries (js or php) that allow you to break large text into pages depending on the height / width of a given page? In addition, I would like such a library to handle the moment when a word seems to need to be transferred, but if it is transferred, then an empty space will remain in the line. which means that the word must be correctly divided into two parts using a hyphen (-). More shortly to implement transfer on syllables. For Russian and English languages ​​(although I think there are no special differences in the hyphenation rule for different languages) ...
I read an article on the wiki, but there is no hyphenation by syllables en.wikipedia.org/wiki/Justification_(typesetting)
In short, for example from this:
" -
Rows of teeth - repeated oh my God - Just rows, you know? By the way, who is this tooth fairy?
- Oh, you can often see her these days, - said Susan. under license. You take a ladder, a belt for money, pincers - and forward, into the night!
- Ticks?
- If the tooth fairy does not have change, he pulls out one or more teeth so as not to violate reporting.
"
It turned out like this:
"
-Rows of teeth repeated oh god, "Just rows, you know
? By the way, who is the tooth fairy?
"
red, at night!
- Ticks?
-If the tooth fairy has no change, she pulls out
one or more teeth so as not to violate the
accountability.
"
It turned out bad, but I think the essence is clear ...
Of course, centering the text on the width is not good to do, and I may not spend much time on syllables, but I would like to know if there are ready-made solutions ... I saw this, for example, in the ZXReader application for Simba ... It seems nowhere else.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Riateche, 2012-01-24
@vitaly_KF

code.google.com/p/hyphenator/
Checked, works well. Supports many languages, including Russian.
> (although I think there are no special differences in the hyphenation rule for different languages)
The hyphenation rules in Russian and English are fundamentally different.

A
Anatoly, 2012-01-24
@taliban

PHP and JS don't work that well with text. + (I may be wrong further) according to my text reader programs, the text “draws” the text, gets the width and height of the line based on the font that will be drawn, and then operate on numbers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question