New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cre hyphenation: allow for setting min left/right fragment length #3890

Merged
merged 5 commits into from Apr 19, 2018

Conversation

Projects
None yet
5 participants
@poire-z
Contributor

poire-z commented Apr 17, 2018

See requests and long discussion in #3848. Closes #3848
When hyphenating a word, the existing algorithms enforce a minimal length of 2 for each word fragments on left or right side.
This adds a widget to allow increasing these minimal sizes.
(The widget displays fine, but it needs crengine bump for koreader/crengine#151 for these new settings to be actually used and applied.)

We'll be able to set defaults such size in language.json if needed for some language, with this:

--- a/cr3gui/data/hyph/languages.json
+++ b/cr3gui/data/hyph/languages.json
@@ -72,6 +74,8 @@
     {
         "name": "German",
         "filename": "German.pattern",
+        "left_hyphen_min": 5,
+        "right_hyphen_min": 5,
         "language": "de",
         "aliases": ["deu"]
     },

These will be used instead of the default hardcoded values of 2.
A user can use this new widget to set his own global prefered values: these are stored in G_reader_settings, and use for all hyph dicts on all books.
These 2 prefered values are reset, erased and forgotten when he chooses Use languages defaults on the widget: after that, the language.json values or the defaults of 2 are used.
(This was easier to implement that having to manage user-prefered values per language - and I guess it will accomodate most users.)

Needs suggestions for the menu text and description, cause I have a hard time finding the correct words, while trying to be short :)

image

image

image

image

The widget is a MovableContainer: you can move it, and Hold on it to make it semi-transparent to see some more of the text under it.

(One needs to tap Apply to apply the selected values. There's one line to uncomment in the code if you want to have them auto-applied when cliciking on the up/down buttons, but this will provoke a full rendering, so it can be slow on big documents.)

poire-z added some commits Apr 17, 2018

cre hyphenation: allow for setting min left/right fragment length
When hyphenating a word, the existing algorithms enforce a minimal
length of 2 for each word fragments on left or right side.
This adds a widget to allow increasing these minimal sizes.
CloseButton:new{ window = self, padding_top = Size.margin.title, },
}
local hyph_into_text = _("Set the minimum length of word accepted on both side of the hyphenation.")

This comment has been minimized.

@Frenzie

Frenzie Apr 17, 2018

Member

both sides

Although I'd say there's something slightly off about the whole phrase.

Set minimum length before hyphenation occurs, perhaps?

@Frenzie Frenzie added the enhancement label Apr 17, 2018

@poire-z

This comment has been minimized.

Contributor

poire-z commented Apr 17, 2018

Info text updated a bit: see 2nd widget screenshot.

@Frenzie

Looks good.

local hyph_into_text = _("Set the minimum length of word accepted on both side of the hyphenation.")
local hyph_into_text = _([[
Set minimum length before hyphenation occurs.
These will apply to all books with any hyphenation dictionary.

This comment has been minimized.

@Frenzie

Frenzie Apr 17, 2018

Member

Oh actually, These settings … is better

local hyph_into_text = _([[
Set minimum length before hyphenation occurs.
These will apply to all books with any hyphenation dictionary.
'Use languages defaults' resets them.]])

This comment has been minimized.

@Frenzie

Frenzie Apr 17, 2018

Member

And a typo here, should be 'use language defaults'

(Distracted by building the new Kobo toolchain.)

@poire-z

This comment has been minimized.

Contributor

poire-z commented Apr 17, 2018

Btw, how do TeX, *Office call these LEFTHYPHENMIN in the user facing menus/widgets?
May be there's a common clearer and shorter name for these than my home-made Left/right minimal sizes...

@Frenzie

This comment has been minimized.

Member

Frenzie commented Apr 17, 2018

LaTeX is the "user facing" form of TeX. :-P But LyX might have a friendlier way of configuring it.

@cramoisi

This comment has been minimized.

Contributor

cramoisi commented Apr 17, 2018

@poire-z in Moffice they don't even propose it. They propose a hyphen zone in centimeter. In Ooffice, in french, it's "nombre de caractères avant le saut" ; "nombre de caractères après le saut", not a very short name :)

@NiLuJe

This comment has been minimized.

Member

NiLuJe commented Apr 17, 2018

It's also utterly nonsensical if you think about it. C'est un retour à la ligne, pas un saut. Ou un retour chariot si on est nostalgique...

@cramoisi

This comment has been minimized.

Contributor

cramoisi commented Apr 18, 2018

J'imagine qu'ils veulent dire "saut par dessus le petit tiret ?" :-p

@poire-z poire-z merged commit 7f6aebe into koreader:master Apr 19, 2018

1 check passed

ci/circleci Your tests passed on CircleCI!
Details

@poire-z poire-z deleted the poire-z:hyph_side_limits branch Apr 19, 2018

@cramoisi

This comment has been minimized.

Contributor

cramoisi commented Apr 19, 2018

@poire-z : neat !
reader_2018-apr-19_170553

@poire-z

This comment has been minimized.

Contributor

poire-z commented Apr 22, 2018

No problem seen with 2-1 with french books.
Could be added to cr3gui/data/hyph/languages.json as shown in the first post.
@jchtt : any suggested min values for German (less that 5/5 if you think that's too much for generic german readers :), and there's something better than the current default of 2/2?)
Same question to other languages readers :) (@robert00s @Eduardomb22 and others)

@cramoisi

This comment has been minimized.

Contributor

cramoisi commented Apr 22, 2018

@poire-z we could check the hyph*.dic files in open/libre office package to see what are their default values

@Frenzie

This comment has been minimized.

Member

Frenzie commented Apr 22, 2018

Also see the various Babel language packages. The language.dtx file will contain something like this:

https://www.ctan.org/pkg/babel-estonian

%  \begin{macro}{\estonianhyphenmins}
%     For Estonian, |\lefthyphenmin| and |\righthyphenmin| are
%    both~2. 
@Eduardomb22

This comment has been minimized.

Eduardomb22 commented Apr 22, 2018

I´m fine with 2/2 (Brazilian Portuguese)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment