Inform 7 Home Page / Documentation
Chapter 12: Typography, Layout, and Multimedia Effects
§12.1. Typography; §12.2. The Status Line; §12.3. Footnotes; §12.4. Timed Input; §12.5. Glulx Multimedia Effects
Contents of The Inform Recipe Book | |
Chapter 11: Out Of World Actions and Effects | |
Chapter 13: Testing and Publishing | |
Indexes of the examples |
§12.1. Typography
Story files produced by Inform tend not to contain elaborate typographical effects. They would only distract. Like a novel, a classic work of IF is best presented in an elegant but unobtrusive font. Inform does, however, provide for italic and bold-face, and also for a typewriter-style fixed pitch of lettering:
"This is an [italic type]italicised[roman type] word."
"This is an [bold type]emboldened[roman type] word."
"This is a [fixed letter spacing]typewritten[variable letter spacing] word."
Authors making very frequent use of these might like to borrow the briefer definitions in Chanel Version 1.
A very wide range of letter-forms is normally available (and even more in quoted text), so that the writer seldom needs to not worry whether, say, a sentence like
will work. The Über-complète clavier is an exhaustive test of such exotica.
Coloured type is trickier, and its availability depends on the story file format. For a Z-machine story, Garibaldi 2 demonstrates this.
Finally, Tilt 3 combines unusual letterforms (suit symbols) with red and black colours to render hands of cards typographically.
Start of Chapter 12: Typography, Layout, and Multimedia Effects | |
Back to Chapter 11: Out Of World Actions and Effects: §11.6. Ending The Story | |
Onward to §12.2. The Status Line |
ExampleGaribaldi 2 |
The extension "Basic Screen Effects" provides a few more type styles, in the form of coloured lettering. The colours available are red, yellow, green, blue, white, magenta, and cyan, as well as the usual black; and to restore the player's default screen colour, we say "default letters".
Thus if we wanted to highlight locked and unlocked doors in our security readout example:
The security readout is a device. The description of the readout is "The screen is blank."
Instead of examining the switched on security readout:
say "The screen reads: [fixed letter spacing]";
say line break;
repeat with item running through doors:
say line break;
say " [item] ([front side of the item]/[back side of the item]): [if the item is locked][green letters]LOCKED[default letters][otherwise][red letters]UNLOCKED[default letters][end if]";
say variable letter spacing;
say paragraph break.
The Docking Bay is a room. The inner airlock is a door. It is north of the Docking Bay and south of the Zocalo. The inner airlock is lockable and unlocked. The outer airlock is lockable and locked. It is a door. It is south of the Docking Bay and north of Space.
The quarantine seal is a door. It is west of the Zocalo and east of Medlab. Quarantine seal is locked.
The security pass unlocks the inner airlock. The player carries the security pass.
Test me with "x readout / turn on readout / x readout / lock inner airlock with security pass / x readout".
Note that this extension does not currently produce the desired effects when compiling with the Glulx setting; to see it working, make sure that the settings tab is set to compile to the Z-machine.
ExampleChanel Version 1 |
HTML uses angled brackets to achieve effects, and places italicised text between <i> and </i> tags; and similarly boldface between <b> and </b>. We can mimic this very easily by setting each up as a segmented substitution:
To say i -- beginning say_i -- running on: (- style underline; -).
To say /i -- ending say_i -- running on: (- style roman; -).
To say b -- beginning say_b -- running on: (- style bold; -).
To say /b -- ending say_b -- running on: (- style roman; -).
Place Vendôme is a room. "[i]Fashion fades, only style remains the same[/i] ([b]Coco Chanel[/b]). And this elegant drawing-room, once a milliner's shop, is a case in point."
Instead of going nowhere, say "[i]Don't spend time beating on a wall, hoping to transform it into a door.[/i] ([b]Coco Chanel[/b]) This one is a wall.".
We have had to use square instead of angle brackets, but then, "in order to be irreplaceable one must always be different" (Coco Chanel).
(Marking these as substitutions which run on prevents unexpected paragraph breaks if they should appear immediately after the end of a sentence.)
ExampleTilt 3 |
Books and articles about card-playing traditionally abbreviate card names into a simple two-symbol notation: a number or letter representing the card rank, followed by a symbol indicating the card suit. Suppose that we want to emulate this notation when taking inventory in our poker game.
The trick here is that colored output is done in different ways by the Z-Machine and by Glulx, so we'll need two different versions of the same section in order to produce this output. The relevant source is right at the beginning:
For the suit symbols, we'll want the Unicode extension included with Inform:
Rule for printing the name of a card (called target) while grouping together:
say "[rank of the target as abbreviated value][suit of the target as symbol]".
To say (current suit - a suit) as symbol:
if current suit is diamonds, say "[red letters][unicode black diamond suit][default letters]";
if current suit is spades, say "[unicode black spade suit]";
if current suit is clubs, say "[unicode black club suit]";
if current suit is hearts, say "[red letters][unicode black heart suit][default letters]".
The Basic Screen Effects extension bundled with Inform includes mechanisms to change the text color, so for the Z-machine, we need only include this:
Under Glulx, we need slightly more set-up: Glulx requires that we define special user font styles when we plan to make display changes. A fuller discussion of this (and of how to define new colors) appears in the documentation of "Glulx Text Effects", but an implementation sufficient to our purposes would be
style name |
glulx color |
special-style-1 |
g-pure-red |
glulx color value |
assigned number |
g-pure-red |
16711680 |
From here, the rest of the source is mostly as we've seen in previous examples:
Suit is a kind of value. The suits are hearts, clubs, diamonds, and spades. Understand "heart" as hearts. Understand "club" as clubs. Understand "diamond" as diamonds. Understand "spade" as spades.
A card is a kind of thing. A card has a suit. A card has a number called rank. Understand the suit property as describing a card. Understand the rank property as describing a card.
To say (count - a number) as a card value:
choose row count in the Table of Value Names;
say "[term entry]".
Rule for printing the name of a card (called target):
say "[rank of the target as a card value] of [suit of the target]"
To say (count - a number) as abbreviated value:
choose row count in the Table of Value Names;
say "[abbrev entry]".
term |
value |
abbrev |
topic |
"ace" |
"1" |
"A" |
"ace/A" |
"deuce" |
"2" |
"2" |
"deuce/two" |
"three" |
"3" |
"3" |
"three" |
"four" |
"4" |
"4" |
"four" |
"five" |
"5" |
"5" |
"five" |
"six" |
"6" |
"6" |
"six" |
"seven" |
"7" |
"7" |
"seven" |
"eight" |
"8" |
"8" |
"eight" |
"nine" |
"9" |
"9" |
"nine" |
"ten" |
"10" |
"10" |
"ten" |
"jack" |
"11" |
"J" |
"jack/knave/J" |
"queen" |
"12" |
"Q" |
"queen/Q" |
"king" |
"13" |
"K" |
"king/K" |
After reading a command:
if the player's command includes "of [suit]":
while the player's command includes "of":
cut the matched text;
repeat through the Table of Value Names:
while the player's command includes topic entry:
replace the matched text with value entry.
To reconstitute deck:
let current suit be hearts;
now every card is in the card repository;
while a card is in the card repository:
repeat with current rank running from 1 to 13:
let item be a random card in card repository;
now rank of item is current rank;
now suit of item is current suit;
now item is in the deck of cards;
now current suit is the suit after the current suit.
The deck of cards is in the Empty Room. It is a closed unopenable container. The description is "A standard poker deck."
The discard pile is a closed unopenable container. The description is "Cards in this game are discarded face-down, so the discard pile is not very interesting to see. All you can observe is that it currently contains [if the number of cards which are in the discard pile is less than ten][the number of cards which are in the discard pile in words][otherwise]about [the rounded number of cards which are in the discard pile in words][end if] card[s]."
To decide what number is the rounded number of (described set - a description of objects):
let N be the number of members of the described set;
let R be N divided by 5;
let total be R times 5;
decide on total.
Rule for printing room description details of something: do nothing instead.
Understand the commands "take" and "carry" and "hold" and "get" and "drop" and "throw" and "discard" as something new.
Understand "take [text]" or "get [text]" or "drop [text]" as a mistake ("Here, you only draw and discard. Nothing else matters at the moment.").
Understand "draw" or "draw card" or "draw a card" as drawing. Drawing is an action applying to nothing. The drawing action has an object called the card drawn.
Setting action variables for drawing:
now the card drawn is a random card which is in the deck of cards.
Check drawing:
if the card drawn is nothing, say "The deck is completely depleted." instead.
Check drawing:
if the number of cards carried by the player is greater than four,
say "This is a five-card game; you must discard something before drawing anything further." instead.
Understand "discard [card]" as discarding. Discarding is an action applying to one thing.
Check discarding:
if the player does not carry the noun, say "You can only discard cards from your own hand." instead.
Carry out discarding:
now the noun is in the discard pile;
if the discard pile is not visible, move the discard pile to the location.
Report discarding:
say "You toss [the noun] nonchalantly onto the discard pile."
Before listing contents while taking inventory: group cards together.
Before grouping together cards:
if the number of cards carried by the player is 5:
say "[run paragraph on]";
follow the hand-ranking rules;
if the rule succeeded, say "[the outcome of the rulebook]";
otherwise say "some random cards";
if the outcome of the rulebook is pair outcome, say " of [rank of the first thing held by the player as a card value]s";
otherwise:
say "[number of cards carried by the player in words] assorted cards";
say " (".
To say list hand:
let chosen card be the first thing held by the player;
while chosen card is a card:
say "[chosen card]";
now chosen card is the next thing held after chosen card;
if chosen card is a card, say "-".
The hand-ranking rules is a rulebook. The hand-ranking rules have outcomes royal flush, straight flush, four of a kind, full house, flush, straight, three of a kind, two pairs, pair, high card.
The hand-ranking rulebook has a truth state called the flushness.
The hand-ranking rulebook has a truth state called the straightness.
The hand-ranking rulebook has a number called the pair count.
The hand-ranking rulebook has a number called the triple count.
The hand-ranking rulebook has a number called the quadruple count.
A card can be sorted or unsorted. A card is usually unsorted.
Definition: a card is high if its rank is 11 or more.
Definition: a card is low if its rank is 4 or less.
A hand-ranking rule (this is the initial sort rule):
now every card is unsorted;
while the player carries an unsorted card:
let item be the lowest unsorted card held by the player;
move item to the player;
now the item is sorted;
if sort-debugging is true, say "-- after initial sort: [list hand]".
A hand-ranking rule (this is the finding flushness rule):
let called suit be the suit of a random card carried by the player;
if every card carried by the player is called suit, now flushness is true.
A hand-ranking rule (this is the finding straightness rule):
now straightness is true;
let N be the rank of the highest card which is carried by the player;
repeat with current rank running from N - 4 to N:
now the test rank is the current rank;
unless the player carries a matching card:
if the current rank is N - 4 and the current rank is 9 and the player carries an ace card, do nothing;
otherwise now straightness is false.
Test rank is a number that varies. Definition: a card is matching if its rank is the test rank.
A hand-ranking rule (this is the counting multiples rule):
now every card is uncombined;
repeat with current rank running from 1 to 13:
now test rank is current rank;
let N be the number of matching cards held by the player;
if N is 4:
increment the quadruple count;
now every matching card held by the player is quadrupled;
if N is 3:
increment the triple count;
now every matching card held by the player is tripled;
if N is 2:
increment the pair count;
now every matching card held by the player is paired.
A hand-ranking rule (this is the move aces up unless there's a low straight rule):
unless the straightness is true and the lowest card carried by the player is an ace card and the rank of the highest card carried by the player is 5,
now every ace card which is carried by the player is carried by the player;
if sort-debugging is true, say "-- after ace movement rule: [list hand]".
A hand-ranking rule (this is the move pairs forward rule):
while the player carries a paired card:
let selection be the lowest paired card which is carried by the player;
move the selection to the player;
now the selection is uncombined;
if sort-debugging is true, say "-- after pairs movement: [list hand]".
A hand-ranking rule (this is the raise ace pairs rule):
if the player carries exactly two ace cards:
repeat with item running through ace cards which are carried by the player:
move item to the player;
if sort-debugging is true, say "-- after paired-ace movement: [list hand]".
A hand-ranking rule (this is the move multiples forward rule):
while the player carries a tripled card:
let selection be the lowest tripled card which is carried by the player;
move the selection to the player;
now the selection is uncombined;
while the player carries a quadrupled card:
let selection be the lowest quadrupled card which is carried by the player;
move the selection to the player;
now the selection is uncombined;
if sort-debugging is true, say "-- after multiples movement rule: [list hand]".
Definition: a card is ace if its rank is 1.
Definition: a card is king if its rank is 13.
A hand-ranking rule (this is the royal-flush rule):
if flushness is true and straightness is true and the highest card carried by the player is king and the lowest card carried by the player is ace, royal flush.
A hand-ranking rule (this is the straight-flushes rule):
if flushness is true and straightness is true, straight flush.
A hand-ranking rule (this is the four-of-a-kind rule):
if the quadruple count is 1, four of a kind.
A hand-ranking rule (this is the full-house rule):
if the pair count is 1 and the triple count is 1, full house.
A hand-ranking rule (this is the flushes rule):
if flushness is true, flush.
A hand-ranking rule (this is the straights rule):
if straightness is true, straight.
A hand-ranking rule (this is the three-of-a-kind rule):
if triple count is 1, three of a kind.
A hand-ranking rule (this is the two-pair rule):
if the pair count is 2, two pairs.
A hand-ranking rule (this is the pair rule):
if the pair count is 1, pair.
Understand "debug sorting" as debugging hand sorting. Debugging hand sorting is an action out of world.
Carry out debugging hand sorting:
if sort-debugging is false, now sort-debugging is true;
otherwise now sort-debugging is false.
Report debugging hand sorting:
say "Sort debugging is now [if sort-debugging is true]on[otherwise]off[end if]."
Test me with "draw / g / g / g / g / force hand / g / g / g / g / g / g / g / g / g / g / g / g".
set suit |
set rank |
|
spades |
1 |
[royal flush] |
spades |
13 |
|
spades |
12 |
|
spades |
11 |
|
spades |
10 |
|
clubs |
12 |
[straight flush] |
clubs |
11 |
|
clubs |
10 |
|
clubs |
9 |
|
clubs |
8 |
|
diamonds |
8 |
[four of a kind] |
hearts |
8 |
|
spades |
8 |
|
clubs |
8 |
|
clubs |
3 |
|
clubs |
1 |
[full house] |
spades |
1 |
|
hearts |
10 |
|
spades |
10 |
|
clubs |
10 |
|
hearts |
2 |
[flush] |
hearts |
5 |
|
hearts |
7 |
|
hearts |
11 |
|
hearts |
12 |
|
hearts |
1 |
[straight] |
spades |
13 |
|
diamonds |
12 |
|
clubs |
11 |
|
hearts |
10 |
|
hearts |
2 |
[three of a kind] |
spades |
2 |
|
clubs |
2 |
|
clubs |
4 |
|
spades |
3 |
|
diamonds |
6 |
[two pairs] |
spades |
6 |
|
clubs |
7 |
|
diamonds |
7 |
|
hearts |
9 |
|
diamonds |
6 |
[two pairs, ace high] |
spades |
6 |
|
clubs |
1 |
|
diamonds |
7 |
|
hearts |
1 |
|
hearts |
12 |
[pair] |
spades |
12 |
|
diamonds |
10 |
|
spades |
7 |
|
clubs |
4 |
|
diamonds |
13 |
[high] |
hearts |
11 |
|
spades |
9 |
|
clubs |
7 |
|
diamonds |
5 |
|
hearts |
1 |
[tricky sorting: low straight] |
diamonds |
2 |
|
spades |
3 |
|
diamonds |
4 |
|
diamonds |
5 |
Understand "force hand" as forcing a hand. Forcing a hand is an action out of world.
Carry out forcing a hand:
repeat with item running through cards which are carried by the player:
increment current marker;
if current marker is greater than the number of filled rows in the Table of Testing Hands, now current marker is 1;
choose row current marker in the Table of Testing Hands;
now the suit of item is the set suit entry;
now the rank of item is the set rank entry.
ExampleThe Über-complète clavier |
The following example puts Inform's support for exotic lettering through its paces. It was useful in testing Inform but is not a very instructive read: still, it does provide a test story file for interpreters, so we are including the source here as an example.
The story headline is "Pushing the Limits of Unicode in IF". The story description is "This is a demanding test for Unicode compliance by Z-machine interpreters."
The Château Bibliothèque Français is east of the Deutsche Universität Bücherei. "From this Borgesian construction, doorways lead into anterooms in each of the four cardinal directions." South of the Bibliothèque is the Miscellany Mañana. North of the Bibliothèque is the Íslendingabók. East of the Bibliothèque is Alphabet Soup.
A framed photograph of Icelandic Prime Minister Halldór Ásgrímsson, a ruler measuring Ångströms, a Bokmål-Lëtzebuergesch Lëtzebuergesch-Bokmål dictionary and a ticket to Tromsø via Østfold are in the Íslendingabók.
A paper by Karl Weierstraß, a general feeling of Ärger, an old Österreich passport and the Bach Clavier-Übung open at the fugue à 4 are in the Bücherei.
The painting of École normale superiéure students singing Ça ira, the frankly lesser-known journal of Niccolò Polo, Così fan tutte on CD, an extract of Herodotus concerning Artaÿctes and the exit sign reading À BIENTÔT are in the Bibliothèque.
A wicker basket marked CHLOË is in the Bibliothèque. A ginger cat is in the basket.
A guide to Æsop for naïve æsthetes, Lönnrot's Kalevala, a creed according to the Bahá'ís, FALARÃO magazine, an Estonian poem by Tõnu Trubetsky, a Portuguese-Italian recipe for macarrão, a stripy hanging CANDY PIÑATA bag, a ¿¡Punctuation Turned Upside Down¿¡ pamphlet, an Italian brewers' anti-violence poster declaring BÓTTE NON BÒTTE, a map of È and a dusty book titled The Parnasum of Luís Vaz bearing CAMÕES on its spine are in Miscellany Mañana.
The description of the map is "È is a province in the People's Republic of China."
In Mañana is something called ÂÊÎÔÛ - The Official Journal of the Society for Vowels bearing Circumflexes.
In Mañana is something called âêîôû comic - the youth edition.
The description of Alphabet Soup is "A bewildering place of glyphs, sigils and signs. The Library proper leads back west: steps lead upwards to an Observatory, or downwards into what seems to be a dangerous area. A gaming lounge lies to the south."
The Greek Alphabet, the Cyrillic Alphabet, the Hebrew alphabet, and the embossed plaque are in Alphabet Soup. The description of the Greek alphabet is "αβγδεζηθικλμνξοπρςστυφχψω.". The description of the Hebrew alphabet is "אבגדהוזחטיךכלםמןנסעףפץצקרשת.". The description of the Cyrillic alphabet is "абвгдежзийклмнопрстуфхцчшщъыьэюя.".
Instead of examining the plaque:
say "It seems to be a sign in Braille: ";
say unicode Braille pattern dots-24, " (I), ",
unicode Braille pattern dots-1345, " (N), ",
unicode Braille pattern dots-124, " (F), ",
unicode Braille pattern dots-135, " (O), ",
unicode Braille pattern dots-1235, " (R), ",
unicode Braille pattern dots-134, " (M)."
The Gaming Lounge is south of Alphabet Soup. The chess position and the book of puzzle canons are in the Gaming Lounge.
The Georges de la Tour painting Le Tricheur is in the Gaming Lounge. "Hanging on one wall is Georges de la Tour's masterpiece Le Tricheur (the card-sharp). Visible are 8[unicode black diamond suit], 9[unicode black diamond suit], A[unicode black diamond suit], A[unicode black spade suit], 6[unicode black club suit] but not one of them has a [unicode black heart suit]."
The description of Le Tricheur is "If they'd been dice-players instead, they might have thrown [unicode die face-1], [unicode die face-2], [unicode die face-3], [unicode die face-4], [unicode die face-5] or [unicode die face-6], but as it is they stick to cards."
The description of the book of canons is "A typical fugue is no. 13 (Tovey: [unicode eighth note] = 110) in F[unicode music sharp sign] minor, but you can also make out keys like A[unicode music flat sign] and G[unicode music natural sign]."
The empty square text is text that varies. To say empty: say the empty square text.
To display the board:
say empty, empty, empty, empty, empty, empty, unicode black chess king, empty, line break;
say empty, empty, empty, unicode black chess queen, empty, empty, unicode black chess pawn, empty, line break;
say unicode black chess pawn, empty, empty, unicode black chess bishop, unicode black chess pawn, empty, empty, unicode black chess pawn, line break;
say empty, empty, empty, unicode black chess pawn, empty, unicode black chess rook, empty, empty, line break;
say empty, unicode black chess pawn, empty, unicode white chess pawn, unicode black chess pawn, empty, empty, empty, line break;
say empty, empty, empty, unicode black chess bishop, unicode white chess queen, empty, unicode white chess pawn, unicode white chess pawn, line break;
say unicode white chess pawn, unicode white chess pawn, empty, unicode white chess bishop, empty, unicode black chess rook, unicode white chess bishop, empty, line break;
say empty, unicode white chess knight, empty, empty, unicode white chess rook, empty, unicode white chess rook, unicode white chess king, line break.
Instead of examining the chess position:
say "Fritz Saemisch - Aron Nimzowitsch, Copenhagen 1923: the Immortal Zugzwang Game. Nimzowitsch (black), observing that white will very soon have to play a terrible move, has just advanced his h pawn for no reason other than to wait. So it is white to play...";
say "[fixed letter spacing]......k. [line break]...q..p. [line break]p..bp..p [line break]...p.r.. [line break].p.Pp... [line break]...bQ.PP [line break]PP.B.rB. [line break].N..R.RK [variable letter spacing][line break]";
say "'White must, willy-nilly, eventually throw himself upon the sword', in Nimzowitsch's commentary. ";
say "We will now try to display the same position using chess-piece symbols in a Unicode font.";
say fixed letter spacing;
now the empty square text is " ";
display the board;
say variable letter spacing.
The planets are in the Observatory. "Diagrams of the planets are scattered across the dome: Sun [unicode Sun], Mercury [unicode Mercury], Venus [unicode Female Sign], Earth [unicode Earth], Moon [unicode First Quarter Moon] and [unicode Last Quarter Moon], Mars [unicode Male Sign], Jupiter [unicode Jupiter], Saturn [unicode Saturn], Uranus [unicode Uranus], Neptune [unicode Neptune], Pluto [unicode Pluto] and one or two comets [unicode Comet]. Fainter, but all around, you see stars black [unicode black star] and white [unicode white star]."
The constellations are in the Observatory. "Ringing the dome are the constellations: Aries [unicode Aries], Taurus [unicode Taurus], Gemini [unicode Gemini], Cancer [unicode Cancer], Leo [unicode Leo], Virgo [unicode Virgo], Libra [unicode Libra], Scorpius [unicode Scorpius], Sagittarius [unicode Sagittarius], Capricorn [unicode Capricorn], Aquarius [unicode Aquarius], Pisces [unicode Pisces]."
The weather almanac is in the Observatory. The description of the almanac is "Here nightly observers scrawl in hasty abbreviations for the current weather conditions: clear weather [unicode Black Sun with Rays], cloudy [unicode cloud], rain [unicode umbrella], snow [unicode snowman], lightning [unicode lightning], thunderstorm [unicode thunderstorm]."
The Danger Zone is below Alphabet Soup. The printed name of the Danger Zone is "[unicode skull and crossbones] Danger Zone [unicode skull and crossbones]".
The warning signs are in the Danger Zone. "A variety of international-standard warning standards suggest that this may not be the safest place: [unicode skull and crossbones], [unicode caution sign], [unicode radioactive sign], [unicode biohazard sign]."
This example text was used to produce a story file which has been tried against both Zoom for Mac OS X and Windows Frotz. The Latin, Greek, Cyrillic and Hebrew text all functioned perfectly on both, but a point of difference showed when writing the Hebrew alphabet: Zoom wrote this right-to-left, Windows Frotz left-to-right. The exotic symbols displayed on Zoom (though others not mentioned above, such as "[unicode staff of hermes]", did not): but most appeared only as black squares on Windows Frotz, exceptions being the astrological signs for Venus and Mars and the musical note.