View Full Version : Text rectangle

10-04-2012, 03:33 AM

Looking some paper books (these things happen), I found this (see screenshot) which looks nice and gave me the idea to adapt it for some MR ebooks.

However the text block shape must be perfectly rectangular to look nice. Is it possible to achieve this on a digital book? I already have the small-caps. :)

10-04-2012, 05:05 AM
Not with ePub 2.1, but in CSS3 (maybe some day usable in ePub 3) there is "text-align-last: justify", which together with "text-align: justify" should give you what you want.

10-04-2012, 06:44 AM
Ah... so we'll wait a little. Thanks for the reply.

10-04-2012, 08:46 AM
How about creating an image with Inkscape ( By manipulating the spacing between letters and words and the font size for each line you should be able to get an image that'll be a close match of the hardcopy.

10-04-2012, 12:14 PM
I don't practice Inkscape but I'll have a look.

10-04-2012, 04:28 PM
Why not try putting it in a simple table of 1 row and 1 column and using that to get the text to do what you want?

10-05-2012, 05:33 AM
He wants all lines to be justified to both margins, I don't think a table does that.

10-05-2012, 05:59 AM
This is a bit of a hack, but might be suitable for small amounts of text. If you aren't worried about where the line breaks come in the block of text, it could be simplified, but it looks to me like you wanted specific line breaks and for all lines to be justified.

It works by making sure there's some invisible text (the non-breaking spaces) that's forced onto the next line as a unit (that's the non-breaking bit), but that won't go onto a second line (as it's white space).

By forcing the line height to be smaller than 100%, we make the spacing between the lines adjust as we want.

By limit the width of the paragraph block, we prevent unfortunate wrapping or non-wrapping.

I suspect it'll be possible to centre the text block as well, perhaps by wrapping the paragraph in another div.

<p style="line-height:60%; text-align:justify; min-width: 20em; max-width:40em">
This is some text in a paragraph to be &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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