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:
object
This 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
slant
spacing
space_stretch
space_shrink
x_height
quad
extra_space
In addition for Math font, the following public attributes are available:
um1
num2
num3
denom1
denom2
sup1
sup2
sup3
sub1
sub2
supdrop
subdrop
delim1
delim2
axis_height
default_rule_thickness
big_op_spacing
The number of characters can be queried using
len()
. TheTfmChar
instance 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:
object
This class encapsulates a TeX Font Metric for a Glyph.
Public attributes:
char_code
width
height
depth
italic_correction
-
next_larger_tfm_char
()[source]¶ Return the
TfmChar
instance 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.TfmChar
This class encapsulates a TeX Font Metric for an extensible Glyph.
Public attributes:
top
mid
bot
rep
-
class
PyDvi.Font.Tfm.
TfmKern
(tfm, index, stop, next_char, kern)[source]¶ Bases:
PyDvi.Font.Tfm.TfmLigKern
This 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.TfmLigKern
This 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