How widely supported are multiple styles on Z-machine?

Unlike in Glk/Glulx, the Z-machine’s text style codes are designed so that you can combine them: reverse video is 1, bold is 2, italic is 4, and monospace is 8, so you can request bold italic text with style 6, or reverse video monospace text with style 9.

My question is, do interpreters actually support this? How many interpreters actually allow bold italic text, for example?

1 Like

Mine does. I’ve never checked, but I get the feeling it isn’t common.

1 Like

The reason I ask is because currently, Dialog’s Z-machine backend turns off all styles before applying a new one, but it wouldn’t take much work to have it combine them instead—that is, if you have a (span @italic) inside a (span @bold), it’ll ask the interpreter for bold italics.

But if interpreters don’t support this, then there’s no point in going to the effort of adding it.

In my ultra-scientific survey of terps I had lying around, using this source:

lab is room.

when play begins:
say "[bold type]fee [italic type]fie [reverse type]fo[verse type] [roman type]fum ."

to say reverse type: (- @set_colour 0 9; @set_colour 2 0; -);
to say verse type: (- @set_colour 1 1; -)
  • frotz: styles stacked
  • bocfel: styles stacked
  • fizmo-ncursesw: styles stacked (but italic was represented by underlining)
  • gargoyle: styles stacked except that the reverse type continued to be black on white
  • lectrote: styles stacked except that the reverse type continued to be black on white
  • single-file-parchment: styles stacked except that the reverse type continued to be black on white

Conclusion: looks to me like it’s more supported than not.

3 Likes

I believe set_color is always supposed to stack with set_text_style; I’m rather surprised that it doesn’t, actually!

Those colours are black on white, aren’t they?

1 Like

That’s cool. I figured it was obscure enough that many wouldn’t bother. I stand corrected.

Doh. I was wondering why it didn’t work in gargoyle and parchment, where I expected it to. I was distracted by that code achieving the desired effect in my (light-on-dark) terminal. ok, shortening it to:

to say reverse type: (- @set_colour 9 2; -)

I see the desired behavior in gargoyle and, when in light mode, parchment. Since the code is really specifying white text on black background and doesn’t know whether that’s normal or the inverse of normal I don’t see a difference in dark mode in parchment… but that’s actually to be expected.

Why not use @set_text_style 1 for reverse video?

'cause I didn’t know about it… :crazy_face:

Terpetude already has tests for this, tests 4 & 5: etude.z5 - Parchment

I suspect its inclusion there has in part lead to its general support now.

3 Likes