Skip to content

Text int typing for positions to float #2221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions arcade/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def _attempt_font_name_resolution(font_name: FontNameOrNames) -> FontNameOrNames
:return: Either a resolved path or the original tuple
"""
if font_name:

# ensure
if isinstance(font_name, str):
font_list: tuple[str, ...] = (font_name,)
Expand Down Expand Up @@ -174,8 +173,8 @@ class Text:
def __init__(
self,
text: str,
x: int,
y: int,
x: float,
y: float,
color: RGBOrA255 = arcade.color.WHITE,
font_size: float = 12,
width: Optional[int] = 0,
Expand All @@ -189,7 +188,7 @@ def __init__(
rotation: float = 0,
batch: Optional[pyglet.graphics.Batch] = None,
group: Optional[pyglet.graphics.Group] = None,
z: int = 0,
z: float = 0,
):
# Raises a RuntimeError if no window for better user feedback
arcade.get_window()
Expand All @@ -203,9 +202,10 @@ def __init__(
adjusted_font = _attempt_font_name_resolution(font_name)
self._label = pyglet.text.Label(
text=text,
x=x,
y=y,
z=z,
# pyglet is lying about what it takes here and float is entirely valid
x=x, # type: ignore
y=y, # type: ignore
z=z, # type: ignore
font_name=adjusted_font,
font_size=font_size,
# use type: ignore since cast is slow & pyglet used Literal
Expand Down
Loading