3.1.3.8. PkGlyph

This module provides functions to handle Packed Font Glyphs.

class PyDvi.Font.PkGlyph.PkGlyph(pk_font, char_code, tfm, dm, dx, dy, height, width, horizontal_offset, vertical_offset, nybbles, dyn_f, first_pixel_is_black)[source]

Bases: object

This class contains the information stored in the Packed Font file for each glyph. For efficiency, the run count list is lazy decoded.

The glyph bitmap can be printed using the method print_glyph(). For example the output for the letter “A” of the font “cmr10” at 600 dpi is:

    0000000000111111111122222222223333333333444444444455555
    0123456789012345678901234567890123456789012345678901234
   +-------------------------------------------------------+
 0 |                          xxx                          |
 1 |                          xxx                          |
 2 |                          xxx                          |
 3 |                         xxxxx                         |
 4 |                         xxxxx                         |
 5 |                         xxxxx                         |
 6 |                        xxxxxxx                        |
 7 |                        xxxxxxx                        |
 8 |                        xxxxxxx                        |
 9 |                       xxxxxxxxx                       |
10 |                       xxxxxxxxx                       |
11 |                       xxxxxxxxx                       |
12 |                      xx xxxxxxxx                      |
13 |                      xx xxxxxxxx                      |
14 |                     xxx xxxxxxxxx                     |
15 |                     xx   xxxxxxxx                     |
16 |                     xx   xxxxxxxx                     |
17 |                    xxx   xxxxxxxxx                    |
18 |                    xx     xxxxxxxx                    |
19 |                    xx     xxxxxxxx                    |
20 |                   xxx     xxxxxxxxx                   |
21 |                   xx       xxxxxxxx                   |
22 |                   xx       xxxxxxxx                   |
23 |                  xxx       xxxxxxxxx                  |
24 |                  xx         xxxxxxxx                  |
25 |                  xx         xxxxxxxx                  |
26 |                 xxx         xxxxxxxxx                 |
27 |                 xx           xxxxxxxx                 |
28 |                 xx           xxxxxxxx                 |
29 |                xx            xxxxxxxxx                |
30 |                xx             xxxxxxxx                |
31 |                xx             xxxxxxxx                |
32 |               xx              xxxxxxxxx               |
33 |               xx               xxxxxxxx               |
34 |               xx               xxxxxxxx               |
35 |              xx                xxxxxxxxx              |
36 |              xx                 xxxxxxxx              |
37 |              xx                 xxxxxxxx              |
38 |             xx                  xxxxxxxxx             |
39 |             xxxxxxxxxxxxxxxxxxxxxxxxxxxxx             |
40 |             xxxxxxxxxxxxxxxxxxxxxxxxxxxxx             |
41 |            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx            |
42 |            xx                     xxxxxxxx            |
43 |            xx                     xxxxxxxx            |
44 |           xx                       xxxxxxxx           |
45 |           xx                       xxxxxxxx           |
46 |           xx                       xxxxxxxx           |
47 |          xx                         xxxxxxxx          |
48 |          xx                         xxxxxxxx          |
49 |          xx                         xxxxxxxx          |
50 |         xx                           xxxxxxxx         |
51 |         xx                           xxxxxxxx         |
52 |        xxx                           xxxxxxxx         |
53 |        xxx                            xxxxxxxx        |
54 |       xxxx                            xxxxxxxx        |
55 |      xxxxxx                           xxxxxxxxx       |
56 |    xxxxxxxxxx                       xxxxxxxxxxxx      |
57 |xxxxxxxxxxxxxxxxx               xxxxxxxxxxxxxxxxxxxxxxx|
58 |xxxxxxxxxxxxxxxxx               xxxxxxxxxxxxxxxxxxxxxxx|
59 |xxxxxxxxxxxxxxxxx               xxxxxxxxxxxxxxxxxxxxxxx|
   +-------------------------------------------------------+
    0000000000111111111122222222223333333333444444444455555
    0123456789012345678901234567890123456789012345678901234

Moreover the method count_list() return a run count list string equivalent at the output of the command pktype. For example the output for the previous glyph is:

(26)[2]3(51)[2]5(49)[2]7(47)[2]9(45)[1]2(1)8(43)3(1)9(42)[1]2(3)8(41)3(3)9 
(40)[1]2(5)8(39)3(5)9(38)[1]2(7)8(37)3(7)9(36)[1]2(9)8(35)3(9)9(34)[1]2(11)8 
(33)2(12)9(32)[1]2(13)8(31)2(14)9(30)[1]2(15)8(29)2(16)9(28)[1]2(17)8(27)2 
(18)9(26)[1]29(25)31(24)[1]2(21)8(23)[2]2(23)8(21)[2]2(25)8(19)[1]2(27)8(17) 
3(27)8(17)3(28)8(15)4(28)8(14)6(27)9(11)10(23)12(6)[2]17(15)23 
_decode_bitmap_glyph()[source]

Decode a bitmap glyph.

_decode_glyph()[source]

Decode the glyph.

_decode_packed_glyph()[source]

Decode a packed glyph.

_init_packed_number_decoder()[source]

Init the packed number decoder.

_next_nybble()[source]

Return the next nybble from the byte array.

_next_packed_number()[source]

Decode a packed number from the byte array.

count_list()[source]

Return the count list as pktype.

get_glyph_bitmap()[source]

Return the glyph bitmap as a Numpy array.

get_scaled_width(scale_factor)[source]

Return the width scaled by scale_factor.

is_bitmap()[source]

Return True is the glyph use the bitmap format.

print_glyph()[source]

Print the glyph.

print_summary()[source]

Previous topic

3.1.3.7. PkFontParser

Next topic

3.1.3.9. Tfm

This Page