The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
dvi2bitmap
dvi2bitmap1.0
|
Represents a DVI file. More...
#include <DviFile.h>
Classes | |
class | FontSet |
Represents the set of fonts in a DVI file. More... | |
Public Types | |
enum | DviUnits { unit_BAD, unit_pt, unit_pc, unit_in, unit_bp, unit_cm, unit_mm, unit_dd, unit_cc, unit_sp, unit_pixels, unit_dvi } |
Units of length. More... | |
Public Member Functions | |
DviFile (string &s, int resolution=0, double magmag=1.0, bool read_postamble=true, bool seekable=true) throw (DviError) | |
Constructs a new DviFile object. More... | |
~DviFile () | |
bool | eof () |
Indicates whether we are at the end of the DVI file. More... | |
DviFileEvent * | getEvent () |
Gets an event from the DVI file. More... | |
DviFileEvent * | getEndOfPage () |
Skips to the end of the page. More... | |
int | currH (DviUnits units=unit_pixels) const throw (DviError) |
Obtains the current horizontal position. More... | |
int | currV (DviUnits units=unit_pixels) const throw (DviError) |
Obtains the current vertical position. More... | |
int | hSize () |
Obtains the `width of the widest page'. More... | |
int | vSize () |
Obtains the `height plus depth of the tallest page'. More... | |
double | magnification () const |
Return the net magnification factor for the DVI file. More... | |
int | pt2px (double npt) const |
Converts a length in points to one in pixels, using the current magnifications and any other relevant parameters. More... | |
const string * | filename () const |
Gets the name of this DVI file. More... | |
const PkFont * | getFallbackFont (const PkFont *desired) |
Returns a fallback font, for use when a requested font is not available. More... | |
bool | haveReadPostamble () const |
Reports whether the DVI file postamble was read when this file was opened. More... | |
const FontSet * | getFontSet () const |
Obtains a representation of the set of fonts contained in this DVI file. More... | |
Static Public Member Functions | |
static DviUnits | unitType (string unitString) |
Convert a string to a unit. More... | |
static string | unitString (DviUnits unit) |
Gets the string representation of a DVI unit. More... | |
static double | convertFromScaledPoints (int sp, DviUnits units, DviFile *dvif=0) throw (DviError) |
Convert a TeX scaled point to another unit. More... | |
static int | convertToScaledPoints (double length, DviUnits units, DviFile *dvif=0) throw (DviError) |
Convert a length to TeX scaled points. More... | |
static double | convertUnits (double length, DviUnits from_units, DviUnits to_units, DviFile *dvif=0) throw (DviError) |
Convert a length from one set of units to another. More... | |
static verbosities | verbosity (const verbosities level) |
Sets the verbosity of this module. More... | |
Represents a DVI file.
See the DVI Driver standard [driv-std] for details of the parameters here.
[driv-std] Level-0 DVI Driver Standard, available on-line on CTAN, in the directory dviware/driv-standard.
enum DviFile::DviUnits |
Units of length.
Used in currH and currV, and other conversions are available through method convertFromScaledPoints.
DviFile::DviFile | ( | string & | fn, |
int | res = 0 , |
||
double | externalmag = 1.0 , |
||
bool | read_post = true , |
||
bool | seekable = true |
||
) | |||
throw | ( | DviError | |
) |
Constructs a new DviFile
object.
Once the DVI file has been opened in this way, its contents can be processed in an event-based fashion, by repeatedly calling getEvent and handling the returned object.
The DVI file may be specified as "-", in which case the DVI file will be read from stdin
. In fact, this is just a synonym for the expression, <osfd>0
, as understood by InputByteStream (qv). In this case, the postamble is not read, irrespective of the value of parameter read_post
, and this is known not to be seekable, so the value of parameter seekable
is ignored.
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 convertUnits), then you should call getEvent once to retrieve the DviFilePreamble event which it returns the first time it is called.
fn | the name of the DVI file. The given name is searched for both as-is, and with an extension .dvi added. |
res | the base DPI to be used for processing the file, in pixels-per-inch. If given as zero, default to the resolution returned by PkFont#dpiBase. |
externalmag | 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 |
read_post | 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 may speed things up. |
seekable | if true, the input file is seekable; if false, it is not seekable, the value of read_post is ignored (taken to be false), and the file is opened without attempting to add any .dvi extension. |
DviError | if the DVI file cannot be opened |
References DviError::problem(), and PkFont::setResolution().
DviFile::~DviFile | ( | ) |
|
static |
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 currH or currV for example).
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).
sp | the length in scaled points |
units | the unit to convert it to |
dvif | a DVI file, if pixels or DVIunits are requested |
DviError | if pixels or DVIunits were requested and no dvif parameter was supplied |
Referenced by DviFilePosition::DviFilePosition(), DviFilePosition::getX(), DviFilePosition::getY(), DviFilePosition::scale(), and DviFilePosition::shift().
|
static |
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).
length | the length to be converted |
units | the units in which the length is currently |
dvif | a DVI file, if pixels or DVIunits are requested |
DviError | if pixels or DVIunits were requested and no dvif parameter was supplied |
Referenced by DviFilePosition::DviFilePosition(), and DviFilePosition::shift().
|
static |
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).
length | the length to be converted |
from_units | the units in which length is currently expressed |
to_units | the target units |
dvif | a DVI file, if pixels or DVIunits are requested |
DviError | if pixels or DVIunits were requested and no dvif parameter was supplied |
Referenced by main().
|
inline |
Obtains the current horizontal position.
The position can be reported in any of unit_pixels, unit_dvi or unit_sp; it is an error to call this function with any other of the defined units.
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).
DviError | if we are invoked with an inappropriate unit argument |
References unit_dvi, unit_pixels, and unit_sp.
Referenced by main(), and show_position().
|
inline |
Obtains the current vertical position.
See currH, to which this is precisely analogous.
References unit_dvi, unit_pixels, and unit_sp.
Referenced by main(), and show_position().
bool DviFile::eof | ( | ) |
Indicates whether we are at the end of the DVI file.
This is true if the underlying file is closed, or if we have read all the pages and getEvent has returned a DviFilePostamble event.
References InputByteStream::eof().
Referenced by getEvent(), and main().
|
inline |
DviFileEvent * DviFile::getEndOfPage | ( | ) |
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 DviFilePostamble event or zero, just like getEvent.
References getEvent().
Referenced by main().
DviFileEvent * DviFile::getEvent | ( | ) |
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.
The first event this method will return is the DviFilePreamble event, and the last one is a DviFilePostamble event, after which eof()
will be true, and this method will return only zero.
The events which can be returned are all of the subclasses of DviFileEvent, qv.
When you are finished with the returned event, you should release it by a call to the event's release method, after which you should make no further reference to it.
eof()
is true References DviFilePreamble::comment, DviFilePage::count, DviFilePreamble::den, DviFilePreamble::dviType, eof(), i, DviFilePreamble::mag, normal, DviFilePreamble::num, and DviFilePage::previous.
Referenced by getEndOfPage(), and main().
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.
desired | a pointer to the font which was requested (but not, presumably, loaded), or 0 if this information is not available |
References DviFile::FontSet::begin(), PkFont::designSize, DviFile::FontSet::end(), and getFontSet().
Referenced by main().
|
inline |
Obtains a representation of the set of fonts contained in this DVI file.
If the postamble was read, then the FontSet
returned by this method will be complete; if not, it will simply represent the set of fonts read so far in the file.
Referenced by getFallbackFont(), and main().
|
inline |
Reports whether the DVI file postamble was read when this file was opened.
This affects the semantics of such methods as getFontSet. Note that this only reports whether the postamble was read at the start 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 eof method.
Referenced by main().
int DviFile::hSize | ( | ) |
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 currH()
), 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 currH, 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.
Referenced by main().
|
inline |
Return the net magnification factor for the DVI file.
Referenced by main().
|
inline |
Converts a length in points to one in pixels, using the current magnifications and any other relevant parameters.
npt | a length in points |
|
static |
|
static |
|
static |
Sets the verbosity of this module.
level | the required verbosity |
References DviFileEvent::verbosity().
Referenced by main().
int DviFile::vSize | ( | ) |
Obtains the `height plus depth of the tallest 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 vertical position (as returned by currV()
), 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 currV, 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.
Referenced by main().
string DviFile::comment |
unsigned int DviFile::den |
unsigned int DviFile::i |
Referenced by getEvent(), and unitType().
unsigned int DviFile::l |
unsigned int DviFile::mag |
unsigned int DviFile::num |
unsigned int DviFile::s |
unsigned int DviFile::t |
unsigned int DviFile::u |
Referenced by unitType().
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.