dviread.pyi 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. class _dvistate(Enum):
  8. pre: int
  9. outer: int
  10. inpage: int
  11. post_post: int
  12. finale: int
  13. class Page(NamedTuple):
  14. text: list[Text]
  15. boxes: list[Box]
  16. height: int
  17. width: int
  18. descent: int
  19. class Box(NamedTuple):
  20. x: int
  21. y: int
  22. height: int
  23. width: int
  24. class Text(NamedTuple):
  25. x: int
  26. y: int
  27. font: DviFont
  28. glyph: int
  29. width: int
  30. @property
  31. def font_path(self) -> Path: ...
  32. @property
  33. def font_size(self) -> float: ...
  34. @property
  35. def font_effects(self) -> dict[str, float]: ...
  36. @property
  37. def glyph_name_or_index(self) -> int | str: ...
  38. class Dvi:
  39. file: io.BufferedReader
  40. dpi: float | None
  41. fonts: dict[int, DviFont]
  42. state: _dvistate
  43. def __init__(self, filename: str | os.PathLike, dpi: float | None) -> None: ...
  44. # Replace return with Self when py3.9 is dropped
  45. def __enter__(self) -> Dvi: ...
  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. # Replace return with Self when py3.9 is dropped
  76. def __new__(cls, filename: str | os.PathLike) -> PsfontsMap: ...
  77. def __getitem__(self, texname: bytes) -> PsFont: ...
  78. def find_tex_file(filename: str | os.PathLike) -> str: ...