Re: Off-by-one error in node.protect_glyph?
I see that part of my problem was creating glyph nodes with subtype 0 and I should use subtype 1 instead. But to be clear, these are the cases I found surprising: local a = node.new('glyph', 0) node.protect_glyph(a) node.protect_glyph(a) print(a.subtype) -- expected 256, actual 512 node.unprotect_glyph(a) node.unprotect_glyph(a) print(a.subtype) -- expected 0, actual 256 local b = node.new('disc') local c = node.new('glyph', 'character') b.replace = c node.unprotect_glyph(b) print(c.subtype) -- expected 1, actual 65281 The second case (expected 0, actual 256) is explained by what you wrote: we make an exception for 256 which can be used when
no subtype is set which makes it possible to disable unprotection.
But the first case still seems surprising to me, and the third case really looks like a bug to me. Thank you!
On Sun, 15 Feb 2026 at 21:34, David Chiang
I see that part of my problem was creating glyph nodes with subtype 0 and I should use subtype 1 instead.
But to be clear, these are the cases I found surprising:
local a = node.new('glyph', 0) node.protect_glyph(a) node.protect_glyph(a) print(a.subtype) -- expected 256, actual 512 node.unprotect_glyph(a) node.unprotect_glyph(a) print(a.subtype) -- expected 0, actual 256
local b = node.new('disc') local c = node.new('glyph', 'character') b.replace = c node.unprotect_glyph(b) print(c.subtype) -- expected 1, actual 65281
The second case (expected 0, actual 256) is explained by what you wrote:
we make an exception for 256 which can be used when
no subtype is set which makes it possible to disable unprotection.
But the first case still seems surprising to me, and the third case really looks like a bug to me.
I will check them later. -- luigi
On Mon, 16 Feb 2026 at 15:48, luigi scarso
On Sun, 15 Feb 2026 at 21:34, David Chiang
wrote: I see that part of my problem was creating glyph nodes with subtype 0 and I should use subtype 1 instead.
But to be clear, these are the cases I found surprising:
local a = node.new('glyph', 0) node.protect_glyph(a) node.protect_glyph(a) print(a.subtype) -- expected 256, actual 512 node.unprotect_glyph(a) node.unprotect_glyph(a) print(a.subtype) -- expected 0, actual 256
local b = node.new('disc') local c = node.new('glyph', 'character') b.replace = c node.unprotect_glyph(b) print(c.subtype) -- expected 1, actual 65281
The second case (expected 0, actual 256) is explained by what you wrote:
we make an exception for 256 which can be used when
no subtype is set which makes it possible to disable unprotection.
But the first case still seems surprising to me, and the third case really looks like a bug to me.
I will check them later.
Hans rewrote that part, see the commit https://svn.tug.org:8369/texlive?view=revision&revision=77938 -- luigi
participants (2)
-
David Chiang -
luigi scarso