| 126 | if entry.encoding is not None else self.glyph) |
| 127 | |
| 128 | def _as_unicode_or_name(self): |
| 129 | if self.font.subfont: |
| 130 | raise NotImplementedError("Indexing TTC fonts is not supported yet") |
| 131 | path = self.font.resolve_path() |
| 132 | if path.name.lower().endswith("pk"): |
| 133 | # PK fonts have no encoding information; report glyphs as ASCII but |
| 134 | # with a "?" to indicate that this is just a guess. |
| 135 | return (f"{chr(self.glyph)}?" if chr(self.glyph).isprintable() else |
| 136 | f"pk{self.glyph:#02x}") |
| 137 | face = font_manager.get_font(path) |
| 138 | glyph_name = face.get_glyph_name(self.index) |
| 139 | glyph_str = fontTools.agl.toUnicode(glyph_name) |
| 140 | return glyph_str or glyph_name |
| 141 | |
| 142 | |
| 143 | # Opcode argument parsing |