pygame-ce
pygame-ce copied to clipboard
add Font.render_to
Thanks to starbuck, matt and other people who helped me
Using this test code:
import pygame
pygame.init()
screen = pygame.display.set_mode((500, 500))
surf = pygame.Surface((50, 50), pygame.SRCALPHA)
surf.fill("red")
font = pygame.font.Font()
font.render_to(surf, (0, 0), "Hello World!", True, "blue")
screen.blit(surf, (100, 100))
pygame.display.flip()
input()
I got this result:
The method should also accept keyword arguments.
And this needs tests too.
Closing the pr as I'm not going to work on it
test code:
import pygame
pygame.font.init()
screen = pygame.display.set_mode((512, 512))
font = pygame.font.SysFont("Arial", 20)
bigfont = pygame.font.SysFont("Arial", 32)
clock = pygame.time.Clock()
while True:
screen.fill("black")
for e in pygame.event.get():
if e.type == pygame.QUIT:
raise SystemExit
dt = clock.tick(60)
rect = font.render_to(screen, pygame.mouse.get_pos(), f"{dt}", True, "red")
pygame.draw.rect(screen, "white", rect, 1)
rect = font.render_to(screen, [100,100], f"test", True, "red")
pygame.draw.rect(screen, "white", rect, 1)
rect = bigfont.render_to(screen, (250, 125), f"Wow big text", True, "red")
pygame.draw.rect(screen, "white", rect, 1)
pygame.display.update()
Installing collected packages: urllib3, pytz, MarkupSafe, idna, charset-normalizer, certifi, sphinxcontrib-serializinghtml, sphinxcontrib-qthelp, sphinxcontrib-jsmath, sphinxcontrib-htmlhelp, sphinxcontrib-devhelp, sphinxcontrib-applehelp, snowballstemmer, requests, Pygments, Jinja2, imagesize, docutils, babel, alabaster, Sphinx
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Successfully installed Jinja2-3.0.3 MarkupSafe-2.0.1 Pygments-2.14.0 Sphinx-5.3.0 alabaster-0.7.13 babel-2.11.0 certifi-2024.7.4 charset-normalizer-2.0.12 docutils-0.18.1 idna-3.7 imagesize-1.4.1 pytz-2024.1 requests-2.27.1 snowballstemmer-2.2.0 sphinxcontrib-applehelp-1.0.2 sphinxcontrib-devhelp-1.0.2 sphinxcontrib-htmlhelp-2.0.0 sphinxcontrib-jsmath-1.0.1 sphinxcontrib-qthelp-1.0.3 sphinxcontrib-serializinghtml-1.1.5 urllib3-1.26.19
Pygame-ce requires Python3 version 3.7 or above.
How can I change the python version?
big thanks to @bilhox for the segfault fix
IIRC Notenlish has said that he does not want to work on this PR, so I'll close it. Maybe @Matiiss or @damusss can fix it up sometime and make a new PR (assuming we still want this API)?
Do we still want this API?
Do we still want this API?
I still think people would like this, someone just needs to work on the pr