used_font always return false
Hi, the node(.direct).uses_font helpers currently always return false for glyph nodes: In the implementation static int lua_nodelib_direct_uses_font(lua_State * L) { halfword n = lua_tointeger(L,1); halfword f = lua_tointeger(L,2); halfword p; if (type(n) == glyph_node) { lua_pushboolean(L,font(n) == f); } else if (type(n) == disc_node) { uses_font_disc(pre_break,p,n); uses_font_disc(post_break,p,n); uses_font_disc(no_break,p,n); } /* todo: other node types */ lua_pushboolean(L,0); return 1; } the actual result is first calculated, but then the last pushboolean pushes a `false` on top of the stack and return this false. It could e.g. be fixed by adding a `return 1;` at the end of the first if block. `disc` nodes are not affected because uses_font_disc is a macro containing `return`. A minimal example in plain LuaTeX: \directlua{ local g = node.new'glyph' g.font = font.current() if not node.uses_font(g, font.current()) then error'This should not happen' end node.free(g) } \bye -- Marcel
On Tue, Sep 17, 2019 at 2:52 PM Marcel Fabian Krüger
Hi,
the node(.direct).uses_font helpers currently always return false for glyph nodes: In the implementation
static int lua_nodelib_direct_uses_font(lua_State * L) { halfword n = lua_tointeger(L,1); halfword f = lua_tointeger(L,2); halfword p; if (type(n) == glyph_node) { lua_pushboolean(L,font(n) == f); } else if (type(n) == disc_node) { uses_font_disc(pre_break,p,n); uses_font_disc(post_break,p,n); uses_font_disc(no_break,p,n); } /* todo: other node types */ lua_pushboolean(L,0); return 1; }
the actual result is first calculated, but then the last pushboolean pushes a `false` on top of the stack and return this false. It could e.g. be fixed by adding a `return 1;` at the end of the first if block. `disc` nodes are not affected because uses_font_disc is a macro containing `return`.
A minimal example in plain LuaTeX:
\directlua{ local g = node.new'glyph' g.font = font.current() if not node.uses_font(g, font.current()) then error'This should not happen' end node.free(g) } \bye
hm, probably a missed else, ie } else { /* todo: other node types */ lua_pushboolean(L,0); } -- luigi
On 17 September 2019 14:56:20 CEST, luigi scarso
On Tue, Sep 17, 2019 at 2:52 PM Marcel Fabian Krüger
wrote: Hi,
the node(.direct).uses_font helpers currently always return false for glyph nodes: In the implementation
static int lua_nodelib_direct_uses_font(lua_State * L) { halfword n = lua_tointeger(L,1); halfword f = lua_tointeger(L,2); halfword p; if (type(n) == glyph_node) { lua_pushboolean(L,font(n) == f); } else if (type(n) == disc_node) { uses_font_disc(pre_break,p,n); uses_font_disc(post_break,p,n); uses_font_disc(no_break,p,n); } /* todo: other node types */ lua_pushboolean(L,0); return 1; }
the actual result is first calculated, but then the last pushboolean pushes a `false` on top of the stack and return this false. It could e.g. be fixed by adding a `return 1;` at the end of the first if block. `disc` nodes are not affected because uses_font_disc is a macro containing `return`.
A minimal example in plain LuaTeX:
\directlua{ local g = node.new'glyph' g.font = font.current() if not node.uses_font(g, font.current()) then error'This should not happen' end node.free(g) } \bye
hm, probably a missed else, ie
} else { /* todo: other node types */ lua_pushboolean(L,0); }
That wouldn't quite work because the uses_font_disc code only returns if the result is true, so pushboolean would also be needed in the disc case.
On Tue, Sep 17, 2019 at 3:27 PM Marcel Krüger
} else { /* todo: other node types */ lua_pushboolean(L,0); }
That wouldn't quite work because the uses_font_disc code only returns if the result is true, so pushboolean would also be needed in the disc case.
yes, with a note that uses_font_disc can return . -- luigi
On 9/17/2019 2:56 PM, luigi scarso wrote:
On Tue, Sep 17, 2019 at 2:52 PM Marcel Fabian Krüger
mailto:tex@2krueger.de> wrote: Hi,
the node(.direct).uses_font helpers currently always return false for glyph nodes: In the implementation
static int lua_nodelib_direct_uses_font(lua_State * L) { halfword n = lua_tointeger(L,1); halfword f = lua_tointeger(L,2); halfword p; if (type(n) == glyph_node) { lua_pushboolean(L,font(n) == f); } else if (type(n) == disc_node) { uses_font_disc(pre_break,p,n); uses_font_disc(post_break,p,n); uses_font_disc(no_break,p,n); } /* todo: other node types */ lua_pushboolean(L,0); return 1; }
the actual result is first calculated, but then the last pushboolean pushes a `false` on top of the stack and return this false. It could e.g. be fixed by adding a `return 1;` at the end of the first if block. `disc` nodes are not affected because uses_font_disc is a macro containing `return`.
A minimal example in plain LuaTeX:
\directlua{ local g = node.new'glyph' g.font = font.current() if not node.uses_font(g, font.current()) then error'This should not happen' end node.free(g) } \bye
hm, probably a missed else, ie
} else { /* todo: other node types */ lua_pushboolean(L,0); }
if (type(n) == glyph_node) { lua_pushboolean(L,font(n) == f); return 1; in the luatex version two times return 1 needs to be added (sorry, it went unnoticed because in lm hese returns are there) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On Thu, Sep 19, 2019 at 8:29 PM Hans Hagen
On 9/17/2019 2:56 PM, luigi scarso wrote:
On Tue, Sep 17, 2019 at 2:52 PM Marcel Fabian Krüger
mailto:tex@2krueger.de> wrote: Hi,
the node(.direct).uses_font helpers currently always return false for glyph nodes: In the implementation
static int lua_nodelib_direct_uses_font(lua_State * L) { halfword n = lua_tointeger(L,1); halfword f = lua_tointeger(L,2); halfword p; if (type(n) == glyph_node) { lua_pushboolean(L,font(n) == f); } else if (type(n) == disc_node) { uses_font_disc(pre_break,p,n); uses_font_disc(post_break,p,n); uses_font_disc(no_break,p,n); } /* todo: other node types */ lua_pushboolean(L,0); return 1; }
the actual result is first calculated, but then the last pushboolean pushes a `false` on top of the stack and return this false. It could e.g. be fixed by adding a `return 1;` at the end of the
first
if block. `disc` nodes are not affected because uses_font_disc is a macro containing `return`.
A minimal example in plain LuaTeX:
\directlua{ local g = node.new'glyph' g.font = font.current() if not node.uses_font(g, font.current()) then error'This should not happen' end node.free(g) } \bye
hm, probably a missed else, ie
} else { /* todo: other node types */ lua_pushboolean(L,0); }
if (type(n) == glyph_node) { lua_pushboolean(L,font(n) == f); return 1;
in the luatex version two times return 1 needs to be added (sorry, it went unnoticed because in lm hese returns are there)
Hans
Committed revision 7191 -- luigi
participants (4)
-
Hans Hagen
-
luigi scarso
-
Marcel Fabian Krüger
-
Marcel Krüger