Skip to content

Add .point_size attribute modifier for fonts #1961

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 27 commits into from
Jul 30, 2023
Merged

Add .point_size attribute modifier for fonts #1961

merged 27 commits into from
Jul 30, 2023

Conversation

andrewhong04
Copy link
Member

@andrewhong04 andrewhong04 commented Mar 1, 2023

Original PR: pygame/pygame#3688

This pull request has been significantly improved since its original state.

Video

vid

Test code

import pygame
import sys

pygame.init()
screen = pygame.display.set_mode((690, 690))

font = pygame.font.Font(None, 10)

while True:
    for x in pygame.event.get():
        if x.type == pygame.QUIT:
            sys.exit()
        if x.type == pygame.KEYUP:
            if x.key == pygame.K_UP:
                # font.set_pointsize(font.get_pointsize() + 10)
                font.pointsize += 10
            if x.key == pygame.K_DOWN:
                # font.set_pointsize(font.get_pointsize() - 10)
                font.pointsize -= 10

    screen.fill((0, 0, 0))
    screen.blit(font.render("among us is real", True, (255, 255, 255)), (250, 250))
    
    pygame.display.flip()

@andrewhong04 andrewhong04 requested a review from a team as a code owner March 1, 2023 02:22
@MyreMylar MyreMylar added this to the 2.1.4 milestone Mar 2, 2023
@MyreMylar
Copy link
Member

I'd like to put this in 2.1.4, because it is font related - if you can get it working.

@andrewhong04 andrewhong04 requested a review from MyreMylar March 3, 2023 10:27
Copy link
Member

@MyreMylar MyreMylar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works well in my testing 👍 Nice work and thanks for fixing it up.

I have some style and philosophical(?) quibbles that you may, or may not, agree with so I'm leaving this review on comment for now.

@Starbuck5
Copy link
Member

I believe we should call this “size” to match the existing freetype attribute.

@andrewhong04
Copy link
Member Author

I believe we should call this “size” to match the existing freetype attribute.

@Starbuck5 and I were in call and realized that font.size is already taken.

@MyreMylar MyreMylar changed the title Add pointsize attribute modifier for fonts Add .point_size attribute modifier for fonts Mar 4, 2023
@MyreMylar MyreMylar modified the milestones: 2.1.4, 2.2 Mar 4, 2023
@yunline yunline added New API This pull request may need extra debate as it adds a new class or function to pygame font pygame.font labels Mar 19, 2023
@Starbuck5 Starbuck5 modified the milestones: 2.2, 2.3 Mar 26, 2023
@Starbuck5 Starbuck5 modified the milestones: 2.3, 2.3.1 Jun 10, 2023
@andrewhong04
Copy link
Member Author

andrewhong04 commented Jul 13, 2023

Whoops, I've been in hiatus for a while. I've pushed some commits resolving some reviews.

Copy link
Member

@Starbuck5 Starbuck5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I've noticed this raises a deprecation warning if you give it a float, and the SDL_TTF_VERSION_ATLEAST could be relaxed around getters. But that can be fixed in the future.

@Starbuck5 Starbuck5 merged commit a7e61d4 into pygame-community:main Jul 30, 2023
@andrewhong04 andrewhong04 deleted the pointsize branch July 30, 2023 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
font pygame.font New API This pull request may need extra debate as it adds a new class or function to pygame
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants