Skip to content

Commit 9ef8bce

Browse files
authored
Merge pull request #5759 from jepler/font-protocol
Add a font protocol
2 parents ea638c0 + 75857ce commit 9ef8bce

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

requirements-doc.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ twine
66
wheel
77
astroid
88
setuptools
9+
setuptools_scm
910

1011
# For sphinx
1112
sphinx>=4.0.0

shared-bindings/fontio/BuiltinFont.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@
3636
#include "shared-bindings/util.h"
3737
#include "supervisor/shared/translate.h"
3838

39+
//| from typing_extensions import Protocol # for compat with python < 3.8
40+
//|
41+
//| class FontProtocol(Protocol):
42+
//| """A protocol shared by `BuiltinFont` and classes in ``adafruit_bitmap_font``"""
43+
//| def get_bounding_box(self) -> Union[Tuple[int, int], Tuple[int, int, int, int]]:
44+
//| """Retrieve the maximum bounding box of any glyph in the font.
45+
//|
46+
//| The four element version is ``(width, height, x_offset, y_offset)``.
47+
//| The two element version is ``(width, height)``, in which
48+
//| ``x_offset`` and ``y_offset`` are assumed to be zero."""
49+
//| pass
50+
//|
51+
//| def get_glyph(self, codepoint: int) -> Optional[Glyph]:
52+
//| """Retrieve the Glyph for a given code point
53+
//|
54+
//| If the code point is not present in the font, `None` is returned."""
55+
//| pass
56+
//|
57+
3958
//| class BuiltinFont:
4059
//| """A font built into CircuitPython"""
4160
//|

0 commit comments

Comments
 (0)