From 316c25303d4b066dd4f9aba7334d394918780b8f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 21 Dec 2021 15:33:59 -0600 Subject: [PATCH] Provide a protocol for `Font`s --- shared-bindings/fontio/BuiltinFont.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/shared-bindings/fontio/BuiltinFont.c b/shared-bindings/fontio/BuiltinFont.c index 171a50dab39b..fcbde4e80dd6 100644 --- a/shared-bindings/fontio/BuiltinFont.c +++ b/shared-bindings/fontio/BuiltinFont.c @@ -36,6 +36,25 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" +//| from typing_extensions import Protocol # for compat with python < 3.8 +//| +//| class FontProtocol(Protocol): +//| """A protocol shared by `BuiltinFont` and classes in ``adafruit_bitmap_font``""" +//| def get_bounding_box(self) -> Union[Tuple[int, int], Tuple[int, int, int, int]]: +//| """Retrieve the maximum bounding box of any glyph in the font. +//| +//| The four element version is ``(width, height, x_offset, y_offset)``. +//| The two element version is ``(width, height)``, in which +//| ``x_offset`` and ``y_offset`` are assumed to be zero.""" +//| pass +//| +//| def get_glyph(self, codepoint: int) -> Optional[Glyph]: +//| """Retrieve the Glyph for a given code point +//| +//| If the code point is not present in the font, `None` is returned.""" +//| pass +//| + //| class BuiltinFont: //| """A font built into CircuitPython""" //|