Skip to content

TextBox texted shifted up with Python 3.14/pygame-ce #94

Description

@marcstober

Describe the bug
When using Python 3.14, and therefore using pygame-ce (since the original pygame doesn't support 3.14), text in a textbox is shifted up vertically, at least when using the default font in Windows 11. It's better with other fonts (at least with Arial). But it also isn't an issue at all in Python 3.13, using the original Pygame, even with the default font.

To Reproduce
Run this example:

import pygame
import pygame_widgets
import sys
from pygame_widgets.textbox import TextBox

pygame.init()

win = pygame.display.set_mode((600, 300))
pygame.display.set_caption(f"Python {sys.version.split()[0]}")

tb1 = TextBox(win, 100, 50, 400, 75)
tb1.setText("This is the default font in Windows 11.")

font = pygame.font.SysFont("Arial", 20)
tb2 = TextBox(win, 100, 150, 400, 75, font=font)
tb2.setText("This is Arial.")


running = True
while running:  # event loop
    events = pygame.event.get()
    for event in events:
        if event.type == pygame.QUIT:
            running = False

    pygame_widgets.update(events)
    pygame.display.flip()

Expected behaviour
To be able to have pygame-widgets work with the latest version of Python (3.14) the same way it worked with the previous version.

Screenshots
Bug (note the position of the text relative to the insertion point!):
Image
Python 3.13--works as expected:
Image
Works better with Arial even in 3.14:
Image

Version Numbers

  • pygame-widgets 1.3.2
  • pygame-ce 2.5.7 (or pygame 2.6.1 with Python 3.13)
  • Python 3.14 (or Python 3.13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions