dviread.pyi 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. from pathlib import Path
  2. import io
  3. import os
  4. from enum import Enum
  5. from collections.abc import Generator
  6. from typing import NamedTuple
  7. from typing_extensions import Self # < Py 3.11
  8. class _dvistate(Enum):
  9. pre = ...
  10. outer = ...
  11. inpage = ...
  12. post_post = ...
  13. finale = ...
  14. class Page(NamedTuple):
  15. text: list[Text]
  16. boxes: list[Box]
  17. height: int
  18. width: int
  19. descent: int
  20. class Box(NamedTuple):
  21. x: int
  22. y: int
  23. height: int
  24. width: int
  25. class Text(NamedTuple):
  26. x: int
  27. y: int
  28. font: DviFont
  29. glyph: int
  30. width: int
  31. @property
  32. def font_path(self) -> Path: ...
  33. @property
  34. def font_size(self) -> float: ...
  35. @property
  36. def font_effects(self) -> dict[str, float]: ...
  37. @property
  38. def glyph_name_or_index(self) -> int | str: ...
  39. class Dvi:
  40. file: io.BufferedReader
  41. dpi: float | None
  42. fonts: dict[int, DviFont]
  43. state: _dvistate
  44. def __init__(self, filename: str | os.PathLike, dpi: float | None) -> None: ...
  45. def __enter__(self) -> Self: ...
  46. def __exit__(self, etype, evalue, etrace) -> None: ...
  47. def __iter__(self) -> Generator[Page, None, None]: ...
  48. def close(self) -> None: ...
  49. class DviFont:
  50. texname: bytes
  51. size: float
  52. widths: list[int]
  53. def __init__(
  54. self, scale: float, tfm: Tfm, texname: bytes, vf: Vf | None
  55. ) -> None: ...
  56. def __eq__(self, other: object) -> bool: ...
  57. def __ne__(self, other: object) -> bool: ...
  58. class Vf(Dvi):
  59. def __init__(self, filename: str | os.PathLike) -> None: ...
  60. def __getitem__(self, code: int) -> Page: ...
  61. class Tfm:
  62. checksum: int
  63. design_size: int
  64. width: dict[int, int]
  65. height: dict[int, int]
  66. depth: dict[int, int]
  67. def __init__(self, filename: str | os.PathLike) -> None: ...
  68. class PsFont(NamedTuple):
  69. texname: bytes
  70. psname: bytes
  71. effects: dict[str, float]
  72. encoding: None | bytes
  73. filename: str
  74. class PsfontsMap:
  75. def __new__(cls, filename: str | os.PathLike) -> Self: ...
  76. def __getitem__(self, texname: bytes) -> PsFont: ...
  77. def find_tex_file(filename: str | os.PathLike) -> str: ...