Most of the information in this object is stored in the underlying ``_GlueSpec`` class, which is shared between multiple glue objects. (This is a memory optimization which probably doesn't matter anymore, but it's easier to stick to what TeX does.)
| 1565 | |
| 1566 | |
| 1567 | class Glue(Node): |
| 1568 | """ |
| 1569 | Most of the information in this object is stored in the underlying |
| 1570 | ``_GlueSpec`` class, which is shared between multiple glue objects. |
| 1571 | (This is a memory optimization which probably doesn't matter anymore, but |
| 1572 | it's easier to stick to what TeX does.) |
| 1573 | """ |
| 1574 | |
| 1575 | def __init__(self, |
| 1576 | glue_type: _GlueSpec | T.Literal["fil", "fill", "filll", |
| 1577 | "neg_fil", "neg_fill", "neg_filll", |
| 1578 | "empty", "ss"]): |
| 1579 | super().__init__() |
| 1580 | if isinstance(glue_type, str): |
| 1581 | glue_spec = _GlueSpec._named[glue_type] # type: ignore[attr-defined] |
| 1582 | elif isinstance(glue_type, _GlueSpec): |
| 1583 | glue_spec = glue_type |
| 1584 | else: |
| 1585 | raise ValueError("glue_type must be a glue spec name or instance") |
| 1586 | self.glue_spec = glue_spec |
| 1587 | |
| 1588 | def shrink(self) -> None: |
| 1589 | super().shrink() |
| 1590 | if self.size < NUM_SIZE_LEVELS: |
| 1591 | g = self.glue_spec |
| 1592 | self.glue_spec = g._replace(width=g.width * SHRINK_FACTOR) |
| 1593 | |
| 1594 | |
| 1595 | class HCentered(Hlist): |