[NTG-context] underscore hyphenation

Pablo Rodriguez oinos at gmx.es
Wed Dec 10 21:03:59 CET 2014


Hans,

the sample below hyphenates right what comes before \TexC in the
paragraph. Also the contents of \TexC are hyphenated right.

But hyphen is removed from standard text after the last \TexC command in
the paragraph.

I have just accidentally discovered it.

Many thanks for your help,

Pablo



\startluacode

    function document.addfunnyhyphen(tfmdata)
        local underscore = utf.byte("_")
        local char       = tfmdata.characters[underscore]
        tfmdata.characters[0xFE000]   = {
            width    = 0,
            height   = 0,
            depth    = 0,
            commands = {
                { "right", -char.width },
                { "down", char.depth },
                { "slot", 1, underscore },
            }
        }
    end

utilities.sequencers.appendaction("aftercopyingcharacters","after","document.addfunnyhyphen")

\stopluacode

\definefontfamily[mainface][serif][GaramondNo8]
\definefontfamily[mainface][mono][Mechanica]
\setupbodyfont[mainface, 14pt]

\definetype
      [TeXcode]
      [option=TEX,
       compact=absolute,
       lines=hyphenated]

\definehyphenationfeatures
      [whatever]
      [righthyphenchar="FE000]

\setuphyphenation[method=traditional]
\sethyphenationfeatures[strict]

\unexpanded\def\TexC#1%
      {\dontleavehmode\begingroup
       \sethyphenationfeatures[whatever]%
       \normalexpanded{\TeXcode{\letterbackslash#1}}%
       \endgroup}

\starttext
        \hsize\zeropoint
        newlargewordwithhyphen
        \TexC{definebodyfont}
        newlargewordwithnohyphen
\stoptext

-- 
http://www.ousia.tk


More information about the ntg-context mailing list