View Issue Details

IDProjectCategoryView StatusLast Update
0000340luatexfeature requestpublic2010-03-12 15:46
Reporterpatrick Assigned ToTaco  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Target Version0.60.0Fixed in Version0.51.0 
Summary0000340: Call line breaking algorithm from lua
DescriptionI would like to create (from inside Lua) a nodelist and afterwards do something like

new_head = tex.linebreak_nodelist(my_nodelist_head,parameters)

and the result is a nodelist or a box that I can put into TeX's main vertical list or just find out how big it is.

That means, I would like to do

\setbox1\vbox{my paragraph}

without TeX's input language and have the result in tex.box[1]
TagsNo tags attached.

Activities

Taco

2010-03-08 18:17

administrator   ~0000463

There is a new lua function in TRUNK and the bin on Hans' ftp:

  local <node> nodelist, <sp> founddepth =
       tex.linebreak(<node> listhead, <table> parameters)

The understood parameters are as follows:


    d = false, % boolean
    pardir = 'TLT', % dir
    pretolerance = 100, % number
    tracingparagraphs = 0, % number
    tolerance = 200, % number
    looseness = 0, % number
    hyphenpenalty = 50, % number
    exhyphenpenalty = 50, % number
    pdfadjustspacing = 0, % number
    adjdemerits = 10000, % number
    pdfprotrudechars = 0, % number
    linepenalty = 10, % number
    lastlinefit = 0, % number
    doublehyphendemerits = 10000, % number
    finalhyphendemerits = 5000, % number
    hangafter = 1, % number
    interlinepenalty = 0, % number
    clubpenalty = 150, % number
    displaywidowpenalty = 150, % number
    widowpenalty = 150, % number
    brokenpenalty = 100, % number
        emergencystretch = 0, % sp
    hangindent = 0, % sp
    hsize = 65536*72*4, % sp
    leftskip = spec, % glue_spec node
    rightskip = spec, % glue_spec node
    pdfeachlineheight = -65536000, % sp
    pdfeachlinedepth = -65536000, % sp
    pdffirstlineheight =-65536000, % sp
    pdflastlinedepth = -65536000, % sp
    pdfignoreddimen = -65536000, % sp

The 'd' is whether or not this should be taken as a pre-math-display
subparagraph, everything else should be fairly obvious except for
the last 5. The four pdf...line... things are ignored if their value
equals pdfignoreddimen.

It is your own job to make sure that 'listhead' is a proper paragraph
list: this function does not add any nodes to it. To be exact, if
you want to replace the core line breaking, you may have to do the following (when you are not actually working in the pre_line_break or
line_break callback, or when the original list starting at listhead
was generated in horizontal mode):

* add an 'indent box' and perhaps a local_par node at the start
  (only if you need them)
* replace any found final glue by an infinite penalty (or add such
  a penalty, if the last node is not a glue).
* add a glue node for the \parfillskip after that penalty.

The result is a node list, it still needs to be vpacked if you
want to assign it to a box.

There are a few things you cannot interface using this function, because
there is no lua glue for the underlying data yet:

  \parshape
  \interlinepenalties
  \clubpenalties
  \displaywidowpenalties
  \widowpenalties

You can't influence font expansion other than via 'pdfadjustspacing',
because the settings for that take place elsewhere. The same is true
for hbadness and hfuzz etc. All these are in the hpack() routine, and
that fetches its own variables via globals.

Issue History

Date Modified Username Field Change
2010-03-04 14:32 patrick New Issue
2010-03-04 15:37 Taco Assigned To => Taco
2010-03-04 15:37 Taco Status new => assigned
2010-03-04 15:37 Taco Target Version => 0.60.0
2010-03-08 18:17 Taco Note Added: 0000463
2010-03-08 18:17 Taco Status assigned => resolved
2010-03-08 18:17 Taco Resolution open => fixed
2010-03-12 15:46 Taco Fixed in Version => 0.51.0
2010-03-12 15:46 Taco Status resolved => closed