On 12/4/2014 8:21 PM, Pablo Rodriguez wrote:
On 12/03/2014 08:30 PM, Hans Hagen wrote:
no need to mess like that:
Many thanks for your reply, Hans.
Sorry, but the Lua code for the underscore hyphenation is all Greek to me.
I need the two following features: use the underscore character from the font and enable it only for certain commands, not for the whole text.
Here is a minimal sample:
\showframe \setupcolor[state=start] \setuplayout[backspace=95mm, width=middle] \definetype[TeXcode][option=TEX, compact=absolute] \unexpanded\def\tex#1{\normalexpanded{\TeXcode{\letterbackslash#1}}} \starttext \tex{thisisaverylongcommand} \hyphenatedurl{http://optimisticwayofthinking.optimist} \input knuth \stoptext
The text from Knuth needs to have the standard hyphenation character, although the other two commands need to have underscore hyphenation.
Which is the best way to do it?
it's no big deal to extend the mechanism to support this ... \definetype [TeXcode] [option=TEX, compact=absolute, lines=hyphenated] \definehyphenationfeatures [whatever] [righthyphenchar=_] \setuphyphenation [method=traditional] \unexpanded\def\TexC#1% {\dontleavehmode\begingroup \sethyphenationfeatures[whatever]% \normalexpanded{\TeXcode{\letterbackslash#1}}% \endgroup} \starttext \input tufte \dorecurse{100}{\TexC{definebodyfont} } \input tufte \stoptext i'll upload a beta (making one now)
Many thanks for your help again,
Pablo
\startluacode
local function addfunnyhyphen(tfmdata) local exheight = tfmdata.parameters.xheight local emwidth = tfmdata.parameters.quad local width = emwidth local height = exheight / 10 local depth = exheight / 2 tfmdata.characters[0xFE000] = { width = 0, height = 0, depth = 0, commands = { { "right", -width }, { "down", depth }, { "rule", height, width }, } } end
fonts.constructors.newfeatures("otf").register { name = "funnyhyphen", description = "funny hyphen", manipulators = { base = addfunnyhyphen, node = addfunnyhyphen, } }
\stopluacode
\definefontfeature[default][default][funnyhyphen=yes]
\starttext
\prehyphenchar"FE000
\hsize 1mm
averylongword
\stoptext
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------