psf2flf

psf2flf.utils

def print_dict(data: dict, prefix: str = "")

Recursively prints the key-value pairs of a dictionary.

psf2flf.reader

read

def read(path: Path)

Reads a font from the given path using the appropriate reader.

psf2flf.reader.reader

Reader Objects

class Reader(ABC)

Base class for font readers.

can_open

@staticmethod
@abstractmethod
def can_open(path: Path) -> bool

Returns True if the reader can open the given file path.

read

@abstractmethod
def read(path: Path) -> Font

Reads the font from the given path and returns a Font object.

psf2flf.reader.psf

psf2flf.__main__

psf2flf.writer

write

def write(font: Font, path: Path, tall_mode: bool = False)

Writes a font to the given path using the appropriate writer.

psf2flf.writer.flf

psf2flf.writer.writer

Writer Objects

class Writer(ABC)

Base class for font writers.

can_write

@staticmethod
@abstractmethod
def can_write(path: Path) -> bool

Returns True if the writer can write to the given file path.

write

@abstractmethod
def write(font: Font, path: Path)

Writes the font to the given path.

psf2flf.font

psf2flf.font.fontdir

FontDir Objects

@dataclass
class FontDir()

A collection of typefaces, typically representing a font directory or archive.

__iadd__

def __iadd__(other: Union[Font, TypeFace])

Add a font or typeface to this directory.

write_directory

def write_directory(output_dir: Path, tall_mode: bool = False)

Write all typefaces to a directory structure.

write_tar

def write_tar(output_path: Path, tall_mode: bool = False)

Write all typefaces to a tar archive.

psf2flf.font.font

Font Objects

@dataclass
class Font()

A generic representation of a font.

name

@property
def name() -> str

Get the font name from metadata.

style

@property
def style() -> frozenset[str]

Get the font style from metadata.

width

@property
def width() -> int

Get the font width from metadata.

height

@property
def height() -> int

Get the font height from metadata.

__eq__

def __eq__(other) -> bool

Two fonts are equal if name, style, width, height match and overlapping ASCII glyphs are identical.

__iadd__

def __iadd__(other)

Merge another font into this one if they are compatible.

force_merge

def force_merge(other)

Force merge another font, ignoring compatibility checks.

psf2flf.font.typeface

TypeFace Objects

@dataclass
class TypeFace()

Represents a collection of related fonts (e.g., by family, style, and size).

__iadd__

def __iadd__(font: Font)

Add a font to this typeface.

psf2flf.main

show_info

def show_info(source: Path)

Show information about a single font file.

is_directory_output

def is_directory_output(path: Path) -> bool

Check if the output path indicates a directory.

convert_multiple

def convert_multiple(inputs: list[Path],
                     output: Path,
                     tall_mode: bool = False,
                     force: bool = False)

Convert multiple input files to single output (font or directory).

convert_all_in_directory

def convert_all_in_directory(source_dir: Path,
                             dest_dir: Path,
                             tall_mode: bool = False)

Convert all PSF fonts in a directory (legacy –all mode).