summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/linebreaker/linebreaker.sty
blob: 2804f4bbe6966451ce1fb5fbf150782310117735 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
\ProvidesPackage{linebreaker}

\RequirePackage{luatexbase}
\directlua{%
linebreaker = require "linebreaker"
luatexbase.add_to_callback("linebreak_filter", linebreaker.linebreak, "new linebreak callback")
luatexbase.add_to_callback("post_linebreak_filter", linebreaker.post_linebreak, "new linebreak callback")
luatexbase.add_to_callback("hpack_quality", linebreaker.hpack_quality, "Our overfull box reporting function")
}


% linebreaker setup
\ExplSyntaxOn
\keys_define:nn{linebreaker}{
  debug .code:n = \directlua{linebreaker.debug=true},
  maxtolerance .code:n = \directlua{linebreaker.max_tolerance = tonumber("#1")},
  maxemergencystretch .code:n = \directlua{linebreaker.max_emergencystretch = tex.sp("#1")},
  maxcycles .code:n = \directlua{linebreaker.max_cycles = tonumber("#1")},
}
\NewDocumentCommand{\linebreakersetup}{m}{
\keys_set:nn {linebreaker} {#1}
}
\ExplSyntaxOff

% enable/disable linebreaker
\NewDocumentCommand{\linebreakerenable}{}{\directlua{linebreaker.active=true}}
\NewDocumentCommand{\linebreakerdisable}{}{\directlua{linebreaker.active=false}}



\endinput