A style definition begins with the command `BeginStyle' and ends with `EndStyle'. Between these come any number of commands and definitions. The style is parsed and interpreted using TJaM, so you will want to read the TJaM documentation if you're going to spend much time writing styles.
ScreenRules, PrintRules, and StyleRules
The basic form for a rule definition in a style is
(name) "comment string" { commands } StyleRule
In many cases it will be desirable for a rule definition to be different depending on whether the output is for printing or for display. To simplify this, you may define a format both as a ScreenRule and as a PrintRule. The ScreenRule definition will be used for display, while the PrintRule will be used for printing. If there is only a StyleRule definition, it will be used for both printing and display.
Style rules should be used only to change style parameters; they should not use what's on the stack, and should not define or re-define anything that persists after they are done. This needs to be the case so that caching of the results can be done. Some attempt is made to enforce these rules.
Names in JaM are always case-sensitive. Format names are always converted to lower case before lookup. To make this work, StyleRule and friends register with both the literal name, and the name converted to all lower case. Thus if you define "MyFormat", it can be invoked by the name "myformat" or by "MyFormat", but not by "myFormat". You don't often have to think about this, but it can lead to some mysterious behaviour if you don't know about it. To ease layering of styles, style rules are also registered under names like "stylename.myformat" (all lower case). For example,
BeginStyle
(Cedar) AttachStyle
(body) "for paragraphs" {cedar.body 1 em bigger firstIndent} StyleRule
EndStyle
is a style definition just like Cedar.styl, except that paragraphs are indented more
Formatting Parameters
This section lists some of the formatting parameters. Those that are recognized by the style machinery but are not currently implemented are in
strikeout
type. Typically, the name of the parameter is a command defined in JaM that pops an item from the stack and makes it the new parameter value. However if the item on the top of the stack is the word `the', the commands push the current parameter value, so style rules can read parameters as well as write them. For numeric parameters, the following mechanisms are provided to simplify making incremental changes to the current parameter value:
<amount> bigger adds the amount to the current parameter value
<amount> smaller subtracts the amount from the parameter value
<amount> percent multiplies the parameter value by the specified percentage, i.e.,
value ← (amount/100)*value
<amount> percent bigger increases value by specified percentage
<amount> percent smaller decreases value by specified percentage
Font
Parameters
There are more parameters here than can reasonably be referenced using the limited number of looks available in a given style. The Postfix property may be applied to individual characters to get fine-grain control of these parameters when you run out of looks, or for special cases. See above for instructions about how to do this.
alphabets one of caps+lowercase, caps+smallcaps, lowercase, or caps
fontPrefix prefix of the full hierarchical font name, e.g.
"xerox/pressfonts/"
family the name of current font family, such as "TimesRoman".
If this contains a slash, it is interpreted as the full hierarchical font name, and the fontPrefix and face parameters are ignored.
size value is the font size in points
face one of regular, bold, italic, or bold+italic
You can also add or remove italic or bold by means of the following commands:
+bold face, -bold face, +italic face, or -italic face
textHue hue of text, in range [0..1);
0=red, 1/6=yellow, 2/6=green, etc.
textSaturation saturation of text; 0=no color, 1=full color
textBrightness brightness of text; 0=black, 1=full brightness
textColor takes 3 numbers: hue, saturation, brightness
textNamedColor takes a string that is a hierarchical color name, e.g.
"xerox/research/distinct/blue".
If this is specified, it takes precedence over the textHue, textSaturation, and textBrightness parameters.
underlining one of all, visible, letters+digits, or none
underlineThickness thickness of the underline.
underlineDescent distance from baseline downwards to top of underline
underlineHue, underlineSaturation, underlineBrightness, underlineColor, underlineNamedColor
parameters describing the color of the underline.
strikeout one of all, visible, letters+digits, or none
strikeoutThickness thickness of the strikeout line.
strikeoutAscent distance from baseline to top of strikeout line.
strikeoutHue, strikeoutSaturation, strikeoutBrightness, strikeoutColor, strikeoutNamedColor
parameters describing the color of the strikeout line.
backgroundAscent, backgroundDescent, backgroundHue, backgroundSaturation, backgroundBrightness, backgroundColor, backgroundNamedColor
parameters describing the size and color
of the text background.
outlineBoxBearoff amount to fatten text background horizontally, or, if no background box is specified, amount of extra white space to leave around the font box, both horizontally and vertically.
outlineBoxThickness thickness of outline around text background.
outlineboxHue, outlineBoxSaturation, outlineBoxBrightness, outlineBoxColor, outlineBoxNamedColor
parameters describing the color
of the text outline box
letterspacing space to add between visible characters
hShift distance to offset text, positive to the right
vShift distance to raise text above baseline (can be negative)
Fancy
Tabs
The style machinery actually allows for a fairly elaborate specification of fancy tabs, but only a tiny subset of this is actually used by the formatter. What is documented here is what actually works.
clearTabStops remove fancy tab stops
flushLeft tabStop define a new tab stop. The only form of fancy tabs currently implemented is of this form.
Example: to set up tab stops for old-fashioned assembly code, use something like
clearTabStops
10 sp flushLeft tabStop
16 sp flushLeft tabStop
35 sp flushLeft tabStop
72 sp flushLeft tabStop
In many cases, you will want to use an actual unit instead of "sp".
This lets you do silly things like
LOOP CR R1, R2 TEST THE LOOP COUNT 00100
BH OUT EXIT IF DONE 00200
LA R1, 1(R1) NEXT BYTE 00300
OUT EQU * 00400
Graphics
Parameters
areaHue, areaSaturation, areaBrightness, areaColor, areaNamedColor, outlineHue, outlineSaturation, outlineBrightness, outlineColor, outlineNamedColor
lineWeight
Leading
Parameters
Leading parameters are stored as triples of <size, stretch, and shrink> which, following Knuth, we refer to as `glue'. You can set the separate components individually, or you can push three values on the stack and use one of the leading glue commands to set them all at once.
There are three kinds of leading corresponding to the spaces between lines in a node, the space above a node, and the space below it. The actual space between two adjacent nodes is the maximum of the `below' leading of the first node and the `above' leading of the second.
leading distance between baselines within a node
leadingStretch how much leading can increase
leadingShrink how much leading can decrease
leadingGlue size, stretch, and shrink for leading
topLeading distance between baselines above a node
topLeadingStretch how much top leading can increase
topLeadingShrink how much top leading can decrease
topLeadingGlue size, stretch, and shrink for top leading
bottomLeading distance between baselines below a node
bottomLeadingStretch how much bottom leading can increase
bottomLeadingShrink how much bottom leading can decrease
bottomLeadingGlue size, stretch, and shrink for bottom leading
Layout
Parameters
lineFormatting FlushLeft, FlushRight, Justified, Centered
lastLineFormatting FlushLeft, FlushRight, Justified, Centered; applies to last line of node.
hyphenation Takes a name (i.e., (English) or (No)) that tells what hyphenation routine to use (applies at node level).
hyphenCode Takes a numeric character code specifying what to use for a hyphen (default 45 is the ASCII hyphen/minus).
maxHorizontalExpansion Spaces in justified lines are never stretched by more than this amount, possibly resulting in a somewhat ragged right margin. Applies at the node level.
minLineGap min distance between line top and
previous bottom (can be negative)
leftIndent all lines indent this much on left
rightIndent all lines indent this much on right
firstIndent first line indents this much more on left
firstIndentRight first line this much shorter on right
restIndent other lines indent this much more on left
runaroundLeft depth of first indent on the left
runaroundRight depth of first indent on the right
topIndent top baseline at least this much down from top of viewer/page
bottomIndent bottom baseline at least this up from bottom of page
lineLength maximum width of lines of text
Page
Layout
Parameters
column number of columns
pageWidth width of the paper
pageLength height of the paper
leftMargin whitespace at left of the page
rightMargin whitespace at right of the page
topMargin whitespace at top of the page
bottomMargin whitespace at bottom of the page
headerMargin height of area below topMargin
reserved for headers
footerMargin height of area above bottomMargin
reserved for footers
bindingMargin extra margin on the bound edge of page
pageBreakAfterFirstLinePenalty
pageBreakAfterLastLinePenalty
pageBreakBeforeFirstLinePenalty
pageBreakBeforeLastLinePenalty
pageBreakPenalty
Dimensions
pt point (72.27 pt/in)
bp big point (72 bp/in)
pc pica
in inches
cm centimeters
mm millimeters
dd Didot points
em size of em quad in current font
en one-half em
sp width of one space in the current font
fil 10^4 points
fill 10^8 points
filll 10^12 points
Miscellaneous
style the name of the current style
isComment pushes .true or .false according to comment property of node
isPrint pushes .true if executing print rules, else .false
nestingLevel pushes integer; 0 for root, 1 for top level, etc.
Making
new
style
parameters
A new style parameter may be defined by
(name) <initialValue> StyleParam
This creates a new style parameter that behaves just like the built-in style parameters, except for performance. It is useful for communicating information between parts of a style definition, and for adding new formatting parameters without having to change Tioga's interfaces.