1. Теория


pygame.font

pygame.font модулі мәтінді әртүрлі қаріптермен көрсетуге мүмкіндік береді.
Мәтіндік объектілерді құру үшін pygame.font.Font() қолданылады.
Жүйелік қаріптерді жүктеу үшін pygame.font.SysFont() функциясы пайдаланылады.

 

Жүйелік қаріпті пайдалану мысалы

1. Font объектісін жасау:


font = pygame.font.SysFont(
    name="verdana",
    size=40,
    bold=False,
    italic=False
)
  • Жүйелік қаріптің атауы
  • Өлшемі (қаріптің биіктігі, пиксельмен)
  • Қаріп қалың болуы керек пе?
  • Қаріп курсив болуы керек пе?

2. Бет (Surface) жасау:


text = font.render("Hello, World!", True, (255, 255, 255), None)
  • Көрсетілетін мәтін
  • Әріптердің шеттерін тегістеу (сглаживание)
  • Мәтіннің түсі
  • Фонның түсі (None – мөлдір фон)

3. Тік төртбұрышты аймақ жасау:


text_rect = text.get_rect()
text_rect.center = WIDTH // 2, HEIGHT // 2

4. Салу (Отрисовка):


screen.fill((0, 0, 0))

screen.blit(text, text_rect)

pygame.display.update()

Мәтін беті (Surface) экранда тік төртбұрыш координаталары бойынша көрсетіледі.


Жүйелік қаріптердің тізімі
Системдік шрифтер тізімі

  • arial
  • arialblack
  • calibri
  • cambria
  • cambriamath
  • candara
  • comicsansms
  • consolas
  • constantia
  • corbel
  • couriernew
  • ebrima
  • franklingothicmedium
  • gabriola
  • gadugi
  • georgia
  • impact
  • javanesetext
  • leelawadeeui
  • leelawadeeuisemilight
  • lucidaconsole
  • lucidasans
  • malgungothic
  • malgungothicsemilight
  • microsofthimalaya
  • microsoftjhenghei
  • microsoftjhengheiui
  • microsoftnewtailue
  • microsoftphagspa
  • microsoftsansserif
  • microsofttaile
  • microsoftyahei
  • microsoftyaheiui
  • microsoftyibaiti
  • mingliuextb
  • pmingliuextb
  • mingliuhkscsextb
  • mongolianbaiti
  • msgothic
  • msuigothic
  • mspgothic
  • mvboli
  • myanmartext
  • nirmalaui
  • nirmalauisemilight
  • palatinolinotype
  • segoemdl2assets
  • segoeprint
  • segoescript
  • segoeui
  • segoeuiblack
  • segoeuiemoji
  • segoeuihistoric
  • segoeuisemibold
  • segoeuisemilight
  • segoeuisymbol
  • simsun
  • nsimsun
  • simsunextb
  • sitkasmall
  • sitkatext
  • sitkasubheading
  • sitkaheading
  • sitkadisplay
  • sitkabanner
  • sylfaen
  • symbol
  • tahoma
  • timesnewroman
  • trebuchetms
  • verdana
  • webdings
  • wingdings
  • yugothic
  • yugothicuisemibold
  • yugothicui
  • yugothicmedium
  • yugothicuiregular
  • yugothicregular
  • yugothicuisemilight
  • holomdl2assets

time 1000 ms
memory 256 Mb

Комментарий учителя