Enum dvi::Instruction [] [src]

pub enum Instruction {
    Set(u32),
    SetRule(i32i32),
    Put(u32),
    PutRule(i32i32),
    Nop,
    Bop([i32; 10]i32),
    Eop,
    Push,
    Pop,
    Right(i32),
    W(Option<i32>),
    X(Option<i32>),
    Down(i32),
    Y(Option<i32>),
    Z(Option<i32>),
    Font(u32),
    Xxx(Vec<u8>),
    FontDef(FontDef),
    Pre {
        format: u8,
        numerator: u32,
        denominator: u32,
        magnification: u32,
        comment: Vec<u8>,
    },
    Post {
        final_bop_pointer: i32,
        numerator: u32,
        denominator: u32,
        magnification: u32,
        tallest_height: i32,
        widest_width: i32,
        max_stack_depth: u16,
        total_no_pages: u16,
    },
    PostPost {
        post_pointer: u32,
        ident: u8,
        two_two_three: u32,
    },
}

A draw instruction

This is the primary unit of a dvi file. Every file is a sequence of instructions following some rules, for example 'preamble only occurs once at the beginning.'

Variants

typeset a character and move right

Typeset character number i from font f such that the reference point of the character is at (h,v). Then increase h by the width of that character. Note that a character may have zero or negative width, so one cannot be sure that h will advance after this command; but h usually does increase.

typeset a rule and move right

Typeset a solid black rectangle of height a and width b, with its bottom left corner at (h,v). Then set h:=h+b. If either a <= 0 or b <= 0, nothing should be typeset. Note that if b < 0, the value of h will decrease even though nothing else happens. Programs that typeset from DVI files should be careful to make the rules line up carefully with digitized characters, as explained in connection with the rule_pixels subroutine below.

typeset a character

Typeset character number c from font f such that the reference point of the character is at (h,v). (The put commands are exactly like the set commands, except that they simply put out a character or a rule without moving the reference point afterwards.)

typeset a rule

Same as set_rule, except that h is not changed.

No-op

No operation, do nothing. Any number of nop's may occur between DVI commands, but a nop cannot be inserted between a command and its parameters or between two parameters.

beginning of page

Set (h,v,w,x,y,z):=(0,0,0,0,0,0) and set the stack empty. Set the current font f to an undefined value. The ten c_i parameters can be used to identify pages. The parameter p points to the previous bop command in the file, where the first bop has p=-1.

ending of page

End of page: Print what you have read since the previous bop. At this point the stack should be empty. (The DVI-reading programs that drive most output devices will have kept a buffer of the material that appears on the page that has just ended. This material is largely, but not entirely, in order by v coordinate and (for fixed v) by h coordinate; so it usually needs to be sorted into some order that is appropriate for the device in question. DVItype does not do such sorting.)

save current positions

Push the current values of (h,v,w,x,y,z) onto the top of the stack; do not change any of these values. Note that f is not pushed.

restore current positions

Pop the top six values off of the stack and assign them to (h,v,w,x,y,z). The number of pops should never exceed the number of pushes, since it would be highly embarrassing if the stack were empty at the time of a pop command.

Move right

Set h:=h+b, i.e., move right b units. The parameter is a signed number in two's complement notation; if b < 0, the reference point actually moves left.

Move right by w

The w0 command sets h:=h+w; i.e., moves right w units. With luck, this parameterless command will usually suffice, because the same kind of motion will occur several times in succession. The other w commands set w:=b and h:=h+b. The value of b is a signed quantity in two's complement notation. This command changes the current w spacing and moves right by b.

Move right by x

The parameterless x0 command sets h:=h+x; i.e., moves right x units. The x commands are like the w commands except that they involve x instead of w. The other x commands set x:=b and h:=h+b. The value of b is a signed quantity in two's complement notation. This command changes the current x spacing and moves right by b.

Move down

Set v:=v+a, i.e., move down a units. The parameter is a signed number in two's complement notation; if a < 0, the reference point actually moves up.

Move down by y

The y0 command sets v:=v+y; i.e., moves down y units. With luck, this parameterless command will usually suffice, because the same kind of motion will occur several times in succession. The other y commands set y:=a and v:=v+a. The value of a is a signed quantity in two's complement notation. This command changes the current y spacing and moves down by a.

Move down by z

The z0 command sets v:=v+z; i.e., moves down z units. The z commands are like the y commands except that they involve z instead of y. The other z commands set z:=a and v:=v+a. The value of a is a signed quantity in two's complement notation. This command changes the current z spacing and moves down by a.

Set current font

Set f:=i. Font i must previously have been defined by a fnt_def instruction, as explained below. TeX82 never generates the fnt2 command, but large font numbers may prove useful for specifications of color or texture, or they may be used for special fonts that have fixed numbers in some external coding scheme.

Extension to DVI primitives

This command is undefined in general; it functions as a k+i+1$-byte nop unless special DVI-reading programs are being used. TeX82 generates xxx1 when a short enough \special appears, setting k to the number of bytes being sent. It is recommended that x be a string having the form of a keyword followed by possible parameters relevant to that keyword.

define the meaning of a font number

The four-byte value c is the check sum that TeX (or whatever program generated the DVI file) found in the TFM file for this font; c should match the check sum of the font found by programs that read this DVI file.

Parameter s contains a fixed-point scale factor that is applied to the character widths in font k; font dimensions in TFM files and other font files are relative to this quantity, which is always positive and less than 227. It is given in the same units as the other dimensions of the DVI file. Parameter d is similar to s; it is the "design size," and (like s) it is given in DVI units. Thus, font k is to be used at mag s / 1000 d times its normal size.

The remaining part of a font definition gives the external name of the font, which is an ASCII string of length a+l. The number a is the length of the "area" or directory, and l is the length of the font name itself; the standard local system font area is supposed to be used when a=0. The n field contains the area in its first a bytes.

Font definitions must appear before the first use of a particular font number. Once font k is defined, it must not be defined again; however, we shall see below that font definitions appear in the postamble as well as in the pages, so in this sense each font number is defined exactly twice, if at all. Like nop commands, font definitions can appear before the first bop, or between an eop and a bop.

preamble

The preamble contains basic information about the file as a whole and must come at the very beginning of the file. The i byte identifies DVI format; currently this byte is always set to 2. (The value i=3 is currently used for an extended format that allows a mixture of right-to-left and left-to-right typesetting. Some day we will set i=4, when DVI format makes another incompatible change - perhaps in the year 2048.)

The next two parameters, num and den, are positive integers that define the units of measurement; they are the numerator and denominator of a fraction by which all dimensions in the DVI file could be multiplied in order to get lengths in units of 10-7 meters. (For example, there are exactly 7227 TeX points in 254 centimeters, and TeX82 works with scaled points where there are 216 sp in a point, so TeX82 sets num=25400000 and den=7227 216=473628672.

The mag parameter is what TeX82 calls \mag, i.e., 1000 times the desired magnification. The actual fraction by which dimensions are multiplied is therefore m n /1000 d. Note that if a TeX source document does not call for any true dimensions, and if you change it only by specifying a different \mag setting, the DVI file that TeX creates will be completely unchanged except for the value of mag in the preamble and postamble. (Fancy DVI-reading programs allow users to override the mag setting when a DVI file is being printed.)

Finally, k and x allow the DVI writer to include a comment, which is not interpreted further. The length of comment x is k, where 0 < = k < 256.

Fields of Pre

postamble beginning

The last page in a DVI file is followed by post; this command introduces the postamble, which summarizes important facts that TeX has accumulated about the file, making it possible to print subsets of the data with reasonable efficiency. The parameter p is a pointer to the final bop in the file. The next three parameters, num, den, and mag, are duplicates of the quantities that appeared in the preamble.

Parameters l and u give respectively the height-plus-depth of the tallest page and the width of the widest page, in the same units as other dimensions of the file. These numbers might be used by a DVI-reading program to position individual "pages" on large sheets of film or paper; however, the standard convention for output on normal size paper is to position each page so that the upper left-hand corner is exactly one inch from the left and the top. Experience has shown that it is unwise to design DVI-to-printer software that attempts cleverly to center the output; a fixed position of the upper left corner is easiest for users to understand and to work with. Therefore l and u are often ignored.

Parameter s is the maximum stack depth (i.e., the largest excess of push commands over pop commands) needed to process this file. Then comes t, the total number of pages (bop commands) present.

The postamble continues with font definitions, which are any number of fnt_def commands as described above, possibly interspersed with nop commands. Each font number that is used in the DVI file must be defined exactly twice: Once before it is first selected by a fnt command, and once in the postamble.

Fields of Post

postamble ending

The last part of the postamble, following the post_post byte that signifies the end of the font definitions, contains q a pointer to the post command that started the postamble. An identification byte, i, comes next; this currently equals 2, as in the preamble.

The i byte is followed by four or more bytes that are all equal to the decimal number 223 (i.e., 337 in octal). TeX puts out four to seven of these trailing bytes, until the total length of the file is a multiple of four bytes, since this works out best on machines that pack four bytes per word; but any number of 223's is allowed, as long as there are at least four of them. In effect, 223 is a sort of signature that is added at the very end.

This curious way to finish off a DVI file makes it feasible for DVI-reading programs to find the postamble first, on most computers, even though TeX wants to write the postamble last. Most operating systems permit random access to individual words or bytes of a file, so the DVI reader can start at the end and skip backwards over the 223's until finding the identification byte. Then it can back up four bytes, read q, and move to byte q of the file. This byte should, of course, contain the value 248 (post); now the postamble can be read, so the DVI reader discovers all the information needed for typesetting the pages. Note that it is also possible to skip through the DVI file at reasonably high speed to locate a particular page, if that proves desirable. This saves a lot of time, since DVI files used in production jobs tend to be large.

Fields of PostPost

Methods

impl Instruction
[src]

Convert this instruction to a string;

Parse an instruction from a byte slice

Trait Implementations

impl Debug for Instruction
[src]

Formats the value using the given formatter.

impl Clone for Instruction
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for Instruction
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for Instruction
[src]