Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

PkFont Class Reference

#include <PkFont.h>

List of all members.

Public Member Functions

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

Static Public Member Functions

verbosities verbosity (const verbosities level)
void setFontSearchPath (string fp)
 Set the list of directories in which to look for fonts.
void setFontSearchPath (char *fp)
 Set the list of directories in which to look for fonts.
void setFontSearchPath (bool yesno)
 Enable or disable using the font-path when searching for fonts.
void setFontSearchCommand (string cmd)
 Set the shell command which is used when searching for fonts.
void setFontSearchCommand (char *cmd)
 Sets the shell command which is used when searching for fonts.
void setFontSearchCommand (bool yesno)
 Enable or disable using a font-search command when searching for fonts.
void setFontSearchKpse (bool yesno)
 Enable or disable using the kpathsea library when searching for fonts.
void setResolution (int res)
 Sets the base font resolution.
void setMissingFontMode (string mode)
 Sets the Metafont mode to be used when generating fonts.
void setFontgen (bool doit)
 Enables or disables font generation.
void setFontgenCommand (string command_template)
 Set the shell command which is used when generating fonts.
int dpiBase ()
 Obtains the base font resolution, in dots-per-inch.
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.


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:
dvimag the scale factor (1.0 = no magnification) by which the font is to be magnified as it is read from the PK file
c the font checksum expected
s fixed-point scale factor applied to the character widths in the font
d the fixed-point `design size' of the font
name the name of the font

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

int PkFont::dpiBase  )  [inline, static]
 

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

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

string PkFont::fontFilename  )  const [inline]
 

Locates the current font's bitmap file.

Returns:
theh path to the PK file which defines this font

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

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

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

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:
includeDviMag if true (the default), include the overall DVI file magnification mag (as set in the constructor); if false, do not
Returns:
the font magnification

string PkFont::name  )  const [inline]
 

Identifies the current font.

Returns:
the font's name

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:
doit if true, font generation is enabled

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:
cmd a font-generation template

void PkFont::setFontSearchCommand bool  useCommand  )  [static]
 

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

Parameters:
useCommand if true, use the command
See also:
setFontSearchCommand(string)

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:
cmd the shell command template

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:
cmd the shell command template

void PkFont::setFontSearchKpse bool  useKpse  )  [static]
 

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

Parameters:
useKpse if true, use the library

void PkFont::setFontSearchPath bool  usePath  )  [static]
 

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

Parameters:
usePath if true, use the font path
See also:
setFontSearchPath(string)

void PkFont::setFontSearchPath char *  fp  )  [static]
 

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

Parameters:
fp the colon-separated font path

void PkFont::setFontSearchPath string  fp  )  [static]
 

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

Parameters:
fp the colon-separated font path

void PkFont::setMissingFontMode string  mode  )  [inline, static]
 

Sets the Metafont mode to be used when generating fonts.

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

Parameters:
mode a Metafont mode

void PkFont::setResolution int  res  )  [inline, static]
 

Sets the base font resolution.

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

Parameters:
res the new font resolution
See also:
dpiBase

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:
fmt the format string, with the format specifiers described above
mode a Metafont mode string, such as ibmvga
fontname the name of a font, such as cmr10
dpi the requested size of a font in dots-per-inch
basedpi the design size of a font
magnification of the font
Returns:
a reference to the formatted string; this is a static string, which is overwritten on each call
Exceptions:
PkError if it encounters an illegal format element.

verbosities PkFont::verbosity const verbosities  level  )  [static]
 

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


The documentation for this class was generated from the following files:
Generated on Sun Aug 21 18:21:09 2005 for dvi2bitmap by doxygen 1.3.8