The font metrics need to be dealt with differently for accents, since they are already offset correctly from the baseline in TrueType fonts.
| 1501 | self.depth *= GROW_FACTOR |
| 1502 | |
| 1503 | class Accent(Char): |
| 1504 | """ |
| 1505 | The font metrics need to be dealt with differently for accents, |
| 1506 | since they are already offset correctly from the baseline in |
| 1507 | TrueType fonts. |
| 1508 | """ |
| 1509 | def _update_metrics(self): |
| 1510 | metrics = self._metrics = self.font_output.get_metrics( |
| 1511 | self.font, self.font_class, self.c, self.fontsize, self.dpi) |
| 1512 | self.width = metrics.xmax - metrics.xmin |
| 1513 | self.height = metrics.ymax - metrics.ymin |
| 1514 | self.depth = 0 |
| 1515 | |
| 1516 | def shrink(self): |
| 1517 | Char.shrink(self) |
| 1518 | self._update_metrics() |
| 1519 | |
| 1520 | def grow(self): |
| 1521 | Char.grow(self) |
| 1522 | self._update_metrics() |
| 1523 | |
| 1524 | def render(self, x, y): |
| 1525 | """ |
| 1526 | Render the character to the canvas. |
| 1527 | """ |
| 1528 | self.font_output.render_glyph( |
| 1529 | x - self._metrics.xmin, y + self._metrics.ymin, |
| 1530 | self.font, self.font_class, self.c, self.fontsize, self.dpi) |
| 1531 | |
| 1532 | class List(Box): |
| 1533 | """ |