Skip to content

Cache loaded fonts #484

@tybulewicz

Description

@tybulewicz

ImageFont.load_default(size=...) is invoked per BoundingBox instance, which can become expensive for many detections on large images. Consider caching fonts by font_size (e.g., a small module-level or class-level dict / functools.lru_cache) and reusing the same ImageFont object across instances with the same size.

Originally posted by @Copilot in #482 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions