Glulx Text Effects by Emily Short Search for other extensions by this author Approved for the Public Library

Versions

Download version 5/140516For Inform 7 6M62, 6L38

Links

Description

Gives control over text formatting in Glulx.

Tags glulx typography

Documentation

Glulx Text Effects provides an easy way to set up special text effects for Glulx. Chapter: Styles in Glulx Unlike the Z-Machine, which allows arbitrary combinations of features (such as color and boldness) to be applied to text, Glulx requires the author to define and then use text styles. There are eleven of these styles: Table of styles normal-style the style used for regular text italic-style used for italic text (this is what the "[italic type]" phrase uses) bold-style used for bold text (this is what the "[bold type]" phrase uses) fixed-letter-spacing-style used for monospaced text (this is what the "[fixed letter spacing]" phrase uses) alert-style used when printing an end of game message such as "*** You have died. ***" blockquote-style used for printing box quotations header-style used to print the title of the game input-style used for the player's own input note-style used for messages such as "[Your score has increased by one point.]" special-style-1 these two styles are not used by Inform, and you are free to use them for any purpose you want special-style-2 Additionally, when defining styles you can set "all-styles" which will define all eleven styles at once. Chapter: Style features Each text style has the following features: Table of style features background color specifies the background color of the text color specifies the color of the text itself fixed width a truth state (default: false). If true then the text will be displayed with a fixed width (monospace) font font weight specifies the weight of the font. Can be set to "light-weight", "regular-weight" (the default), or "bold-weight" indentation a number (default: 0) specifying the number of units of indentation for the whole block of text. Units are defined by interpreter, but are often equivalent to spaces first line indentation a number (default: 0) specifying additional indentation for the first line of the text block italic a truth state (default: false). If true then the text will be displayed in italics justification can be set to "left-justified", "center-justified", "right-justified", or "left-right-justified" for justified on the left and right (often called full justification) relative size a number (default: 0) specifying how many font sizes above or below the browser's default a style should be set to reversed a truth state (default: false). If true then the foreground and background colors of the text will be reversed. This is most commonly used for the status line Not all interpreters support all of these features. Notably, Gargoyle does not support justification or font sizes. If the interpreter does not support one of the features it will just be quietly ignored. Chapter: Defining styles To define the features each style should have, add a table continuation to the Table of User Styles in your code. For example: Table of User Styles (continued) style name color italic relative size all-styles "#FF0000" true -- header-style "#0000FF" false 1 special-style-1 "#00FF00" This definition table above will make everything red and italics, except for the title which will be blue and a size bigger. Special style 1 is set to green, but it won't be used without the author manually turning it on. Your table continuation does not need to include every column in the Table of User Styles, nor does it need to define every style. You can also continue the table multiple times, and even define a style in multiple places; if you do then the definitions will be combined together. If you do not want to set a feature for a style you can leave it blank with "--". Colors are defined by specifying a web (CSS) color in a text. Web colors specify the red/green/blue components of a color in hexadecimal, and a correctly specified color will be 6 characters long (with an optional # at the beginning.) Note that short (#000) web colors are not supported. If you use a color many times you can define it as a text constant, and then use that in the table: Red is always "#FF0000". Table of User Styles (continued) style name color special-style-1 red Chapter: Using the styles You may invoke the text styles by using the following phrases Table of style phrases normal-style "[roman type]" italic-style "[italic type]" bold-style "[bold type]" fixed-letter-spacing-style "[fixed letter spacing]" (Return to regular variable spaced type with either "[variable letter spacing]" or just "[roman type]") alert-style "[alert style]" blockquote-style "[blockquote style]" header-style "[header style]" input-style "[input style]" note-style "[note style]" special-style-1 "[special-style-1]", "[first special style]", or "[first custom style]" (there are multiple options to support older code) special-style-2 "[special-style-2]", "[second special style]", or "[second custom style]" Chapter: About this extension This extension was originally by Emily Short. Version 5 was rewritten by Dannii Willis. The latest version of this extension can be found at <https://github.com/i7/extensions>. This extension is released under the Creative Commons Attribution licence. Bug reports, feature requests or questions can be made at <https://github.com/i7/extensions/issues>. Example: * Gaudy - A visually overpowering exercise in modifying all the built-in text styles. *: "Gaudy" Include Version 5 of Glulx Text Effects by Emily Short. Use scoring. Texty Room is a room. "This is a room of [bold type]bold[roman type] and [italic type]italic[roman type] texts as well as messages in [fixed letter spacing]fixed width[variable letter spacing] text." Table of User Styles (continued) style name relative size color background color italic-style -1 "#0000FF" [ blue ] -- fixed-letter-spacing-style -- "#444444" [ dark-grey ] -- header-style 10 -- -- bold-style 2 "#888888" [ medium-grey ] "#80DAEB" alert-style 5 "#FF0000" [ red ] note-style -- "#00FF00" [ green ] blockquote-style -- "#FFFF00" [ yellow ] input-style -1 "#FF00FF" [ magenta ] Instead of waiting: increase the score by 5. Instead of jumping: end the story finally. Every turn: display the boxed quotation "Tempus fugit." Test me with "z / z / z / jump". Example: ** The Gallic War - An excuse to print a large, fancily-formatted bit of text using custom styles. *: "The Gallic War" by Julius Caesar. The story headline is "An interactive campaign". Lessons is a room. Include Glulx Text Effects by Emily Short. Include Basic Screen Effects by Emily Short. Table of User Styles (continued) style name justification italic indentation first line indentation font weight color special-style-2 left-right-justified true 15 -4 light-weight "#888888" [ medium-grey ] When play begins: now the left hand status line is ""; now right hand status line is ""; say "[second custom style]Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur. Hi omnes lingua, institutis, legibus inter se differunt. Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit. Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque humanitate provinciae longissime absunt, minimeque ad eos mercatores saepe commeant atque ea quae ad effeminandos animos pertinent important, proximique sunt Germanis, qui trans Rhenum incolunt, quibuscum continenter bellum gerunt. Qua de causa Helvetii quoque reliquos Gallos virtute praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt."; pause the game; say roman type; now the left hand status line is "[location]"; now the right hand status line is "[turn count]". Bank of the Garumna is a room.