3.1.3.9. Tfm¶
This module handles TeX Font Metric.
The class PyDvi.Tfm handles the font’s metric. To get a PyDvi.Tfm instance for a
particular font use the static method PyDvi.TfmParser.TfmParser.parse(). For example use this
code for the font “cmr10”:
tfm = TfmParser.parse('cmr10', '/usr/share/texmf/fonts/tfm/public/cm/cmr10.tfm')
The number of characters in the font can be obtained using the function len():
>>> len(tfm)
128
Each character’s metric is stored in a TfmChar instance that can be accessed using the char
code as index on the Tfm class instance. For example to get the metric of the character
“A” use:
tfm[ord('A')]
-
class
PyDvi.Font.Tfm.Tfm(font_name, filename, smallest_character_code, largest_character_code, checksum, design_font_size, character_coding_scheme, family)[source]¶ Bases:
objectThis class encapsulates a TeX Font Metric for a font.
Public attributes:
font_name- font’s name
filename- ”.tfm” filename
smallest_character_code- smallest character code of the font
largest_character_code- largest character code of the font
checksum- checksum of the tfm file
design_font_size- design font size
character_coding_scheme- character coding scheme
family- font’s family
slantspacingspace_stretchspace_shrinkx_heightquadextra_spaceIn addition for Math font, the following public attributes are available:
um1num2num3denom1denom2sup1sup2sup3sub1sub2supdropsubdropdelim1delim2axis_heightdefault_rule_thicknessbig_op_spacingThe number of characters can be queried using
len(). TheTfmCharinstance for a character code char_code can be set or get using the operator [].
-
class
PyDvi.Font.Tfm.TfmChar(tfm, char_code, width, height, depth, italic_correction, lig_kern_program_index=None, next_larger_char=None)[source]¶ Bases:
objectThis class encapsulates a TeX Font Metric for a Glyph.
Public attributes:
char_codewidthheightdepthitalic_correction-
next_larger_tfm_char()[source]¶ Return the
TfmCharinstance for the next larger char if it exists else returnNone.
-
printable= '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'¶ List of the printable characters.
-
-
class
PyDvi.Font.Tfm.TfmExtensibleChar(tfm, char_code, width, height, depth, italic_correction, extensible_recipe, lig_kern_program_index=None, next_larger_char=None)[source]¶ Bases:
PyDvi.Font.Tfm.TfmCharThis class encapsulates a TeX Font Metric for an extensible Glyph.
Public attributes:
topmidbotrep
-
class
PyDvi.Font.Tfm.TfmKern(tfm, index, stop, next_char, kern)[source]¶ Bases:
PyDvi.Font.Tfm.TfmLigKernThis class represents a Kerning Program Instruction.
Public Attributes:
next_char- next character
kern- kerning value
-
class
PyDvi.Font.Tfm.TfmLigature(tfm, index, stop, next_char, ligature_char_code, number_of_chars_to_pass_over, current_char_is_deleted, next_char_is_deleted)[source]¶ Bases:
PyDvi.Font.Tfm.TfmLigKernThis class represents a Ligature Program Instruction.
Public Attributes:
next_char- next character
ligature_char_code- ligature character code
current_char_is_deleted- the current characters must be deleted of the stream
next_char_is_deleted- the next characters must be deleted of the stream
number_of_chars_to_pass_over- number of characters to pass over