ft2font.pyi 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. from typing import BinaryIO, Literal, TypedDict, overload
  2. import numpy as np
  3. from numpy.typing import NDArray
  4. __freetype_build_type__: str
  5. __freetype_version__: str
  6. BOLD: int
  7. EXTERNAL_STREAM: int
  8. FAST_GLYPHS: int
  9. FIXED_SIZES: int
  10. FIXED_WIDTH: int
  11. GLYPH_NAMES: int
  12. HORIZONTAL: int
  13. ITALIC: int
  14. KERNING: int
  15. KERNING_DEFAULT: int
  16. KERNING_UNFITTED: int
  17. KERNING_UNSCALED: int
  18. LOAD_CROP_BITMAP: int
  19. LOAD_DEFAULT: int
  20. LOAD_FORCE_AUTOHINT: int
  21. LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH: int
  22. LOAD_IGNORE_TRANSFORM: int
  23. LOAD_LINEAR_DESIGN: int
  24. LOAD_MONOCHROME: int
  25. LOAD_NO_AUTOHINT: int
  26. LOAD_NO_BITMAP: int
  27. LOAD_NO_HINTING: int
  28. LOAD_NO_RECURSE: int
  29. LOAD_NO_SCALE: int
  30. LOAD_PEDANTIC: int
  31. LOAD_RENDER: int
  32. LOAD_TARGET_LCD: int
  33. LOAD_TARGET_LCD_V: int
  34. LOAD_TARGET_LIGHT: int
  35. LOAD_TARGET_MONO: int
  36. LOAD_TARGET_NORMAL: int
  37. LOAD_VERTICAL_LAYOUT: int
  38. MULTIPLE_MASTERS: int
  39. SCALABLE: int
  40. SFNT: int
  41. VERTICAL: int
  42. class _SfntHeadDict(TypedDict):
  43. version: tuple[int, int]
  44. fontRevision: tuple[int, int]
  45. checkSumAdjustment: int
  46. magicNumber: int
  47. flags: int
  48. unitsPerEm: int
  49. created: tuple[int, int]
  50. modified: tuple[int, int]
  51. xMin: int
  52. yMin: int
  53. xMax: int
  54. yMax: int
  55. macStyle: int
  56. lowestRecPPEM: int
  57. fontDirectionHint: int
  58. indexToLocFormat: int
  59. glyphDataFormat: int
  60. class _SfntMaxpDict(TypedDict):
  61. version: tuple[int, int]
  62. numGlyphs: int
  63. maxPoints: int
  64. maxContours: int
  65. maxComponentPoints: int
  66. maxComponentContours: int
  67. maxZones: int
  68. maxTwilightPoints: int
  69. maxStorage: int
  70. maxFunctionDefs: int
  71. maxInstructionDefs: int
  72. maxStackElements: int
  73. maxSizeOfInstructions: int
  74. maxComponentElements: int
  75. maxComponentDepth: int
  76. class _SfntOs2Dict(TypedDict):
  77. version: int
  78. xAvgCharWidth: int
  79. usWeightClass: int
  80. usWidthClass: int
  81. fsType: int
  82. ySubscriptXSize: int
  83. ySubscriptYSize: int
  84. ySubscriptXOffset: int
  85. ySubscriptYOffset: int
  86. ySuperscriptXSize: int
  87. ySuperscriptYSize: int
  88. ySuperscriptXOffset: int
  89. ySuperscriptYOffset: int
  90. yStrikeoutSize: int
  91. yStrikeoutPosition: int
  92. sFamilyClass: int
  93. panose: bytes
  94. ulCharRange: tuple[int, int, int, int]
  95. achVendID: bytes
  96. fsSelection: int
  97. fsFirstCharIndex: int
  98. fsLastCharIndex: int
  99. class _SfntHheaDict(TypedDict):
  100. version: tuple[int, int]
  101. ascent: int
  102. descent: int
  103. lineGap: int
  104. advanceWidthMax: int
  105. minLeftBearing: int
  106. minRightBearing: int
  107. xMaxExtent: int
  108. caretSlopeRise: int
  109. caretSlopeRun: int
  110. caretOffset: int
  111. metricDataFormat: int
  112. numOfLongHorMetrics: int
  113. class _SfntVheaDict(TypedDict):
  114. version: tuple[int, int]
  115. vertTypoAscender: int
  116. vertTypoDescender: int
  117. vertTypoLineGap: int
  118. advanceHeightMax: int
  119. minTopSideBearing: int
  120. minBottomSizeBearing: int
  121. yMaxExtent: int
  122. caretSlopeRise: int
  123. caretSlopeRun: int
  124. caretOffset: int
  125. metricDataFormat: int
  126. numOfLongVerMetrics: int
  127. class _SfntPostDict(TypedDict):
  128. format: tuple[int, int]
  129. italicAngle: tuple[int, int]
  130. underlinePosition: int
  131. underlineThickness: int
  132. isFixedPitch: int
  133. minMemType42: int
  134. maxMemType42: int
  135. minMemType1: int
  136. maxMemType1: int
  137. class _SfntPcltDict(TypedDict):
  138. version: tuple[int, int]
  139. fontNumber: int
  140. pitch: int
  141. xHeight: int
  142. style: int
  143. typeFamily: int
  144. capHeight: int
  145. symbolSet: int
  146. typeFace: bytes
  147. characterComplement: bytes
  148. strokeWeight: int
  149. widthType: int
  150. serifStyle: int
  151. class FT2Font:
  152. ascender: int
  153. bbox: tuple[int, int, int, int]
  154. descender: int
  155. face_flags: int
  156. family_name: str
  157. fname: str
  158. height: int
  159. max_advance_height: int
  160. max_advance_width: int
  161. num_charmaps: int
  162. num_faces: int
  163. num_fixed_sizes: int
  164. num_glyphs: int
  165. postscript_name: str
  166. scalable: bool
  167. style_flags: int
  168. style_name: str
  169. underline_position: int
  170. underline_thickness: int
  171. units_per_EM: int
  172. def __init__(
  173. self,
  174. filename: str | BinaryIO,
  175. hinting_factor: int = ...,
  176. *,
  177. _fallback_list: list[FT2Font] | None = ...,
  178. _kerning_factor: int = ...
  179. ) -> None: ...
  180. def _get_fontmap(self, string: str) -> dict[str, FT2Font]: ...
  181. def clear(self) -> None: ...
  182. def draw_glyph_to_bitmap(
  183. self, image: FT2Image, x: float, y: float, glyph: Glyph, antialiased: bool = ...
  184. ) -> None: ...
  185. def draw_glyphs_to_bitmap(self, antialiased: bool = ...) -> None: ...
  186. def get_bitmap_offset(self) -> tuple[int, int]: ...
  187. def get_char_index(self, codepoint: int) -> int: ...
  188. def get_charmap(self) -> dict[int, int]: ...
  189. def get_descent(self) -> int: ...
  190. def get_glyph_name(self, index: int) -> str: ...
  191. def get_image(self) -> NDArray[np.uint8]: ...
  192. def get_kerning(self, left: int, right: int, mode: int) -> int: ...
  193. def get_name_index(self, name: str) -> int: ...
  194. def get_num_glyphs(self) -> int: ...
  195. def get_path(self) -> tuple[NDArray[np.float64], NDArray[np.int8]]: ...
  196. def get_ps_font_info(
  197. self,
  198. ) -> tuple[str, str, str, str, str, int, int, int, int]: ...
  199. def get_sfnt(self) -> dict[tuple[int, int, int, int], bytes]: ...
  200. @overload
  201. def get_sfnt_table(self, name: Literal["head"]) -> _SfntHeadDict | None: ...
  202. @overload
  203. def get_sfnt_table(self, name: Literal["maxp"]) -> _SfntMaxpDict | None: ...
  204. @overload
  205. def get_sfnt_table(self, name: Literal["OS/2"]) -> _SfntOs2Dict | None: ...
  206. @overload
  207. def get_sfnt_table(self, name: Literal["hhea"]) -> _SfntHheaDict | None: ...
  208. @overload
  209. def get_sfnt_table(self, name: Literal["vhea"]) -> _SfntVheaDict | None: ...
  210. @overload
  211. def get_sfnt_table(self, name: Literal["post"]) -> _SfntPostDict | None: ...
  212. @overload
  213. def get_sfnt_table(self, name: Literal["pclt"]) -> _SfntPcltDict | None: ...
  214. def get_width_height(self) -> tuple[int, int]: ...
  215. def get_xys(self, antialiased: bool = ...) -> NDArray[np.float64]: ...
  216. def load_char(self, charcode: int, flags: int = ...) -> Glyph: ...
  217. def load_glyph(self, glyphindex: int, flags: int = ...) -> Glyph: ...
  218. def select_charmap(self, i: int) -> None: ...
  219. def set_charmap(self, i: int) -> None: ...
  220. def set_size(self, ptsize: float, dpi: float) -> None: ...
  221. def set_text(
  222. self, string: str, angle: float = ..., flags: int = ...
  223. ) -> NDArray[np.float64]: ...
  224. class FT2Image: # TODO: When updating mypy>=1.4, subclass from Buffer.
  225. def __init__(self, width: float, height: float) -> None: ...
  226. def draw_rect(self, x0: float, y0: float, x1: float, y1: float) -> None: ...
  227. def draw_rect_filled(self, x0: float, y0: float, x1: float, y1: float) -> None: ...
  228. class Glyph:
  229. width: int
  230. height: int
  231. horiBearingX: int
  232. horiBearingY: int
  233. horiAdvance: int
  234. linearHoriAdvance: int
  235. vertBearingX: int
  236. vertBearingY: int
  237. vertAdvance: int
  238. @property
  239. def bbox(self) -> tuple[int, int, int, int]: ...