Thread: JBPatch
View Single Post
Old 07-30-2012, 04:42 PM   #339
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,907
Karma: 6736094
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
Upcoming: justification and hyphenation patch

Hi,

I had already started to develop this some time ago, but then froze development of that particular patch because of the release of JBPatch 2.

Now, because the default formatting is really quite bad (IMO), I came back to this project. It's more or less working, but I would like to get some feedback first.

The fact that the default formatting looks so bad is actually caused by the combination of two different (but somewhat interdependent) shortcomings of the reader software:
  • First, there is no hyphenation support. This means that words which don't fit at the end of the current line will be put on a new line, instead of being hyphenated. This is particularly annoying for languages which tend to contain long words, such as german.
  • Second, for some reason that only the developers know, lines are not always filling the block size. This results in a really ugly layout, where most of the lines are "block-aligned", but where some lines are shorter than the rest.

The patch which is currently under development can, in principle, fix all of these issues. For now, I have implemented three different modes:
  • Block alignment only: This does not involve any hyphenation, but will simply make sure that all lines (except for the ones ending a paragraph) stretch, so that they are left- and right-aligned. This alone already provides a much more pleasant visual experience.
  • Dumb hyphenation: this mode allows words to be hyphenated almost everywhere.
  • Smart hyphenation: In this mode, language-specific rules are considered to determine where hyphenation can occur. This generally leads to much more sensible ("natural") results, even if they aren't always perfect. The downside is that it requires a bit more processing power and memory - and the hyphenation rules, of course. At the moment, rules for about 160 locales are available.

Below are sample screenshots for an english (first row) and a german book (second row). Each row is ordered as follows:
  1. Default K5 display
  2. Justification only, no hyphenation
  3. Justification + dumb hyphenation
  4. Justification + smart hyphenation

Click image for larger version

Name:	screen-en-0default.gif
Views:	446
Size:	37.3 KB
ID:	89928Click image for larger version

Name:	screen-en-1aligned.gif
Views:	435
Size:	37.2 KB
ID:	89929Click image for larger version

Name:	screen-en-2dumb.gif
Views:	470
Size:	38.0 KB
ID:	89930Click image for larger version

Name:	screen-en-3full.gif
Views:	440
Size:	37.9 KB
ID:	89931

Click image for larger version

Name:	screen-de-0default.gif
Views:	430
Size:	39.5 KB
ID:	89932Click image for larger version

Name:	screen-de-1aligned.gif
Views:	399
Size:	39.5 KB
ID:	89933Click image for larger version

Name:	screen-de-2dumb.gif
Views:	399
Size:	42.0 KB
ID:	89934Click image for larger version

Name:	screen-de-3full.gif
Views:	435
Size:	41.6 KB
ID:	89935

Please take a look at these and let me know what you think. At the moment, I'm inclined to make the patch configurable to select between options 2) and 4), but suggestions and feedback are highly appreciated.

Note: Yes, the hyphen character is an "@". This is intentional, because it makes it easier to spot the locations where hyphenation has kicked in. Of course, this will be fixed in the final version.

Last edited by ixtab; 07-30-2012 at 09:25 PM. Reason: minor corrections
ixtab is offline   Reply With Quote