.TH "DviFile" 3 "Mon Jan 12 2015" "Version dvi2bitmap1.0" "dvi2bitmap" \" -*- nroff -*- .ad l .nh .SH NAME DviFile \- .PP Represents a DVI file\&. .SH SYNOPSIS .br .PP .PP \fC#include \fP .SS "Classes" .in +1c .ti -1c .RI "class \fBFontSet\fP" .br .RI "\fIRepresents the set of fonts in a DVI file\&. \fP" .in -1c .SS "Public Types" .in +1c .ti -1c .RI "enum \fBDviUnits\fP { \fBunit_BAD\fP, \fBunit_pt\fP, \fBunit_pc\fP, \fBunit_in\fP, \fBunit_bp\fP, \fBunit_cm\fP, \fBunit_mm\fP, \fBunit_dd\fP, \fBunit_cc\fP, \fBunit_sp\fP, \fBunit_pixels\fP, \fBunit_dvi\fP }" .br .RI "\fIUnits of length\&. \fP" .in -1c .SS "Public Member Functions" .in +1c .ti -1c .RI "\fBDviFile\fP (string &\fBs\fP, int \fBresolution\fP=0, double magmag=1\&.0, bool read_postamble=true, bool seekable=true) throw (DviError)" .br .RI "\fIConstructs a new \fC\fBDviFile\fP\fP object\&. \fP" .ti -1c .RI "\fB~DviFile\fP ()" .br .ti -1c .RI "bool \fBeof\fP ()" .br .RI "\fIIndicates whether we are at the end of the DVI file\&. \fP" .ti -1c .RI "\fBDviFileEvent\fP * \fBgetEvent\fP ()" .br .RI "\fIGets an event from the DVI file\&. \fP" .ti -1c .RI "\fBDviFileEvent\fP * \fBgetEndOfPage\fP ()" .br .RI "\fISkips to the end of the page\&. \fP" .ti -1c .RI "int \fBcurrH\fP (\fBDviUnits\fP units=\fBunit_pixels\fP) const throw (DviError)" .br .RI "\fIObtains the current horizontal position\&. \fP" .ti -1c .RI "int \fBcurrV\fP (\fBDviUnits\fP units=\fBunit_pixels\fP) const throw (DviError)" .br .RI "\fIObtains the current vertical position\&. \fP" .ti -1c .RI "int \fBhSize\fP ()" .br .RI "\fIObtains the `width of the widest page'\&. \fP" .ti -1c .RI "int \fBvSize\fP ()" .br .RI "\fIObtains the `height plus depth of the tallest page'\&. \fP" .ti -1c .RI "double \fBmagnification\fP () const " .br .RI "\fIReturn the net magnification factor for the DVI file\&. \fP" .ti -1c .RI "int \fBpt2px\fP (double npt) const " .br .RI "\fIConverts a length in points to one in pixels, using the current magnifications and any other relevant parameters\&. \fP" .ti -1c .RI "const string * \fBfilename\fP () const " .br .RI "\fIGets the name of this DVI file\&. \fP" .ti -1c .RI "const \fBPkFont\fP * \fBgetFallbackFont\fP (const \fBPkFont\fP *desired)" .br .RI "\fIReturns a fallback font, for use when a requested font is not available\&. \fP" .ti -1c .RI "bool \fBhaveReadPostamble\fP () const " .br .RI "\fIReports whether the DVI file postamble was read when this file was opened\&. \fP" .ti -1c .RI "const \fBFontSet\fP * \fBgetFontSet\fP () const " .br .RI "\fIObtains a representation of the set of fonts contained in this DVI file\&. \fP" .in -1c .SS "Static Public Member Functions" .in +1c .ti -1c .RI "static \fBDviUnits\fP \fBunitType\fP (string \fBunitString\fP)" .br .RI "\fIConvert a string to a unit\&. \fP" .ti -1c .RI "static string \fBunitString\fP (\fBDviUnits\fP unit)" .br .RI "\fIGets the string representation of a DVI unit\&. \fP" .ti -1c .RI "static double \fBconvertFromScaledPoints\fP (int sp, \fBDviUnits\fP units, \fBDviFile\fP *dvif=0) throw (DviError)" .br .RI "\fIConvert a TeX scaled point to another unit\&. \fP" .ti -1c .RI "static int \fBconvertToScaledPoints\fP (double length, \fBDviUnits\fP units, \fBDviFile\fP *dvif=0) throw (DviError)" .br .RI "\fIConvert a length to TeX scaled points\&. \fP" .ti -1c .RI "static double \fBconvertUnits\fP (double length, \fBDviUnits\fP from_units, \fBDviUnits\fP to_units, \fBDviFile\fP *dvif=0) throw (DviError)" .br .RI "\fIConvert a length from one set of units to another\&. \fP" .ti -1c .RI "static \fBverbosities\fP \fBverbosity\fP (const \fBverbosities\fP level)" .br .RI "\fISets the verbosity of this module\&. \fP" .in -1c .SH "Detailed Description" .PP Represents a DVI file\&. See the DVI Driver standard [driv-std] for details of the parameters here\&. .PP [driv-std] Level-0 DVI Driver Standard, available on-line on CTAN, in the directory \fCdviware/driv-standard\fP\&. .SH "Member Enumeration Documentation" .PP .SS "enum \fBDviFile::DviUnits\fP" .PP Units of length\&. Used in \fBcurrH\fP and \fBcurrV\fP, and other conversions are available through method \fBconvertFromScaledPoints\fP\&. .PP \fBEnumerator\fP .in +1c .TP \fB\fIunit_BAD \fP\fP An invalid unit\&. .TP \fB\fIunit_pt \fP\fP Traditional printer's point\&. There are 72\&.27pt in 1in\&. .TP \fB\fIunit_pc \fP\fP Pica; 1pc=12pt\&. .TP \fB\fIunit_in \fP\fP Inch; 1in=25\&.4mm\&. .TP \fB\fIunit_bp \fP\fP The big point; 72bp=1in\&. Postscript points are bigpoints in this terminology\&. .TP \fB\fIunit_cm \fP\fP Centimetre; 1cm=10E-2m\&. .TP \fB\fIunit_mm \fP\fP Millimetre; 1mm=10E-3m\&. One metre is the distance light travels, in vacuum, in a time 1/299792458 seconds\&. .PP Conversion factors: 1mm=2\&.84527559pt; 1pt=0\&.3515mm\&. .TP \fB\fIunit_dd \fP\fP Didot point; 1157dd=1238pt\&. .TP \fB\fIunit_cc \fP\fP Cicero; 1cc=12dd\&. .TP \fB\fIunit_sp \fP\fP TeX `scaled points'\&. These are the dimensions which TeX itself works in, where 65536sp=1pt, or 1sp=5.36434 * 10**-9 metres\&. Light at that wavelength is classed as soft X-rays, and is a health-hazard (so don't examine your scaled points too closely); it's about the size of 50 atoms\&. .TP \fB\fIunit_pixels \fP\fP Pixel units\&. The DVI standard calls these `device units', and refers to them with the notation \fIhh\fP\&. .TP \fB\fIunit_dvi \fP\fP DVI units\&. All dimensions within the DVI file are expressed in these units, written as \fIh\fP in the standard\&. The conversion of DVI units to physical units is governed by the values in the preamble\&. DVI files written by TeX (that is, essentially all of them, except those written by converters such as \fCdtl\fP, which write compatible ones) have a preamble which ensures that the DVI units are scaled points, times the overall magnification factor\&. .SH "Constructor & Destructor Documentation" .PP .SS "DviFile::DviFile (string &fn, intres = \fC0\fP, doubleexternalmag = \fC1\&.0\fP, boolread_post = \fCtrue\fP, boolseekable = \fCtrue\fP)\fBDviError\fP" .PP Constructs a new \fC\fBDviFile\fP\fP object\&. Once the DVI file has been opened in this way, its contents can be processed in an event-based fashion, by repeatedly calling \fBgetEvent\fP and handling the returned object\&. .PP The DVI file may be specified as '-', in which case the DVI file will be read from \fCstdin\fP\&. In fact, this is just a synonym for the expression, \fC0\fP, as understood by \fBInputByteStream\fP (qv)\&. In this case, the postamble is not read, irrespective of the value of parameter \fCread_post\fP, and this is known not to be seekable, so the value of parameter \fCseekable\fP is ignored\&. .PP After the DVI file has been opened using this constructor, the preamble may or may not be read (this may be specified in future versions)\&. If you need to ensure that the preamble is read (for example if you wish to call \fBconvertUnits\fP), then you should call \fBgetEvent\fP once to retrieve the \fBDviFilePreamble\fP event which it returns the first time it is called\&. .PP \fBParameters:\fP .RS 4 \fIfn\fP the name of the DVI file\&. The given name is searched for both as-is, and with an extension \fC\&.dvi\fP added\&. .br \fIres\fP the base DPI to be used for processing the file, in pixels-per-inch\&. If given as zero, default to the resolution returned by \fBPkFont#dpiBase\fP\&. .br \fIexternalmag\fP the factor by which the DVI file's internal magnification factor should itself be magnified, specified externally to the DVI file (on a command line, for example); default is 1\&.0 .br \fIread_post\fP if true, then the DVI postamble will be read; if false, it will be skipped\&. This is false by default, but if the postamble is read, then the font declarations there will be read and acted on, which \fImay\fP speed things up\&. .br \fIseekable\fP if true, the input file is seekable; if false, it is not seekable, the value of \fCread_post\fP is ignored (taken to be false), and the file is opened without attempting to add any \fC\&.dvi\fP extension\&. .RE .PP \fBExceptions:\fP .RS 4 \fI\fBDviError\fP\fP if the DVI file cannot be opened .RE .PP .PP References DviError::problem(), and PkFont::setResolution()\&. .SS "DviFile::~DviFile ()" .SH "Member Function Documentation" .PP .SS "double DviFile::convertFromScaledPoints (intsp, \fBDviUnits\fPunits, \fBDviFile\fP *dvif = \fC0\fP)\fBDviError\fP\fC [static]\fP" .PP Convert a TeX scaled point to another unit\&. It is possible to convert to pixel units with this method; however it is generally better to either get pixel positions directly (through \fBcurrH\fP or \fBcurrV\fP for example)\&. .PP The conversions to DVIunits and pixels are not universal, but are instead dependent on a particular DVI file; if you wish to convert to either of these units, you must supply a reference to a DVI file\&. If not, any argument here is ignored, and may be zero (the default)\&. .PP \fBParameters:\fP .RS 4 \fIsp\fP the length in scaled points .br \fIunits\fP the unit to convert it to .br \fIdvif\fP a DVI file, if pixels or DVIunits are requested .RE .PP \fBReturns:\fP .RS 4 the converted unit .RE .PP \fBExceptions:\fP .RS 4 \fI\fBDviError\fP\fP if pixels or DVIunits were requested and no dvif parameter was supplied .RE .PP \fBSee Also:\fP .RS 4 \fBconvertToScaledPoints\fP .PP \fBconvertUnits\fP .RE .PP .PP Referenced by DviFilePosition::DviFilePosition(), DviFilePosition::getX(), DviFilePosition::getY(), DviFilePosition::scale(), and DviFilePosition::shift()\&. .SS "int DviFile::convertToScaledPoints (doublelength, \fBDviUnits\fPunits, \fBDviFile\fP *dvif = \fC0\fP)\fBDviError\fP\fC [static]\fP" .PP Convert a length to TeX scaled points\&. The conversions from DVIunits and pixels are not universal, but are instead dependent on a particular DVI file; if you wish to convert from either of these units, you must supply a reference to a DVI file\&. If not, any argument here is ignored, and may be zero (the default)\&. .PP \fBParameters:\fP .RS 4 \fIlength\fP the length to be converted .br \fIunits\fP the units in which the length is currently .br \fIdvif\fP a DVI file, if pixels or DVIunits are requested .RE .PP \fBReturns:\fP .RS 4 the input length as a multiple of the TeX scaled-point .RE .PP \fBExceptions:\fP .RS 4 \fI\fBDviError\fP\fP if pixels or DVIunits were requested and no dvif parameter was supplied .RE .PP \fBSee Also:\fP .RS 4 \fBconvertFromScaledPoints\fP .PP \fBconvertUnits\fP .RE .PP .PP Referenced by DviFilePosition::DviFilePosition(), and DviFilePosition::shift()\&. .SS "double DviFile::convertUnits (doublelength, \fBDviUnits\fPfrom_units, \fBDviUnits\fPto_units, \fBDviFile\fP *dvif = \fC0\fP)\fBDviError\fP\fC [static]\fP" .PP Convert a length from one set of units to another\&. The conversions to DVIunits and pixels are not universal, but are instead dependent on a particular DVI file; if you wish to convert to either of these units, you must supply a reference to a DVI file\&. If not, any argument here is ignored, and may be zero (the default)\&. .PP \fBParameters:\fP .RS 4 \fIlength\fP the length to be converted .br \fIfrom_units\fP the units in which length is currently expressed .br \fIto_units\fP the target units .br \fIdvif\fP a DVI file, if pixels or DVIunits are requested .RE .PP \fBReturns:\fP .RS 4 the length expressed as a multiple of the target unit .RE .PP \fBExceptions:\fP .RS 4 \fI\fBDviError\fP\fP if pixels or DVIunits were requested and no dvif parameter was supplied .RE .PP \fBSee Also:\fP .RS 4 \fBconvertFromScaledPoints\fP .PP \fBconvertToScaledPoints\fP .RE .PP .PP Referenced by main()\&. .SS "int DviFile::currH (\fBDviUnits\fPunits = \fC\fBunit_pixels\fP\fP) const\fBDviError\fP\fC [inline]\fP" .PP Obtains the current horizontal position\&. The position can be reported in any of \fBunit_pixels\fP, \fBunit_dvi\fP or \fBunit_sp\fP; it is an error to call this function with any other of the defined units\&. .PP The conversion to pixel units includes any drift correction, and is correctly rounded\&. Scaled points are calculated as DVI units times the overall magnification (that is, we ignore the general case of DVI files with odd preamble scalings)\&. .PP \fBReturns:\fP .RS 4 the horizontal position, in the chosen units .RE .PP \fBExceptions:\fP .RS 4 \fI\fBDviError\fP\fP if we are invoked with an inappropriate unit argument .RE .PP .PP References unit_dvi, unit_pixels, and unit_sp\&. .PP Referenced by main(), and show_position()\&. .SS "int DviFile::currV (\fBDviUnits\fPunits = \fC\fBunit_pixels\fP\fP) const\fBDviError\fP\fC [inline]\fP" .PP Obtains the current vertical position\&. See \fBcurrH\fP, to which this is precisely analogous\&. .PP References unit_dvi, unit_pixels, and unit_sp\&. .PP Referenced by main(), and show_position()\&. .SS "bool DviFile::eof ()" .PP Indicates whether we are at the end of the DVI file\&. This is true if the underlying file is closed, \fIor\fP if we have read all the pages and \fBgetEvent\fP has returned a \fBDviFilePostamble\fP event\&. .PP \fBReturns:\fP .RS 4 true if we are at EOF .RE .PP .PP References InputByteStream::eof()\&. .PP Referenced by getEvent(), and main()\&. .SS "const string* DviFile::filename () const\fC [inline]\fP" .PP Gets the name of this DVI file\&. .PP \fBReturns:\fP .RS 4 the open file name as a string .RE .PP .PP Referenced by main()\&. .SS "\fBDviFileEvent\fP * DviFile::getEndOfPage ()" .PP Skips to the end of the page\&. This reads the DVI file at high speed until it finds the next end-of-page event, which it returns, leaving the DVI file positioned appropriately\&. If there are in fact no more pages -- if the last end-of-page event has already been returned -- then return either a \fBDviFilePostamble\fP event or zero, just like \fBgetEvent\fP\&. .PP \fBReturns:\fP .RS 4 the next end-of-page event .RE .PP .PP References getEvent()\&. .PP Referenced by main()\&. .SS "\fBDviFileEvent\fP * DviFile::getEvent ()" .PP Gets an event from the DVI file\&. This is the routine which does most of the actual work\&. It scans through the file reading opcodes\&. Most of these it handles itself, but certain ones it handles by returning an event to the calling routine\&. .PP The first event this method will return is the \fBDviFilePreamble\fP event, and the last one is a \fBDviFilePostamble\fP event, after which \fC\fBeof()\fP\fP will be true, and this method will return only zero\&. .PP The events which can be returned are all of the subclasses of \fBDviFileEvent\fP, qv\&. .PP When you are finished with the returned event, you should release it by a call to the event's \fBrelease\fP method, after which you should make no further reference to it\&. .PP \fBReturns:\fP .RS 4 the next event from the DVI file, or zero if \fC\fBeof()\fP\fP is true .RE .PP .PP References DviFilePreamble::comment, DviFilePage::count, DviFilePreamble::den, DviFilePreamble::dviType, eof(), i, DviFilePreamble::mag, normal, DviFilePreamble::num, and DviFilePage::previous\&. .PP Referenced by getEndOfPage(), and main()\&. .SS "const \fBPkFont\fP * DviFile::getFallbackFont (const \fBPkFont\fP *desired)" .PP Returns a fallback font, for use when a requested font is not available\&. The font returned depends on whether the DVI postamble was read or not, on what fonts have already been seen in the file, and on the font desired\&. This flexibility will not, however, stray beyond the liberty given by section 4\&.4, `Missing fonts', in the DVI standard\&. .PP \fBParameters:\fP .RS 4 \fIdesired\fP a pointer to the font which was requested (but not, presumably, loaded), or 0 if this information is not available .RE .PP \fBReturns:\fP .RS 4 a pointer to a fallback font, or zero if absolutely no fonts are available .RE .PP .PP References DviFile::FontSet::begin(), PkFont::designSize, DviFile::FontSet::end(), and getFontSet()\&. .PP Referenced by main()\&. .SS "const \fBFontSet\fP* DviFile::getFontSet () const\fC [inline]\fP" .PP Obtains a representation of the set of fonts contained in this DVI file\&. If the postamble was read, then the \fC\fBFontSet\fP\fP returned by this method will be complete; if not, it will simply represent the set of fonts read so far in the file\&. .PP \fBReturns:\fP .RS 4 a pointer to the \fBFontSet\fP for this file .RE .PP .PP Referenced by getFallbackFont(), and main()\&. .SS "bool DviFile::haveReadPostamble () const\fC [inline]\fP" .PP Reports whether the DVI file postamble was read when this file was opened\&. This affects the semantics of such methods as \fBgetFontSet\fP\&. Note that this only reports whether the postamble was read at the \fIstart\fP of processing, and it does not become true when the postamble is discovered at the end; it is not an end-of-file indicator\&. For that, see the \fBeof\fP method\&. .PP \fBReturns:\fP .RS 4 true if the postamble was (successfully) read .RE .PP .PP Referenced by main()\&. .SS "int DviFile::hSize ()" .PP Obtains the `width of the widest page'\&. This is either the value obtained from the postamble of the DVI file, if that was read, or else the maximum value of the horizontal position (as returned by \fC\fBcurrH()\fP\fP), if that is larger\&. If the postamble has not been read, then this is initialised to -1\&. Note that this isn't the same as the maximum value of \fBcurrH\fP, any more than 0 is the minimum, but if the origin is set `appropriately' (ie, at (1in,1in)), then everything should fit on\&. It's not a precise figure, but can be useful as a scale for initialising bitmap sizes, for example\&. .PP \fBReturns:\fP .RS 4 the horizontal size of the largest `page', in pixels .RE .PP .PP Referenced by main()\&. .SS "double DviFile::magnification () const\fC [inline]\fP" .PP Return the net magnification factor for the DVI file\&. .PP \fBReturns:\fP .RS 4 the overall magnification factor applied to lengths in the DVI file\&. A value of 1\&.0 implies no magnification at all\&. .RE .PP .PP Referenced by main()\&. .SS "int DviFile::pt2px (doublenpt) const\fC [inline]\fP" .PP Converts a length in points to one in pixels, using the current magnifications and any other relevant parameters\&. .PP \fBParameters:\fP .RS 4 \fInpt\fP a length in points .RE .PP \fBReturns:\fP .RS 4 the given length, in pixels .RE .PP .SS "string DviFile::unitString (\fBDviFile::DviUnits\fPunit)\fC [static]\fP" .PP Gets the string representation of a DVI unit\&. .PP \fBParameters:\fP .RS 4 \fIunit\fP the unit in question .RE .PP \fBReturns:\fP .RS 4 a string representing the unit .RE .PP .PP References MAP\&. .PP Referenced by main()\&. .SS "\fBDviFile::DviUnits\fP DviFile::unitType (stringunitString)\fC [static]\fP" .PP Convert a string to a unit\&. .PP \fBParameters:\fP .RS 4 \fIunitString\fP one of the strings representing a DVI unit .RE .PP \fBReturns:\fP .RS 4 the appropriate member of the \fBDviUnits\fP enum, or \fBunit_BAD\fP if the unit string is not recognised .RE .PP .PP References i, MAP, u, unit_BAD, unit_dvi, and unit_pixels\&. .PP Referenced by main()\&. .SS "\fBverbosities\fP DviFile::verbosity (const \fBverbosities\fPlevel)\fC [static]\fP" .PP Sets the verbosity of this module\&. .PP \fBParameters:\fP .RS 4 \fIlevel\fP the required verbosity .RE .PP \fBReturns:\fP .RS 4 the previous verbosity level .RE .PP .PP References DviFileEvent::verbosity()\&. .PP Referenced by main()\&. .SS "int DviFile::vSize ()" .PP Obtains the `height plus depth of the tallest page'\&. .PP .nf This is either the .fi .PP value obtained from the postamble of the DVI file, if that was read, or else the maximum value of the vertical position (as returned by \fC\fBcurrV()\fP\fP), if that is larger\&. If the postamble has not been read, then this is initialised to -1\&. Note that this isn't the same as the maximum value of \fBcurrV\fP, any more than 0 is the minimum, but if the origin is set `appropriately' (ie, at (1in,1in)), then everything should fit on\&. It's not a precise figure, but can be useful as a scale for initialising bitmap sizes, for example\&. .PP \fBReturns:\fP .RS 4 the vertical size of the largest `page', in pixels .RE .PP .PP Referenced by main()\&. .SH "Member Data Documentation" .PP .SS "string DviFile::comment" .SS "unsigned int DviFile::den" .SS "unsigned int DviFile::i" .PP Referenced by getEvent(), and unitType()\&. .SS "unsigned int DviFile::l" .SS "unsigned int DviFile::mag" .SS "unsigned int DviFile::num" .SS "unsigned int DviFile::s" .SS "unsigned int DviFile::t" .SS "unsigned int DviFile::u" .PP Referenced by unitType()\&. .SH "Author" .PP Generated automatically by Doxygen for dvi2bitmap from the source code\&.