Skip to content

[Task]: Extract random font selection logic into a dedicated helper function #319

Description

@sepandhaghighi

Describe the feature you want to add

Refactor the random font selection logic in indirect_font() to reduce duplicated code and make adding new random font groups easier.

Describe your proposed solution

Create a new helper function random_from_group() in utils.py that receives a font size group name (small, medium, large, xlarge) and returns a random font from the corresponding list in RND_SIZE_DICT.

Replace the repeated conditional blocks inside indirect_font():

  • rnd-small
  • rnd-medium
  • rnd-large
  • rnd-xlarge

with a dictionary-based mapping between aliases and font groups. Use the helper function to return the selected font.

This reduces duplicated random.choice() calls and makes future random font categories easier to add.

Describe alternatives you've considered, if relevant

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions