oin/typings/bdfparser/bdfparser.pyi

346 lines
10 KiB
Python
Raw Normal View History

2024-12-09 13:25:00 +01:00
"""
This type stub file was generated by pyright.
"""
from typing import Any
def format_warning(message, category, filename, lineno, file=..., line=...): ...
class Font:
"""
`Font` object
https://font.tomchen.org/bdfparser_py/font
"""
__PATTERN_VVECTOR_DELIMITER = ...
__META_TITLES = ...
__EMPTY_GLYPH = ...
def __init__(self, *argv) -> None:
"""
Initialize a `Font` object. Load the BDF font file if a file path string or a file object is present.
https://font.tomchen.org/bdfparser_py/font#font
"""
...
def load_file_path(self, file_path): # -> Self:
"""
Load the BDF font file in the file path.
https://font.tomchen.org/bdfparser_py/font#load_file_path
"""
...
def load_file_obj(self, file_obj): # -> Self:
"""
Load the BDF font file object.
https://font.tomchen.org/bdfparser_py/font#load_file_obj
"""
...
def length(self): # -> int:
"""
Returns how many glyphs actually exist in the font.
https://font.tomchen.org/bdfparser_py/font#length
"""
...
def __len__(self): # -> int:
"""
Same as `.length()`
"""
...
def itercps(self, order=..., r=...): # -> filter[Any] | Iterator[Any]:
"""
Almost identical to `.iterglyphs()`, except it returns an `iterator` of glyph codepoints instead of an `iterator` of `Glyph` objects.
https://font.tomchen.org/bdfparser_py/font#itercps
"""
...
def iterglyphs(self, order=..., r=...): # -> Generator[Glyph | None, Any, None]:
"""
Returns an iterator of all the glyphs (as `Glyph` objects) in the font (default) or in the specified codepoint range in the font, sorted by the specified order (or by the ascending codepoint order by default).
https://font.tomchen.org/bdfparser_py/font#iterglyphs
"""
...
def glyphbycp(self, codepoint): # -> Glyph | None:
"""
Get a glyph (as Glyph object) by its codepoint.
https://font.tomchen.org/bdfparser_py/font#glyphbycp
"""
...
def glyph(self, character): # -> Glyph | None:
"""
Get a glyph (as `Glyph` object) by its character.
https://font.tomchen.org/bdfparser_py/font#glyph
"""
...
def lacksglyphs(self, string): # -> list[Any] | None:
"""
Check if there is any missing glyph and gets these glyphs' character.
https://font.tomchen.org/bdfparser_py/font#lacksglyphs
"""
...
def drawcps(
self,
cps,
linelimit=...,
mode=...,
direction=...,
usecurrentglyphspacing=...,
missing=...,
):
"""
Draw the glyphs of the specified codepoints, to a `Bitmap` object.
https://font.tomchen.org/bdfparser_py/font#drawcps
"""
...
def draw(
self,
string: str,
linelimit: int = ...,
mode: int = ...,
direction: str = ...,
usecurrentglyphspacing: bool = ...,
missing: dict[str, Any] | Glyph = ...,
) -> Bitmap:
"""
Draw (render) the glyphs of the specified words / setences / paragraphs (as a `str`), to a `Bitmap` object.
https://font.tomchen.org/bdfparser_py/font#draw
"""
...
def drawall(
self,
order=...,
r=...,
linelimit=...,
mode=...,
direction=...,
usecurrentglyphspacing=...,
):
"""
Draw all the glyphs in the font (default) or in the specified codepoint range in the font, sorted by the specified order (or by the ascending codepoint order by default), to a `Bitmap` object.
https://font.tomchen.org/bdfparser_py/font#drawall
"""
...
class Glyph:
"""
`Glyph` object
https://font.tomchen.org/bdfparser_py/glyph
"""
def __init__(self, meta_dict, font) -> None:
"""
Initialize a `Glyph` object. Load a `dict` of meta information and the font the glyph belongs.
https://font.tomchen.org/bdfparser_py/glyph#glyph
"""
...
def __str__(self) -> str:
"""
Gets a human-readable (multi-line) `str` representation of the `Glyph` object.
https://font.tomchen.org/bdfparser_py/glyph#str-and-print
"""
...
def __repr__(self): # -> str:
"""
Gets a programmer-readable `str` representation of the `Glyph` object.
https://font.tomchen.org/bdfparser_py/glyph#repr
"""
...
def cp(self):
"""
Get the codepoint of the glyph.
https://font.tomchen.org/bdfparser_py/glyph#cp
"""
...
def chr(self): # -> str:
"""
Get the character of the glyph.
https://font.tomchen.org/bdfparser_py/glyph#chr
"""
...
def draw(self, mode=..., bb=...): # -> Bitmap:
"""
Draw the glyph to a `Bitmap` object.
https://font.tomchen.org/bdfparser_py/glyph#draw
"""
...
def origin(
self, mode=..., fromorigin=..., xoff=..., yoff=...
): # -> tuple[Any, Any]:
"""
Get the relative position (displacement) of the origin from the left bottom corner of the bitmap drawn by the method `.draw()`, or vice versa.
https://font.tomchen.org/bdfparser_py/glyph#origin
"""
...
class Bitmap:
"""
`Bitmap` object
https://font.tomchen.org/bdfparser_py/bitmap
"""
def __init__(self, bin_bitmap_list) -> None:
"""
Initialize a `Bitmap` object. Load binary bitmap data (`list` of `str`s).
https://font.tomchen.org/bdfparser_py/bitmap#bitmap
"""
...
def __str__(self) -> str:
"""
Gets a human-readable (multi-line) `str` representation of the `Bitmap` object.
https://font.tomchen.org/bdfparser_py/bitmap#str-and-print
"""
...
def __repr__(self): # -> str:
"""
Gets a programmer-readable (multi-line) `str` representation of the `Bitmap` object.
https://font.tomchen.org/bdfparser_py/bitmap#repr
"""
...
def width(self): # -> int:
"""
Get the width of the bitmap.
https://font.tomchen.org/bdfparser_py/bitmap#width
"""
...
def height(self): # -> int:
"""
Get the height of the bitmap.
https://font.tomchen.org/bdfparser_py/bitmap#height
"""
...
def clone(self): # -> Self:
"""
Get a deep copy / clone of the `Bitmap` object.
https://font.tomchen.org/bdfparser_py/bitmap#clone
"""
...
def crop(
self, w: int, h: int, xoff: int = ..., yoff: int = ...
) -> Bitmap: # -> Self:
"""
Crop and/or extend the bitmap.
https://font.tomchen.org/bdfparser_py/bitmap#crop
"""
...
def overlay(self, bitmap): # -> Self:
"""
Overlay another bitmap over the current one.
https://font.tomchen.org/bdfparser_py/bitmap#overlay
"""
...
@classmethod
def concatall(
cls, bitmaplist, direction=..., align=..., offsetlist=...
): # -> Self:
"""
Concatenate all `Bitmap` objects in a `list`.
https://font.tomchen.org/bdfparser_py/bitmap#bitmapconcatall
"""
...
def __add__(self, bitmap): # -> Self:
"""
`+` is a shortcut of `Bitmap.concatall()`. Use `+` to concatenate two `Bitmap` objects and get a new `Bitmap` objects.
https://font.tomchen.org/bdfparser_py/bitmap#-concat
"""
...
def concat(self, bitmap, direction=..., align=..., offset=...): # -> Self:
"""
Concatenate another `Bitmap` objects to the current one.
https://font.tomchen.org/bdfparser_py/bitmap#concat
"""
...
def enlarge(self, x=..., y=...): # -> Self:
"""
Enlarge a `Bitmap` object, by multiplying every pixel in x (right) direction and in y (top) direction.
https://font.tomchen.org/bdfparser_py/bitmap#enlarge
"""
...
def __mul__(self, mul): # -> Self:
"""
`*` is a shortcut of `.enlarge()`.
https://font.tomchen.org/bdfparser_py/bitmap#-enlarge
"""
...
def replace(self, substr, newsubstr): # -> Self:
"""
Replace a string by another in the bitmap.
https://font.tomchen.org/bdfparser_py/bitmap#replace
"""
...
def shadow(self, xoff=..., yoff=...): # -> Self:
"""
Add shadow to the shape in the bitmap.
The shadow will be filled by `'2'`s.
https://font.tomchen.org/bdfparser_py/bitmap#shadow
"""
...
def glow(self, mode=...): # -> Self:
"""
Add glow effect to the shape in the bitmap.
The glowing area is one pixel up, right, bottom and left to the original pixels (corners will not be filled in default mode 0 but will in mode 1), and will be filled by `'2'`s.
https://font.tomchen.org/bdfparser_py/bitmap#glow
"""
...
def bytepad(self, bits=...): # -> Self:
"""
Pad each line (row) to multiple of 8 (or other numbers) bits/pixels, with `'0'`s.
Do this before using the bitmap for a glyph in a BDF font.
https://font.tomchen.org/bdfparser_py/bitmap#bytepad
"""
...
def todata(
self, datatype: int = ...
) -> (
Any
): # -> LiteralString | Any | list[list[int]] | list[int] | list[str] | None:
"""
Get the bitmap's data in the specified type and format.
https://font.tomchen.org/bdfparser_py/bitmap#todata
"""
...
def tobytes(self, mode=..., bytesdict=...): # -> bytes:
"""
Get the bitmap's data as `bytes` to be used with Pillow library's `Image.frombytes(mode, size, data)`.
https://font.tomchen.org/bdfparser_py/bitmap#tobytes
"""
...