lua code prevents compilation
Dear list, I have the following sample: \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 \def\CoverImageFile{}%\externalfigure[TypeWriter][width=\textwidth]} \definefontfamily[ornamenta][rm][FontAwesome] \def\CoverImageFont{\scale[width=\textwidth]{\ornamenta }} \def\CoverImage{\doifsomethingelse{\CoverImageFile}{\CoverImageFile}{\CoverImageFont}} \starttext \CoverImage \stoptext For some reason unknown to me, the only way to compile the sample is to remove the luacode snippet. I need the lua code to have underscore hyphenation in type commands. And I need two extra \definehyphenationfeatures and \sethyphenationfeatures to invoke it. Have I hit a bug or what am I missing? Many thanks for your help, Pablo -- http://www.ousia.tk
On 3/30/2015 5:19 PM, Pablo Rodriguez wrote:
Dear list,
I have the following sample:
\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
\def\CoverImageFile{}%\externalfigure[TypeWriter][width=\textwidth]} \definefontfamily[ornamenta][rm][FontAwesome] \def\CoverImageFont{\scale[width=\textwidth]{\ornamenta }} \def\CoverImage{\doifsomethingelse{\CoverImageFile}{\CoverImageFile}{\CoverImageFont}}
\starttext \CoverImage \stoptext
For some reason unknown to me, the only way to compile the sample is to remove the luacode snippet.
I need the lua code to have underscore hyphenation in type commands. And I need two extra \definehyphenationfeatures and \sethyphenationfeatures to invoke it.
Have I hit a bug or what am I missing?
I don't know as i see nothing at all with that code .. this is more fun: \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 }, } } tfmdata.characters[0xFE001] = { width = 0, height = 0, depth = 0, commands = { { "down", char.depth }, { "slot", 1, underscore }, { "right", char.width }, } } end utilities.sequencers.appendaction("aftercopyingcharacters","after","document.addfunnyhyphen") \stopluacode \setuplanguage[en][righthyphenchar="FE000,lefthyphenchar="FE001] \starttext \input tufte \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 -----------------------------------------------------------------
On 03/30/2015 10:33 PM, Hans Hagen wrote:
On 3/30/2015 5:19 PM, Pablo Rodriguez wrote:
[...] For some reason unknown to me, the only way to compile the sample is to remove the luacode snippet.
I need the lua code to have underscore hyphenation in type commands. And I need two extra \definehyphenationfeatures and \sethyphenationfeatures to invoke it.
Have I hit a bug or what am I missing?
I don't know as i see nothing at all with that code .. this is more fun:
Many thanks for your reply, Hans, The following code shows the problem: \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[ornamenta][rm][TypographyTribute] \definehyphenationfeatures[underscore][righthyphenchar="FE000] \setuphyphenation[method=traditional] \sethyphenationfeatures[strict] \setupbodyfont[ornamenta] \starttext \hsize\zeropoint {\sethyphenationfeatures[underscore]\tt pandoc} A \stoptext If you uncomment the line with the font definition, font loading crashes compilation. It only crashes with this font (http://www.dafont.com/typographytribute.font) or FontAwesome (http://www.fontawesome.io). Both lack the underscore glyph. This causes the crash, since it works fine if I replace the glyph with an existing glyph in the font. Error message: code.tex: ! LuaTeX fatal error error in error handling \font_helpers_low_level_define ...\scaledfontmode \relax \ifcase \scaledfont... \font_helpers_trigger_define ..._identifier_class \csname \v_font_identifier... \applyfontclassstrategies ...\fontface \endcsname \else \expandafter \font_h... \font_helpers_synchronize_font ...classstrategies \fi \setfalse \c_font_auto... \rm ->\ifmmode \mathrm \else \normalrm \fi \font_basics_switch_style ...ntstyle #1\endcsname \edef \fontstyle {#1}\ifmm... ... Would it be possible that ConTeXt silently ignores that the font doesn’t contain the glyph? I think this might be a bug. Many thanks for your help, Pablo -- http://www.ousia.tk
On 4/2/2015 1:21 AM, Pablo Rodriguez wrote:
On 03/30/2015 10:33 PM, Hans Hagen wrote:
On 3/30/2015 5:19 PM, Pablo Rodriguez wrote:
[...] For some reason unknown to me, the only way to compile the sample is to remove the luacode snippet.
I need the lua code to have underscore hyphenation in type commands. And I need two extra \definehyphenationfeatures and \sethyphenationfeatures to invoke it.
Have I hit a bug or what am I missing?
I don't know as i see nothing at all with that code .. this is more fun:
Many thanks for your reply, Hans,
The following code shows the problem:
\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[ornamenta][rm][TypographyTribute] \definehyphenationfeatures[underscore][righthyphenchar="FE000] \setuphyphenation[method=traditional] \sethyphenationfeatures[strict] \setupbodyfont[ornamenta] \starttext \hsize\zeropoint {\sethyphenationfeatures[underscore]\tt pandoc} A \stoptext
If you uncomment the line with the font definition, font loading crashes compilation. It only crashes with this font (http://www.dafont.com/typographytribute.font) or FontAwesome (http://www.fontawesome.io).
Both lack the underscore glyph. This causes the crash, since it works fine if I replace the glyph with an existing glyph in the font.
Error message:
code.tex: ! LuaTeX fatal error error in error handling \font_helpers_low_level_define ...\scaledfontmode \relax \ifcase \scaledfont... \font_helpers_trigger_define ..._identifier_class \csname \v_font_identifier... \applyfontclassstrategies ...\fontface \endcsname \else \expandafter \font_h... \font_helpers_synchronize_font ...classstrategies \fi \setfalse \c_font_auto... \rm ->\ifmmode \mathrm \else \normalrm \fi \font_basics_switch_style ...ntstyle #1\endcsname \edef \fontstyle {#1}\ifmm... ...
Would it be possible that ConTeXt silently ignores that the font doesn’t contain the glyph?
the message is fuzzy (and i have to check a lua stack issue maybe but not now) ... if char is nil then char.depth is an error
I think this might be a bug.
function document.addfunnyhyphen(tfmdata) local underscore = utf.byte("_") local char = tfmdata.characters[underscore]
if not char then return end
tfmdata.characters[0xFE000] = { width = 0, height = 0, depth = 0, commands = { { "right", -char.width }, { "down", char.depth }, { "slot", 1, underscore }, } } end
----------------------------------------------------------------- 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 -----------------------------------------------------------------
On 04/02/2015 02:23 AM, Hans Hagen wrote:
On 4/2/2015 1:21 AM, Pablo Rodriguez wrote:
[...] Both lack the underscore glyph. This causes the crash, since it works fine if I replace the glyph with an existing glyph in the font. [...] Would it be possible that ConTeXt silently ignores that the font doesn’t contain the glyph?
the message is fuzzy (and i have to check a lua stack issue maybe but not now) ... if char is nil then char.depth is an error
I think this might be a bug.
function document.addfunnyhyphen(tfmdata) local underscore = utf.byte("_") local char = tfmdata.characters[underscore]
if not char then return end
Many thanks for your help, Hans. This solves my issue. Pablo -- http://www.ousia.tk
participants (2)
-
Hans Hagen
-
Pablo Rodriguez