A glyph in the dvi file. In order to render the glyph, load the glyph at index ``text.index`` from the font at ``text.font.resolve_path()`` with size ``text.font.size``, warped with ``text.font.effects``, then draw it at position ``(text.x, text.y)``. ``text.glyph`` is the
| 67 | |
| 68 | # Also a namedtuple, for backcompat. |
| 69 | class Text(namedtuple('Text', 'x y font glyph width')): |
| 70 | """ |
| 71 | A glyph in the dvi file. |
| 72 | |
| 73 | In order to render the glyph, load the glyph at index ``text.index`` |
| 74 | from the font at ``text.font.resolve_path()`` with size ``text.font.size``, |
| 75 | warped with ``text.font.effects``, then draw it at position |
| 76 | ``(text.x, text.y)``. |
| 77 | |
| 78 | ``text.glyph`` is the glyph number actually stored in the dvi file (whose |
| 79 | interpretation depends on the font). ``text.width`` is the glyph width in |
| 80 | dvi units. |
| 81 | """ |
| 82 | |
| 83 | @property |
| 84 | def index(self): |
| 85 | """ |
| 86 | The FreeType index of this glyph (that can be passed to FT_Load_Glyph). |
| 87 | """ |
| 88 | # See DviFont._index_dvi_to_freetype for details on the index mapping. |
| 89 | return self.font._index_dvi_to_freetype(self.glyph) |
| 90 | |
| 91 | font_path = property(lambda self: self.font.resolve_path()) |
| 92 | font_size = property(lambda self: self.font.size) |
| 93 | font_effects = property(lambda self: self.font.effects) |
| 94 | |
| 95 | @property # To be deprecated together with font_path, font_size, font_effects. |
| 96 | def glyph_name_or_index(self): |
| 97 | """ |
| 98 | The glyph name, the native charmap glyph index, or the raw glyph index. |
| 99 | |
| 100 | If the font is a TrueType file (which can currently only happen for |
| 101 | DVI files generated by xetex or luatex), then this number is the raw |
| 102 | index of the glyph, which can be passed to FT_Load_Glyph/load_glyph. |
| 103 | |
| 104 | Otherwise, the font is a PostScript font. For such fonts, if |
| 105 | :file:`pdftex.map` specifies an encoding for this glyph's font, |
| 106 | that is a mapping of glyph indices to Adobe glyph names; which |
| 107 | is used by this property to convert dvi numbers to glyph names. |
| 108 | Callers can then convert glyph names to glyph indices (with |
| 109 | FT_Get_Name_Index/get_name_index), and load the glyph using |
| 110 | FT_Load_Glyph/load_glyph. |
| 111 | |
| 112 | If :file:`pdftex.map` specifies no encoding for a PostScript font, |
| 113 | this number is an index to the font's "native" charmap; glyphs should |
| 114 | directly load using FT_Load_Char/load_char after selecting the native |
| 115 | charmap. |
| 116 | """ |
| 117 | # The last section is only true on luatex since luaotfload 3.23; this |
| 118 | # must be checked by the code generated by texmanager. (luaotfload's |
| 119 | # docs states "No one should rely on the mapping between DVI character |
| 120 | # codes and font glyphs [prior to v3.15] unless they tightly |
| 121 | # control all involved versions and are deeply familiar with the |
| 122 | # implementation", but a further mapping bug was fixed in luaotfload |
| 123 | # commit 8f2dca4, first included in v3.23). |
| 124 | entry = PsfontsMap(find_tex_file("pdftex.map"))[self.font.texname] |
| 125 | return (_parse_enc(entry.encoding)[self.glyph] |
| 126 | if entry.encoding is not None else self.glyph) |
no test coverage detected
searching dependent graphs…