pygame.font
pygame module for loading and rendering fonts
pygame.font.init
— initialize the font module pygame.font.quit
— uninitialize the font module pygame.font.get_init
— true if the font module is initialized pygame.font.get_default_font
— get the filename of the default font pygame.font.get_sdl_ttf_version
— gets SDL_ttf version pygame.font.get_fonts
— get all available fonts pygame.font.match_font
— find a specific font on the system pygame.font.SysFont
— create a Font object from the system fonts pygame.font.Font
— create a new Font object from a file The font module allows for rendering TrueType fonts into Surface objects.This module is built on top of the SDL_ttf library, which comes with allnormal pygame installations.
Most of the work done with fonts are done by using the actual Font objects.The module by itself only has routines to support the creation of Font objectswith pygame.font.Font()create a new Font object from a file.
You can load fonts from the system by using the pygame.font.SysFont()create a Font object from the system fontsfunction. There are a few other functions to help look up the system fonts.
Pygame comes with a builtin default font, freesansbold. This can always beaccessed by passing
None
as the font name.Before pygame 2.0.3, pygame.font accepts any UCS-2 / UTF-16 character('\u0001' to '\uFFFF'). After 2.0.3, pygame.font built with SDL_ttf2.0.15 accepts any valid UCS-4 / UTF-32 character(like emojis, if the font has them) ('\U00000001' to '\U0010FFFF')).More about this in Font.render().
Before pygame 2.0.3, this character space restriction can be avoided byusing the pygame.freetypeEnhanced pygame module for loading and rendering computer fonts based
pygame.ftfont
to emulate the Fontmodule. This can be used by defining the environment variable PYGAME_FREETYPEbefore the first import of pygamethe top level pygame package. Since the problempygame.ftfont
solves no longer exists, it will likely be removed in the future.- pygame.font.init()¶
initialize the font module
init() -> None
This method is called automatically by
pygame.init()
. It initializes thefont module. The module must be initialized before any other functions willwork.It is safe to call this function more than once.
- pygame.font.quit()¶
uninitialize the font module
quit() -> None
Manually uninitialize SDL_ttf's font system. This is called automatically by
pygame.quit()
.It is safe to call this function even if font is currently not initialized.
- pygame.font.get_init()¶
true if the font module is initialized
get_init() -> bool
Test if the font module is initialized or not.
- pygame.font.get_default_font()¶
get the filename of the default font
get_default_font() -> string
Return the filename of the system font. This is not the full path to thefile. This file can usually be found in the same directory as the fontmodule, but it can also be bundled in separate archives.
- pygame.font.get_sdl_ttf_version()¶
gets SDL_ttf version
get_sdl_ttf_version(linked=True) -> (major, minor, patch)
Experimental: feature still in development available for testing and feedback. It may change.Please leave get_sdl_ttf_version feedback with authors
Returns a tuple of integers that identify SDL_ttf's version.SDL_ttf is the underlying font rendering library, written in C,on which pygame's font module depends. If 'linked' is True (the default),the function returns the version of the linked TTF library.Otherwise this function returns the version of TTF pygame was compiled with
New in pygame 2.1.3.
- pygame.font.get_fonts()¶
get all available fonts
get_fonts() -> list of strings
Returns a list of all the fonts available on the system. The names of thefonts will be set to lowercase with all spaces and punctuation removed. Thisworks on most systems, but some will return an empty list if they cannotfind fonts.
Changed in pygame 2.1.3: Checks through user fonts instead of just global fonts for Windows.
- pygame.font.match_font()¶
find a specific font on the system
match_font(name, bold=False, italic=False) -> path
Returns the full path to a font file on the system. If bold or italic areset to true, this will attempt to find the correct family of font.
The font name can also be an iterable of font names, a string ofcomma-separated font names, or a bytes of comma-separated font names, inwhich case the set of names will be searched in order.If none of the given names are found, None is returned.
New in pygame 2.0.1: Accept an iterable of font names.
Changed in pygame 2.1.3: Checks through user fonts instead of just global fonts for Windows.
Example:
print pygame.font.match_font('bitstreamverasans')# output is: /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf# (but only if you have Vera on your system)
- pygame.font.SysFont()¶
create a Font object from the system fonts
SysFont(name, size, bold=False, italic=False) -> Font
Return a new Font object that is loaded from the system fonts. The font willmatch the requested bold and italic flags. Pygame uses a small set of commonfont aliases. If the specific font you ask for is not available, a reasonablealternative may be used. If a suitable system font is not found this willfall back on loading the default pygame font.
The font name can also be an iterable of font names, a string ofcomma-separated font names, or a bytes of comma-separated font names, inwhich case the set of names will be searched in order.
New in pygame 2.0.1: Accept an iterable of font names.
Changed in pygame 2.1.3: Checks through user fonts instead of just global fonts for Windows.
- pygame.font.Font¶
create a new Font object from a file
Font(file_path=None, size=12) -> Font
Font(file_path, size) -> Font
Font(pathlib.Path, size) -> Font
Font(object, size) -> Font
pygame.font.Font.bold
— Gets or sets whether the font should be rendered in (faked) bold. pygame.font.Font.italic
— Gets or sets whether the font should be rendered in (faked) italics. pygame.font.Font.underline
— Gets or sets whether the font should be rendered with an underline. pygame.font.Font.strikethrough
— Gets or sets whether the font should be rendered with a strikethrough. pygame.font.Font.render
— draw text on a new Surface pygame.font.Font.size
— determine the amount of space needed to render text pygame.font.Font.set_underline
— control if text is rendered with an underline pygame.font.Font.get_underline
— check if text will be rendered with an underline pygame.font.Font.set_strikethrough
— control if text is rendered with a strikethrough pygame.font.Font.get_strikethrough
— check if text will be rendered with a strikethrough pygame.font.Font.set_bold
— enable fake rendering of bold text pygame.font.Font.get_bold
— check if text will be rendered bold pygame.font.Font.set_italic
— enable fake rendering of italic text pygame.font.Font.metrics
— gets the metrics for each character in the passed string pygame.font.Font.get_italic
— check if the text will be rendered italic pygame.font.Font.get_linesize
— get the line space of the font text pygame.font.Font.get_height
— get the height of the font pygame.font.Font.get_ascent
— get the ascent of the font pygame.font.Font.get_descent
— get the descent of the font pygame.font.Font.set_script
— set the script code for text shaping Load a new font from a given filename or a python file object. The size isthe height of the font in pixels. If the filename is
None
the pygamedefault font will be loaded. If a font cannot be loaded from the argumentsgiven an exception will be raised. Once the font is created the size cannotbe changed. If no arguments are given then the default font will be used anda font size of 12 is used.Font objects are mainly used to render text into new Surface objects. Therender can emulate bold or italic features, but it is better to load from afont with actual italic or bold glyphs.
- bold¶
Gets or sets whether the font should be rendered in (faked) bold.
bold -> bool
Whether the font should be rendered in bold.
When set to True, this enables the bold rendering of text. Thisis a fake stretching of the font that doesn't look good on manyfont types. If possible load the font from a real bold fontfile. While bold, the font will have a different width than whennormal. This can be mixed with the italic, underline andstrikethrough modes.
New in pygame 2.0.0.
- italic¶
Gets or sets whether the font should be rendered in (faked) italics.
italic -> bool
Whether the font should be rendered in italic.
When set to True, this enables fake rendering of italictext. This is a fake skewing of the font that doesn't look goodon many font types. If possible load the font from a real italicfont file. While italic the font will have a different widththan when normal. This can be mixed with the bold, underline andstrikethrough modes.
New in pygame 2.0.0.
- underline¶
Gets or sets whether the font should be rendered with an underline.
underline -> bool
Whether the font should be rendered in underline.
When set to True, all rendered fonts will include anunderline. The underline is always one pixel thick, regardlessof font size. This can be mixed with the bold, italic andstrikethrough modes.
New in pygame 2.0.0.
- strikethrough¶
Gets or sets whether the font should be rendered with a strikethrough.
strikethrough -> bool
Whether the font should be rendered with a strikethrough.
When set to True, all rendered fonts will include anstrikethrough. The strikethrough is always one pixel thick,regardless of font size. This can be mixed with the bold,italic and underline modes.
New in pygame 2.1.3.
- render()¶
draw text on a new Surface
render(text, antialias, color, background=None) -> Surface
This creates a new Surface with the specified text rendered on it.pygame.fontpygame module for loading and rendering fonts provides no way to directly draw text on an existingSurface: instead you must use Font.render() to create an image(Surface) of the text, then blit this image onto another Surface.
The text can only be a single line: newline characters are not rendered.Null characters ('x00') raise a TypeError. Both Unicode and char (byte)strings are accepted. For Unicode strings only UCS-2 characters('\u0001' to '\uFFFF') were previously supported and any greaterunicode codepoint would raise a UnicodeError. Now, characters in theUCS-4 range are supported. For char strings a
LATIN1
encoding isassumed. The antialias argument is a boolean: if True the characterswill have smooth edges. The color argument is the color of the text[e.g.: (0,0,255) for blue]. The optional background argument is a colorto use for the text background. If no background is passed the areaoutside the text will be transparent.The Surface returned will be of the dimensions required to hold the text.(the same as those returned by Font.size()). If an empty string is passedfor the text, a blank surface will be returned that is zero pixel wide andthe height of the font.
Depending on the type of background and antialiasing used, this returnsdifferent types of Surfaces. For performance reasons, it is good to knowwhat type of image will be used. If antialiasing is not used, the returnimage will always be an 8-bit image with a two-color palette. If thebackground is transparent a colorkey will be set. Antialiased images arerendered to 24-bit
RGB
images. If the background is transparent apixel alpha will be included.Optimization: if you know that the final destination for the text (on thescreen) will always have a solid background, and the text is antialiased,you can improve performance by specifying the background color. This willcause the resulting image to maintain transparency information bycolorkey rather than (much less efficient) alpha values.
If you render '\n' an unknown char will be rendered. Usually arectangle. Instead you need to handle newlines yourself.
Font rendering is not thread safe: only a single thread can render textat any time.
Changed in pygame 2.0.3: Rendering UCS4 unicode works and does notraise an exception. Use if hasattr(pygame.font, "UCS4"): to see ifpygame supports rendering UCS4 unicode including more languages andemoji.
- size()¶
determine the amount of space needed to render text
size(text) -> (width, height)
Returns the dimensions needed to render the text. This can be used tohelp determine the positioning needed for text before it is rendered. Itcan also be used for word wrapping and other layout effects.
Be aware that most fonts use kerning which adjusts the widths forspecific letter pairs. For example, the width for "ae" will not alwaysmatch the width for "a" + "e".
- set_underline()¶
control if text is rendered with an underline
set_underline(bool) -> None
When enabled, all rendered fonts will include an underline. The underlineis always one pixel thick, regardless of font size. This can be mixedwith the bold, italic and strikethrough modes.
Note
This is the same as the underline attribute.
- get_underline()¶
check if text will be rendered with an underline
get_underline() -> bool
Return True when the font underline is enabled.
Note
This is the same as the underline attribute.
- set_strikethrough()¶
control if text is rendered with a strikethrough
set_strikethrough(bool) -> None
When enabled, all rendered fonts will include a strikethrough. Thestrikethrough is always one pixel thick, regardless of font size.This can be mixed with the bold, italic and underline modes.
Note
This is the same as the strikethrough attribute.
New in pygame 2.1.3.
- get_strikethrough()¶
check if text will be rendered with a strikethrough
get_strikethrough() -> bool
Return True when the font strikethrough is enabled.
Note
This is the same as the strikethrough attribute.
New in pygame 2.1.3.
- set_bold()¶
enable fake rendering of bold text
set_bold(bool) -> None
Enables the bold rendering of text. This is a fake stretching of the fontthat doesn't look good on many font types. If possible load the font froma real bold font file. While bold, the font will have a different widththan when normal. This can be mixed with the italic, underline andstrikethrough modes.
Note
This is the same as the bold attribute.
- get_bold()¶
check if text will be rendered bold
get_bold() -> bool
Return True when the font bold rendering mode is enabled.
Note
This is the same as the bold attribute.
- set_italic()¶
enable fake rendering of italic text
set_italic(bool) -> None
Enables fake rendering of italic text. This is a fake skewing of the fontthat doesn't look good on many font types. If possible load the font froma real italic font file. While italic the font will have a differentwidth than when normal. This can be mixed with the bold, underline andstrikethrough modes.
Note
This is the same as the italic attribute.
- metrics()¶
gets the metrics for each character in the passed string
metrics(text) -> list
The list contains tuples for each character, which contain the minimum
X
offset, the maximumX
offset, the minimumY
offset, themaximumY
offset and the advance offset (bearing plus width) of thecharacter. [(minx, maxx, miny, maxy, advance), (minx, maxx, miny, maxy,advance), ...]. None is entered in the list for each unrecognizedcharacter.
- get_italic()¶
check if the text will be rendered italic
get_italic() -> bool
Return True when the font italic rendering mode is enabled.
Note
This is the same as the italic attribute.
- get_linesize()¶
get the line space of the font text
get_linesize() -> int
Return the height in pixels for a line of text with the font. Whenrendering multiple lines of text this is the recommended amount of spacebetween lines.
- get_height()¶
get the height of the font
get_height() -> int
Return the height in pixels of the actual rendered text. This is theaverage size for each glyph in the font.
- get_ascent()¶
get the ascent of the font
get_ascent() -> int
Return the height in pixels for the font ascent. The ascent is the numberof pixels from the font baseline to the top of the font.
- get_descent()¶
get the descent of the font
get_descent() -> int
Return the height in pixels for the font descent. The descent is thenumber of pixels from the font baseline to the bottom of the font.
- set_script()¶
set the script code for text shaping
set_script(str) -> None
Experimental: feature still in development available for testing and feedback. It may change.Please leave feedback with authors
Sets the script used by harfbuzz text shaping, taking a 4 characterscript code as input. For example, Hindi is written in the Devanagariscript, for which the script code is "Deva". See the full list ofscript codes in ISO 15924.
This method requires pygame built with SDL_ttf 2.20.0 or above. Otherwise themethod will raise a pygame.error.
New in pygame 2.2.0.
pygame.font — pygame v2.6.0 documentation (2024)
References
- https://thenevadaindependent.com/article/in-return-to-nevada-obama-condemns-trumps-character-touts-harris-proposals
- https://www.dnd-compendium.com/player-guides/character-creation
- https://milanote.com/guide/characters
- https://www.bedrockexplorer.com/marketplace-offer/ascent/kawaii-top
- https://www.arb.com.au/new-vehicle-offerings/next-generation-ford-ranger/
- https://www.pygame.org/docs/ref/font.html/
Top Articles
Mecklenburg County Mugshots August 3rd - WCCB Charlotte's CW
Brujita, by Chris Masuak and The Viveiro Wave Riders
Blueberry Automatic (Zamnesia Seeds) feminisiert
Latest Posts
Mecklenburg County Mugshots August 6th - WCCB Charlotte's CW
Essential Equipment for Antkeeping: High-Quality Options
Recommended Articles
- Matt Krol Today 2023
- Visited an ABDL store in Albany, NY
- What Theaters Are Showing Journeyman
- Games Like Uncle Zebulon's Will
- After-Sun Test und Vergleich 2024
- The best photo organizing software in 2024
- Gem Legends Styles
- Grand Gardens Memorabilia
- Is Ishq Tamasha Based On True Story
- 新垣結衣 Upcoming Movies 2019
- Interview mit Artur Jussupow
- All Episodes Of Himeyuka & Rozione’s Story
- Are HydraFacials Worth The Hype? Our Editor Put It To The Test
- References – Psychology 2e
- Chia Anime Little Nemo Pilot
- Why Helldivers 2 Might’ve Hit a Ceiling with Ship Module Upgrade Customization
- Optimize Your Heat Pump: The Power of the Expansion Valve Revealed - Apollo Heat Pumps
- 5 Best Eyebrow Trimmers and Razors To Maintain Unruly Brows
- Mark Ss Manga Mangakakalot
- The Best Beard Trimmers Will Keep Your Scruff Shaped Up
- Rayman Brain Games Do
- Crayon Shin-Chan Movie 01: Action Kamen Vs. Haigure Maou Gender Bender
- Best electric shavers in 2024 to keep stubble in check | Stuff
- Tomijuu S1
- Book Excerpt: Muhammad Ali ‘beats’ Jimmy Young thanks to gift decision - The Ring
- Why Do Hippies Smell Like Patchouli? Stress, Anxiety & Benefits
- How to make a purifying foaming cleanser - Formula Botanica
- When Did The Movie とらいあんぐるBlue Come Out
- How To Start Seventeen
- Big Earth Gamestop Ps5
- The Illusionary Golden Bowl Behind The Voice Actors
- Jayabrata Das Rihanna
- The Princess's Mirror 73
- Tetsuwan Atom: Kagayakeru Hoshi - Anata Wa Aoku, Utsukushii... S2 Ep 3
- La bella stagione, la recensione del documentario sulla Sampdoria
- Male to Female Transformation Stories Library Wiki
- A Matter of Trust: Dayaks & Z Special Unit Operatives in Borneo 1945
- Someday's Dreamers Ii: Sora When Will It End
- 10 Fascinating Facts of Korean Actor Yeon Woo Jin – Profile, Works, Ideal Type, Net Worth, and More
- Postponement Warning Ep 7 English Dub
- The One And Only Thing Box Office
- Hot Topic Seitokaichou Hikaru
- Frases De David Earl
- मिथ्या Book
- Puzzler World Xl Ps4 Target
- Shahid Kapoor Doppelgänger
- The 30 best family resorts in Wisconsin Dells
- Shinyaku Märchen 04
- Burning Moon Gif Wallpaper
- Filmes Elizabeth Henstridge
- Types Of Car Paint Top Coats
- How To Contact Mokoko X
- 월수금화목토 Online Free
- Best all-natural makeup remover cleansing wipes | Well+Good
- Watch Kono Minikuku Mo Utsukushii Sekai Episode 1 Dubbed
- Actors Of The Fantastic Beasts: The Secrets Of Dumbledore (2022)
- These Top-Tested Hands Creams (From $6!) Make Great Stocking Stuffers
- Akumu No Elevator Season 2 Episode 6 Sub
- 12 Best Exfoliators For Black Skin 2024, Cleanse, Tone & Scrub To Perfection - That Sister
- 《Wallpaper Engine》steam正版分流-3DM单机
- Where To Watch Vfw (2019)
- Homura Manga Wiki
- Dragon Quest Great Adventure Of Dai! Disciple Of Aban. Armor
- 薄桜鬼 〜御伽草子〜 Transcript
- Heroes League Baseball Saddest Moments
- E-Rechnung mit DATEV
- Ocean's Eight streaming: where to watch online?
- Real Name Of Fraser Taggart
- Piyoko Ni Omakase Pyo! Ep 5 Dub
- Filmy online, oglądaj przez internet na Player.pl
- Erfroren, zerrissen, zermalmt: 4 Szenarien für das Ende des Universums
- Easy Anti Cheat Clash Royale
- I'm Wearing The New Glossier You Perfumes On Repeat — They're That Good
- Neon Sign Amber Opening Mp3 Download
- My Heroic Husband 2160P Download
- SEAL Team Season 7 Cast, Characters & Actors (Photos)
- Qiang Shen Ji Vampire
- Doctors Agree: These Futuristic Helmets Could Help Grow Your Hair Back
- Fast Travel Star Wars Jedi: Survivor - Deluxe Edition
- What Can I Watch Insanity: The Asylum Volume 2 On
- How to use SPNs when you configure Web applications that are hosted on Internet Information Services
- AEW's Best Friends Members, Ranked By Promo Skills
- Can I Put Any Mirror in the Bathroom? (3 Mistakes to Avoid)
- 9 Types of Specimen Collection Containers, Tubes, Swabs and Devices | Lab Tests Guide
- CeraVe Lotion Review: A Review of The 10 Best CeraVe Lotion Products - The Dermatology Review
- The 15 Best Aluminum-Free Deodorants That Actually Work
- Soukou Kihei Votoms Vol.i: Stories Of The "A.t.votoms" Japanese Voice Actors
- Green Eggs And Ham 1080P Download
- Hectopascal Temporada 3 Capitulo 3
- Amazing Grace Song Download
- Sanjeev Bhaskar – Kriminalakte
- Doesn't Want To Die So She Decided To Crossdress Is Boring
- Departed Dlc 2 Release Date
- Nimrod Reshef Body Count
- Ghost Ghost Summer Flirt | Savour Experience Perfumes
- Is Argoman The Fantastic Superman (1967) The Last Movie
- Honeymoon Typhoon Season Three
- Lene Beier Wikipedia Magyar
- design
- mixed nail decorations
- nail decoration nails
- manicure sticker easter
- flowers line art 3d stickers nail
- design art decorations
- nail art templates printing stencil
- nail art stamping plate
- for home manicure
- stickers decals
Article information
Author: Lakeisha Bayer VM
Last Updated:
Views: 5588
Rating: 4.9 / 5 (69 voted)
Reviews: 92% of readers found this page helpful
Author information
Name: Lakeisha Bayer VM
Birthday: 1997-10-17
Address: Suite 835 34136 Adrian Mountains, Floydton, UT 81036
Phone: +3571527672278
Job: Manufacturing Agent
Hobby: Skimboarding, Photography, Roller skating, Knife making, Paintball, Embroidery, Gunsmithing
Introduction: My name is Lakeisha Bayer VM, I am a brainy, kind, enchanting, healthy, lovely, clean, witty person who loves writing and wants to share my knowledge and understanding with you.