dvi2bitmap  dvi2bitmap1.0
Public Member Functions | Static Public Member Functions | List of all members
PkFont Class Reference

#include <PkFont.h>

Public Member Functions

 PkFont (double fontmag, unsigned int c, unsigned int s, unsigned int d, string name)
 Represents a PK font. More...
 
 ~PkFont ()
 
PkGlyphglyph (unsigned int i) const
 Returns the glyph at a given position in this font. More...
 
string fontgenCommand () const
 Returns a command which can be used to generate fonts. More...
 
string name () const
 Identifies the current font. More...
 
string fontFilename () const
 Locates the current font's bitmap file. More...
 
double magnification (bool includeDviMag=true) const
 Obtain the magnification of this font. More...
 
int dpiScaled () const
 Obtains the resolution of the current font, taking magnification into account. More...
 
double scale () const
 Obtains the font's scale. More...
 
bool seenInDoc (void) const
 Has the current font been declared in the document so far, or just in the DVI file postamble. More...
 
void setSeenInDoc (void)
 
double wordSpace () const
 Obtains the size of the word_space parameter for this font. More...
 
double backSpace () const
 Obtains the size of the back_space parameter for this font. More...
 
double quad () const
 Obtains the size of the quad parameter for this font. More...
 
double designSize () const
 Obtains the design size of this font, as obtained from the PK file preamble. More...
 
double hppp () const
 Obtains the number of horizontal pixels per point for this font, as obtained from the PK file preamble. More...
 
double vppp () const
 Obtains the number of vertical pixels per point for this font, as obtained from the PK file preamble. More...
 
unsigned int checksum () const
 Obtains the font checksum, as obtained from the PK file preamble. More...
 
bool loaded () const
 Check if the font has actually been loaded. More...
 

Static Public Member Functions

static verbosities verbosity (const verbosities level)
 
static void setFontSearchPath (string fp)
 Set the list of directories in which to look for fonts. More...
 
static void setFontSearchPath (char *fp)
 Set the list of directories in which to look for fonts. More...
 
static void setFontSearchPath (bool yesno)
 Enable or disable using the font-path when searching for fonts. More...
 
static void setFontSearchCommand (string cmd)
 Set the shell command which is used when searching for fonts. More...
 
static void setFontSearchCommand (char *cmd)
 Sets the shell command which is used when searching for fonts. More...
 
static void setFontSearchCommand (bool yesno)
 Enable or disable using a font-search command when searching for fonts. More...
 
static void setFontSearchKpse (bool yesno)
 Enable or disable using the kpathsea library when searching for fonts. More...
 
static void setResolution (int res)
 Sets the base font resolution. More...
 
static void setMissingFontMode (string mode)
 Sets the Metafont mode to be used when generating fonts. More...
 
static void setFontgen (bool doit)
 Enables or disables font generation. More...
 
static void setFontgenCommand (string command_template)
 Set the shell command which is used when generating fonts. More...
 
static int dpiBase ()
 Obtains the base font resolution, in dots-per-inch. More...
 
static string & substitute_font_string (const string fmt, const string mode, const string fontname, const int dpi, const int basedpi, const double magnification) throw (PkError)
 Given a format string, return a reference to a string with format specifiers replaced by font information. More...
 

Constructor & Destructor Documentation

PkFont::PkFont ( double  dvimag,
unsigned int  c,
unsigned int  s,
unsigned int  d,
string  name 
)

Represents a PK font.

The constructor arguments are those read from the DVI file font declaration, after a fnt_def opcode, except for dvimag, which is the overall DVI magnification factor, and includes the file and command-line magnification adjustments. For more details, see the definition of the font declaration in section `A.4 Font defintions' of the DVI standard, and the use of these factors in method magnification.

Parameters
dvimagthe scale factor (1.0 = no magnification) by which the font is to be magnified as it is read from the PK file
cthe font checksum expected
sfixed-point scale factor applied to the character widths in the font
dthe fixed-point `design size' of the font
namethe name of the font

References c, d, dpiScaled(), fontgenCommand(), PipeStream::getResult(), PipeStream::getTerminationStatus(), magnification(), normal, DviError::problem(), quiet, and s.

PkFont::~PkFont ( )

Member Function Documentation

double PkFont::backSpace ( ) const
inline

Obtains the size of the back_space parameter for this font.

This does not include any overall DVI magnification.

Returns
back_space in DVI units
unsigned int PkFont::checksum ( ) const
inline

Obtains the font checksum, as obtained from the PK file preamble.

Returns
checksum
double PkFont::designSize ( ) const
inline

Obtains the design size of this font, as obtained from the PK file preamble.

Returns
the design size in points
static int PkFont::dpiBase ( )
inlinestatic

Obtains the base font resolution, in dots-per-inch.

This is the base resolution corresponding to the Metafont mode set by setMissingFontMode, and the two must be consistent if font-generation is to work.

Returns
the font resolution, in dots-per-inch
See Also
setResolution

Referenced by fontgenCommand(), KarlPathSearcher::getInstance(), and main().

int PkFont::dpiScaled ( ) const
inline

Obtains the resolution of the current font, taking magnification into account.

Returns
the font's resolution, in dots-per-inch

References magnification().

Referenced by fontgenCommand(), main(), and PkFont().

string PkFont::fontFilename ( ) const
inline

Locates the current font's bitmap file.

Returns
theh path to the PK file which defines this font

Referenced by main().

string PkFont::fontgenCommand ( void  ) const

Returns a command which can be used to generate fonts.

The command should return a single line containing the path to the generated font file. Return an empty string on errors, or if such a command is not supported on a particular platform.

Note that if a font-generation command template is defined but automatic font generation is disabled, this still returns a font-generation command.

Returns
a font generation command, suitable for passing to a shell

References dpiBase(), dpiScaled(), magnification(), normal, DviError::problem(), quiet, substitute_font_string(), and Util::verbosity_.

Referenced by main(), and PkFont().

PkGlyph* PkFont::glyph ( unsigned int  i) const
inline

Returns the glyph at a given position in this font.

If the font has not been loaded, it returns a dummy glyph.

Returns
the numbered glyph from the font

Referenced by main().

double PkFont::hppp ( ) const
inline

Obtains the number of horizontal pixels per point for this font, as obtained from the PK file preamble.

Returns
the hppp parameter in points
bool PkFont::loaded ( ) const
inline

Check if the font has actually been loaded.

This is false if the font was declared in the DVI file, but its bitmaps were not or cound not be loaded from disk for some reason.

Returns
true if the font was successfully read from disk

Referenced by main().

double PkFont::magnification ( bool  includeDviMag = true) const

Obtain the magnification of this font.

This includes both font scaling and overall DVI file magnification: this number is mag/1000 . s/d, where s and d are taken from the font definition in the DVI file, and mag is the total magnification taking into account DVI preamble magnification and any command-line overriding.

Parameters
includeDviMagif true (the default), include the overall DVI file magnification mag (as set in the constructor); if false, do not
Returns
the font magnification

References normal, and Util::verbosity_.

Referenced by dpiScaled(), fontgenCommand(), main(), and PkFont().

string PkFont::name ( ) const
inline

Identifies the current font.

Returns
the font's name

Referenced by DviFileFontChange::debug(), and main().

double PkFont::quad ( ) const
inline

Obtains the size of the quad parameter for this font.

This does not include any overall DVI magnification.

Returns
quad in DVI units
double PkFont::scale ( ) const
inline

Obtains the font's scale.

This is the factor s/d, where s and d are the font scale and font design size as specified when the font was declared in the DVI file. Together, they specify that the font is to be used at magnification/1000 . s/d times its design size. This is distinct from the return value of magnification, which takes DVI file magnification into account, and which is therefore more useful in general.

Returns
the font scale, s/d
bool PkFont::seenInDoc ( void  ) const
inline

Has the current font been declared in the document so far, or just in the DVI file postamble.

Returns
true if we have seen a fnt_def declaration for this font, in the DVI file body
void PkFont::setFontgen ( bool  doit)
static

Enables or disables font generation.

Font generation will only be enabled if there is a font-generation template command, either set through method setFontgenCommand, or as a compiled-in default. If there is no such command, this method will have no effect.

Parameters
doitif true, font generation is enabled

Referenced by main().

void PkFont::setFontgenCommand ( string  cmd)
static

Set the shell command which is used when generating fonts.

The specified string should be a template string with the formatting characters managed by substitute_font_string, and these will be substituted with the required values before the command is run.

This also enables font-generation, so that it has the effect of setFontgen(true).

Parameters
cmda font-generation template

Referenced by main().

void PkFont::setFontSearchCommand ( string  cmd)
static

Set the shell command which is used when searching for fonts.

The specified string should be a template string with the formatting characters managed by substitute_font_string, and these will be substituted with the required values before the command is run.

Parameters
cmdthe shell command template

Referenced by main(), and setFontSearchCommand().

void PkFont::setFontSearchCommand ( char *  cmd)
static

Sets the shell command which is used when searching for fonts.

The specified string should be a template string with the formatting characters managed by substitute_font_string, and these will be substituted with the required values before the command is run.

Parameters
cmdthe shell command template

References s, and setFontSearchCommand().

void PkFont::setFontSearchCommand ( bool  useCommand)
static

Enable or disable using a font-search command when searching for fonts.

Parameters
useCommandif true, use the command
See Also
setFontSearchCommand(string)
void PkFont::setFontSearchKpse ( bool  useKpse)
static

Enable or disable using the kpathsea library when searching for fonts.

Parameters
useKpseif true, use the library

Referenced by main().

void PkFont::setFontSearchPath ( string  fp)
static

Set the list of directories in which to look for fonts.

Parameters
fpthe colon-separated font path

Referenced by main(), and setFontSearchPath().

void PkFont::setFontSearchPath ( char *  fp)
static

Set the list of directories in which to look for fonts.

Parameters
fpthe colon-separated font path

References s, and setFontSearchPath().

void PkFont::setFontSearchPath ( bool  usePath)
static

Enable or disable using the font-path when searching for fonts.

Parameters
usePathif true, use the font path
See Also
setFontSearchPath(string)
static void PkFont::setMissingFontMode ( string  mode)
inlinestatic

Sets the Metafont mode to be used when generating fonts.

This must be consistent with any base font resolution set in setResolution.

Parameters
modea Metafont mode

Referenced by main().

static void PkFont::setResolution ( int  res)
inlinestatic

Sets the base font resolution.

This must be consistent with the the Metafont mode set by setMissingFontMode, if font-generation is to work.

Parameters
resthe new font resolution
See Also
dpiBase

Referenced by DviFile::DviFile(), and main().

void PkFont::setSeenInDoc ( void  )
inline
string & PkFont::substitute_font_string ( const string  fmt,
const string  mode,
const string  fontname,
const int  dpi,
const int  basedpi,
const double  magnification 
)
throw (PkError
)
static

Given a format string, return a reference to a string with format specifiers replaced by font information.

The format specifiers are:

Mmodeibmvga
ffont namecmr10
ddpi330
bbase dpi110
mmagnification3
%%literal %-character

Any other format specifiers constitute an error. There is no support for any backslash escapes.

Parameters
fmtthe format string, with the format specifiers described above
modea Metafont mode string, such as ibmvga
fontnamethe name of a font, such as cmr10
dpithe requested size of a font in dots-per-inch
basedpithe design size of a font
magnificationof the font
Returns
a reference to the formatted string; this is a static string, which is overwritten on each call
Exceptions
PkErrorif it encounters an illegal format element.

References normal, SS_C_STR, SS_STRING, SSTREAM, and Util::verbosity_.

Referenced by fontgenCommand().

verbosities PkFont::verbosity ( const verbosities  level)
static

References KarlPathSearcher::verbosity().

Referenced by main().

double PkFont::vppp ( ) const
inline

Obtains the number of vertical pixels per point for this font, as obtained from the PK file preamble.

Returns
the vppp parameter in points
double PkFont::wordSpace ( ) const
inline

Obtains the size of the word_space parameter for this font.

This does not include any overall DVI magnification.

Returns
word_space in DVI units

Member Data Documentation

unsigned int PkFont::c

Referenced by PkFont().

string PkFont::comment
unsigned int PkFont::cs
unsigned int PkFont::d

Referenced by PkFont().

double PkFont::designSize
double PkFont::hppp
unsigned int PkFont::id
unsigned int PkFont::s
double PkFont::vppp

The documentation for this class was generated from the following files: