Skip to content
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

pygame.freetype.Font.get_metrics returns the third value in tuple 'min_y' a wrong value #4148

Open
gkusnir opened this issue Jan 26, 2024 · 0 comments
Labels

Comments

@gkusnir
Copy link

gkusnir commented Jan 26, 2024

pygame 2.5.2 (SDL 2.28.3, Python 3.11.2) on Raspberry Pi OS

When running get_metrics() on a font object, the resulting list of tuples contains the metrics values and the min_y value (which is the third value in the tuple) is sometimes a huge positive integer. Assuming from the similarity with pygame.font.Font.metrics() this value should be a small negative integer. It looks like the value is just wrongly interpreted as unsigned int instead of signed int.

pygame.font.Font.metrics() for a letter 'd' gives this tuple (3, 50, -3, 73, 56)
pygame.freetype.Font.get_metrics() for 'd' gives this tuple (3, 50, 4294967293, 73, 56.0, 0.0)
The number 4294967293 when interpreted as signed is -3.

import pygame
import pygame.freetype
pygame.init()
pygame.freetype.init()

ff = pygame.freetype.match_font("freesans")
f = pygame.freetype.Font(ff)

_metrics = f.get_metrics("d", 100)

print(_metrics)
@gkusnir gkusnir added the bug label Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant