NAME

TeX::XDV::Parse - Perl extension for parsing TeX XDV files

SYNOPSIS

package My_XDV_Parser;
use TeX::XDV::Parse;
@ISA = qw( TeX::XDV::Parse );

sub dir {...}
sub pic_file {...}
sub glyph_array {...}
sub glyph_string {...}
sub native_font_def {...}

DESCRIPTION

TeX::XDV::Parse is an extension of TeX::DVI::Parse, much as XDV is an extension of DVI. This module simply overlays the additional XDV functionality on top of TeX::DVI::Parse and inherits its interface.

To use, you should subclass this module and define functions to handle each of the XDV/DVI commands. Each command will be passed the appropriate arguments. For example:

sub dir {
  my ($self, $opcode, $direction) = @_;
  ...
}

See the TeX::DVI::Parse documentation for details on the DVI commands.

METHODS

dir( direction )

Sets either left to right or top to bottom direction.

0 = horizontal
1 = vertical

pic_file( $type, $a, $b, $c, $d, $tx, $ty, $page, $len, $file )

Sets an image.

type : file type
   a : affine transform element
   b : affine transform element
   c : affine transform element
   d : affine transform element
  tx : affine transform element
  ty : affine transform element
 len : length of filename
page : page number
file : filename

The affine transform takes the form

[ a   b   0 ]
[ c   d   0 ]
[ tx  ty  1 ]

In general though, to transform a point (x,y):

x' = ax + cy + tx
y' = bx + dy + ty

glyph_string( $width, $count, $x_loc, ..., $glyph, ... )

Set a string of glyphs.

width : TeX width
count : glyph count
x_loc : TeX horizontal location (x count)
glyph : glyph id (x count)

The glyph string will generally be broken at word boundaries with whitespace excluded. The exception is at line endings where a word is hypenated. The word will naturally be broken into two seperate glyph strings.

x_loc and glyph are repeated count times.

glyph is the glyph id of the character to set in the current font, which isn't necessarily the same as the characters ordinal value.

glyph_array( $width, $count, $x_loc, $y_loc, ..., $glyph, ... )

Set an array of glyphs.

width : TeX width
count : glyph count
x_loc : TeX horizontal location (x count)
y_loc : TeX vertical location (x count)
glyph : glyph id (x count)

A glyph array is similar to a glyph string, but also include vertical location information.

x_loc and y_loc are sent in pairs. The pairs are repeated count times. glyph is also repeated count times, but after all the x_loc and y_loc pairs.

glyph is the glyph id of the character to set in the current font, which isn't necessarily the same as the characters ordinal value.

native_font_def( $k, $ps, $fl, $p_len, $f_len, $s_len, $n, $f, $s, $c, $n, $v, $ext, $slt, $emb )

Defines a font.

    k : font id
   ps : point size in TeX units
   fl : flags
p_len : ps name len
f_len : family name len
s_len : style name len
    n : font_name
    f : fam_name
    s : sty_name
    c : rgba_color
    n : nvars
    v : variations * nvars
  ext : extend
  slt : slant
  emb : embolden

Many of these are unknown. k, ps, and n are the only ones seen so far. See the source code for some flag constants and how the command is decoded. Any information regarding this, or documentation patches welcome.

EXPORT

None.

SEE ALSO

TeX::DVI::Parse

AUTHOR

Rick Myers, <jrm at cpan dot org>

COPYRIGHT AND LICENSE

Copyright (C) 2013 by Rick Myers

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.16.3 or, at your option, any later version of Perl 5 you may have available.