Problems displaying special unicode characters

I’m using Inform 6.31 and Frotz.

I’ve tried using

Zcharacter table '@{2660}' '@{2663}' '@{2665}' @{2666};

to add the symbols for the card suits to the character set, but I can’t get them to display properly in the interpreter. They show up as those annoying white boxes instead symbols for Spades, Diamonds, etc… Using the same code, I can get other special unicode characters to display properly, but not those ones. Here’s the full code I’m trying to implement:

[code]Zcharacter table ‘@{2660}’ ‘@{2663}’ ‘@{2665}’ ‘@{2666}’;
Array pack_of_cards --> 52;
[Shuffle i j;
for (i=1:i<52:i++) {
j = random(i+1) - 1;
pack_of_cards–>i = pack_of_cards–>j; pack_of_cards–>j = i;
[Card n;
switch(n%13) {
0: print “Ace”;
1 to 9: print n%13 + 1;
10: print “Jack”; 11: print “Queen”; 12: print “King”;
print " of ";
switch(n/13) {
0: print “@{2660}”; 1: print “@{2663}”;
2: print “@{2665}”; 3: print “@{2666}”;
[Main i;
! Create the pack in “factory order”:
for (i=0:i<52:i++) pack_of_cards–>i = i;

! Shuffle the cards:

print “The pack has been shuffled into the following order:^”;
for (i=0:i<52:i++)
print (Card) pack_of_cards–>i, “^”;

This was actually taken right out of the designer’s manual, except for the addition of these unicode characters and a few other minor adjustments. Originally, in the Card routine it printed “Hearts”, “Spades”, etc… I thought it would be nice if I could get it to print the appropriate symbols instead. Any idea why this doesn’t work or how I could get it to work? Thank you!

I don’t know a great deal about Inform 6, I’m afraid, particularly not about its support for special characters. But it’s possible that the font Frotz is using simply doesn’t support those characters. To check whether that’s the problem, download the zipped .zblorb file I’ve attached to this post (it’s an Inform 7 example which uses a lot of special characters, including the playing card symbols) and run it. Go east then south to the Gaming Lounge, and see if the symbols in the room description show up. If they do, then you have a problem with your I6 code. If they don’t, it’s probably a problem with your interpreter or font. (142 KB)

1 Like

Wow. I didn’t even think about the interpreter font. It was late and I wasn’t thinking clearly. That was indeed the problem. Thank you for the file, and your help.

Is there any way to preset the font at compile time? At the very least, I would include an advisory statement at the start of the game about font selection, I suppose.

EDIT: I’ve realized that it would be better to write a routine that prints using an appropriate font regardless of what the player has the font set to, and am educating myself to that end by reading up on fonts in the DM. Thanks again for your help, Emerald.

Glad to have helped!

Like I said, I don’t know much about Inform 6 and its support for special characters. But Roger Firth’s article on character sets in I6 might help you, particularly the last section, “Runtime issues”.

No, there’s no way to control the font: that’s purely the user’s choice. However, if you’re using Windows Frotz 1.13 or later, the interpreter will try to find a suitable font to use for Unicode characters. From the revision history:

If you install a decent Unicode font, then the characters will be available - see the attached screenshot of the “Clavier” example on my system.

I see! I’m only using version 1.09. I’ll get the latest version from the developer’s site.

A few more quick suggestions:

  1. You don’t strictly need to add the Unicode chars to the Zcharacter table if all you’re going to do is print them out: you can use the @print_unicode opcode instead, just giving it the number of the Unicode character.

  2. You can also ask the interpreter if it thinks it can output a given Unicode character with the @check_unicode opcode.

Both of the above require a “Standard 1.0” compliant interpreter, but virtually all of them are these days (and have been since the late 1990s): you can check the header to be sure.

Awesome! Boy am I glad I registered here! You guys are more helpful than I could have imagined. I’m sure I will be back with more problems to discuss in the future.