Insert :class:`Kern` nodes between :class:`Char` nodes to set kerning. The :class:`Char` nodes themselves determine the amount of kerning they need (in :meth:`~Char.get_kerning`), and this function just creates the linked list in the correct way.
(self)
| 1602 | self.hpack() |
| 1603 | |
| 1604 | def kern(self): |
| 1605 | """ |
| 1606 | Insert :class:`Kern` nodes between :class:`Char` nodes to set |
| 1607 | kerning. The :class:`Char` nodes themselves determine the |
| 1608 | amount of kerning they need (in :meth:`~Char.get_kerning`), |
| 1609 | and this function just creates the linked list in the correct |
| 1610 | way. |
| 1611 | """ |
| 1612 | new_children = [] |
| 1613 | num_children = len(self.children) |
| 1614 | if num_children: |
| 1615 | for i in range(num_children): |
| 1616 | elem = self.children[i] |
| 1617 | if i < num_children - 1: |
| 1618 | next = self.children[i + 1] |
| 1619 | else: |
| 1620 | next = None |
| 1621 | |
| 1622 | new_children.append(elem) |
| 1623 | kerning_distance = elem.get_kerning(next) |
| 1624 | if kerning_distance != 0.: |
| 1625 | kern = Kern(kerning_distance) |
| 1626 | new_children.append(kern) |
| 1627 | self.children = new_children |
| 1628 | |
| 1629 | # This is a failed experiment to fake cross-font kerning. |
| 1630 | # def get_kerning(self, next): |
no test coverage detected