def dynamic_font_size(image_size: tuple[int, int], min_size: int = 20, max_size: int = 100, divisor: int = 10) -> int:
    """Calculate a dynamic font size based on image dimensions.

    This function determines an appropriate font size based on the image dimensions while
    staying within specified bounds. The font size is calculated by dividing the smaller
    image dimension by the divisor.

    Args:
        image_size (tuple[int, int]): Tuple of image dimensions ``(width, height)``.
        min_size (int, optional): Minimum allowed font size. Defaults to ``20``.
        max_size (int, optional): Maximum allowed font size. Defaults to ``100``.
        divisor (int, optional): Value to divide the minimum image dimension by.
            Defaults to ``10``.

    Returns:
        int: Calculated font size constrained between ``min_size`` and ``max_size``.

    Examples:
        Calculate font size for a small image:

        >>> dynamic_font_size((200, 100))
        20

        Calculate font size for a large image:

        >>> dynamic_font_size((1000, 800))
        80

        Font size is capped at max_size:

        >>> dynamic_font_size((2000, 2000), max_size=50)
        50

    Note:
        - The function uses the smaller dimension to ensure text fits in both directions
        - The calculated size is clamped between ``min_size`` and ``max_size``
        - Larger ``divisor`` values result in smaller font sizes
    """
    min_dimension = min(image_size)
    return max(min_size, min(max_size, min_dimension // divisor))
Calculate a dynamic font size based on image dimensions.

    This function determines an appropriate font size based on the image dimensions while
    staying within specified bounds. The font size is calculated by dividing the smaller
    image dimension by the divisor.

    Args:
        image_size (tuple[int, int]): Tuple of image dimensions ``(width, height)``.
        min_size (int, optional): Minimum allowed font size. Defaults to ``20``.
        max_size (int, optional): Maximum allowed font size. Defaults to ``100``.
        divisor (int, optional): Value to divide the minimum image dimension by.
            Defaults to ``10``.

    Returns:
        int: Calculated font size constrained between ``min_size`` and ``max_size``.

    Examples:
        Calculate font size for a small image:

        >>> dynamic_font_size((200, 100))
        20

        Calculate font size for a large image:

        >>> dynamic_font_size((1000, 800))
        80

        Font size is capped at max_size:

        >>> dynamic_font_size((2000, 2000), max_size=50)
        50

    Note:
        - The function uses the smaller dimension to ensure text fits in both directions
        - The calculated size is clamped between ``min_size`` and ``max_size``
        - Larger ``divisor`` values result in smaller font sizes
    
src/anomalib/visualization/image/functional.py