Font Classes
In Drawlib, fonts are categorized into various Font Classes, each serving different purposes and supporting different styles and languages. Here’s an overview of the supported Font Classes:
Default Fonts
Font: Supports both SanSerif and Serif fonts for Alphabet and CJK (Chinese, Japanese, Korean) characters.
Alphabet Fonts
FontSansSerif: Specifically SanSerif fonts for Alphabet characters.FontSerif: Specifically Serif fonts for Alphabet characters.FontMonoSpace: Monospace fonts, where each character occupies the same amount of horizontal space.FontSourcecode: A subset of FontMonoSpace fonts, optimized for source code display usingdsart.sourcecode().FontRoboto: Fonts from the Roboto family, tailored for Alphabet characters.
Local Language Fonts
FontArabic: Fonts specifically designed for Arabic script.FontBrahmic: Fonts for Brahmic scripts used in India and neighboring countries.FontChinese: Fonts tailored for Chinese characters.FontJapanese: Fonts designed for Japanese characters.FontKorean: Fonts specifically for Korean characters.FontThai: Fonts optimized for Thai script.
Each font class supports various styles, though some fonts may have fewer styles available:
Light: A lighter weight variant of the font.
Regular: The standard, normal-weight variant of the font.
Bold: A heavier, bold-weight variant of the font.
Due to the large file sizes of font files, Drawlib does not include them in the initial package when installed via pip. Instead, the necessary font files are downloaded dynamically the first time they are used. This approach minimizes the initial package size and allows for on-demand fetching of resources. Once downloaded, these font files are cached on your local machine.
If needed, you can manage the font cache using the drawlib --purge_font_cache command.
This command clears the cached font files from your system, freeing up storage space if necessary.
FontFile
The FontFile class in Drawlib allows users to utilize custom fonts for rendering text using the text() function and similar methods.
Here’s how you can use the FontFile class in your Python code:
1from drawlib.apis import *
2
3config(width=100, height=50)
4text(
5 (50, 25),
6 "Hello Drawlib!",
7 style=TextStyle(
8 size=36,
9 font=FontFile("./avenger/regular.ttf"),
10 ),
11)
12save()
Executing this code generate the output:
Using font file
Font
The Font class in Drawlib provides default fonts.
Here’s an overview of the fonts available in the Font class:
SanSerif Fonts
SANSSERIF_LIGHT: Noto SansSerif CJK(Chinese, Japanese, Korean)SANSSERIF_REGULARSANSSERIF_BOLD
Serif Fonts
SERIF_LIGHT: Noto Serif CJK JapaneseSERIF_REGULARSERIF_BOLD
By default, the Drawlib’s default theme uses Font.SANSSERIF_REGULAR.
This font choice is based on its standard shape and wide coverage across different languages and populations.
The following image illustrates the fonts available in the Font class:
class Font
FontSansSerif
Class FontSansSerif contains popular SansSerif fonts for alphabet languages.
Lato
LATO_LIGHTLATO_REGULARLATO_BOLD
Raleways
RALEWAYS_LIGHTRALEWAYS_REGULARRALEWAYS_BOLD
Montserrat
MONTSERRAT_LIGHTMONTSERRAT_REGULARMONTSERRAT_BOLD
Oswald
OSWALD_LIGHTOSWALD_REGULAROSWALD_BOLD
Poppins
POPPINS_LIGHTPOPPINS_REGULARPOPPINS_BOLD
The following image illustrates the fonts available in the FontSansSerif class:
class FontSansSerif
FontSerif
Class FontSerif contains popular Serif fonts for alphabet languages.
Courier
COURIER_REGULARCOURIER_BOLD
Merriweather
MERRIWEATHER_LIGHTMERRIWEATHER_REGULARMERRIWEATHER_BOLD
Platypi
PLATYPI_LIGHTPLATYPI_REGULARPLATYPI_BOLD
PlayFairDisplay
PLAYFAIRDISPLAY_LIGHTPLAYFAIRDISPLAY_REGULARPLAYFAIRDISPLAY_BOLD
The following image illustrates the fonts available in the FontSerif class:
class FontSansSerif
FontRoboto
Class FontRoboto famous and popular Roboto group fonts.
Roboto
ROBOTO_LIGHTROBOTO_REGULARROBOTO_BOLD
Roboto Serif
SERIF_LIGHTSERIF_REGULARSERIF_BOLD
Roboto Mono
MONO_LIGHTMONO_REGULARMONO_BOLD
Roboto Condensed
CONDENSED_LIGHTCONDENSED_REGULARCONDENSED_BOLD
Roboto Slab
SLAB_LIGHTSLAB_REGULARSLAB_BOLD
The following image illustrates the fonts available in the FontRoboto class:
class FontRoboto
FontMonoSpace
Class FontMonoSpace contains mono space fonts.
Almost all are for alphabet, but SourceHanCodeJP supports Japanese.
Courier
COURIER_REGULARCOURIER_BOLD
Roboto Mono
ROBOTO_MONO_LIGHTROBOTO_MONO_REGULARROBOTO_MONO_BOLD
SourceCodePro
SOURCECODEPRO_LIGHTSOURCECODEPRO_REGULARSOURCECODEPRO_BOLD
SourceHanCodeJP
SOURCEHANCODEJP_LIGHTSOURCEHANCODEJP_REGULARSOURCEHANCODEJP_BOLD
The following image illustrates the fonts available in the FontMonoSpace class:
class FontSansSerif
FontArabic
Class FontArabic contains Arabic fonts.
Sans Serif
SANSSERIF_LIGHTSANSSERIF_REGULARSANSSERIF_BOLD
Kufi
KUFI_LIGHTKUFI_REGULARKUFI_BOLD
Naskh
NASKH_LIGHTNASKH_REGULARNASKH_BOLD
The following image illustrates the fonts available in the FontArabic class:
class FontArabic
FontBrahmic
Class FontBrahmic contains fonts for characters which delived from Brahmic.
Bengali
BENGALI_SANSSERIF_LIGHTBENGALI_SANSSERIF_REGULARBENGALI_SANSSERIF_BOLDBENGALI_SERIF_LIGHTBENGALI_SERIF_REGULARBENGALI_SERIF_BOLD
Devanagari
DEVANAGARI_SANSSERIF_LIGHTDEVANAGARI_SANSSERIF_REGULARDEVANAGARI_SANSSERIF_BOLDDEVANAGARI_SERIF_LIGHTDEVANAGARI_SERIF_REGULARDEVANAGARI_SERIF_BOLD
Tamil
TAMIL_SANSSERIF_LIGHTTAMIL_SANSSERIF_REGULARTAMIL_SANSSERIF_BOLDTAMIL_SERIF_LIGHTTAMIL_SERIF_REGULARTAMIL_SERIF_BOLD
Telugu
TELUGU_SANSSERIF_LIGHTTELUGU_SANSSERIF_REGULARTELUGU_SANSSERIF_BOLDTELUGU_SERIF_LIGHTTELUGU_SERIF_REGULARTELUGU_SERIF_BOLD
The following image illustrates the fonts available in the FontBrahmic class:
class FontBrahmic
FontChinese
Class FontChinese contains Chinese fonts.
Simplified
SIMPLIFIED_SANSSERIF_LIGHTSIMPLIFIED_SANSSERIF_REGULARSIMPLIFIED_SANSSERIF_BOLDSIMPLIFIED_SERIF_LIGHTSIMPLIFIED_SERIF_REGULARSIMPLIFIED_SERIF_BOLD
Traditional
TRADITIONAL_SANSSERIF_LIGHTTRADITIONAL_SANSSERIF_REGULARTRADITIONAL_SANSSERIF_BOLDTRADITIONAL_SERIF_LIGHTTRADITIONAL_SERIF_REGULARTRADITIONAL_SERIF_BOLD
HongKong
HONGKONG_SANSSERIF_LIGHTHONGKONG_SANSSERIF_REGULARHONGKONG_SANSSERIF_BOLDHONGKONG_SERIF_LIGHTHONGKONG_SERIF_REGULARHONGKONG_SERIF_BOLD
The following image illustrates the fonts available in the FontChinese class:
class FontChinese
FontJapanese
Class FontJapanese contains Japanese fonts.
Sans Serif
SANSSERIF_LIGHTSANSSERIF_REGULARSANSSERIF_BOLD
Serif
SERIF_LIGHTSERIF_REGULARSERIF_BOLD
Mplus 1P
MPLUS1P_LIGHTMPLUS1P_REGULARMPLUS1P_BOLD
Mplus Rounded 1C
MPLUSROUNDED1C_LIGHTMPLUSROUNDED1C_REGULARMPLUSROUNDED1C_BOLD
Sawarabi
SAWARABI_GOTHICSAWARABI_MINCHO
The following image illustrates the fonts available in the FontJapanese class:
class FontJapanese
FontKorean
Class FontKorean contains Korean fonts.
Sans Serif
SANSSERIF_LIGHTSANSSERIF_REGULARSANSSERIF_BOLD
Serif
SERIF_LIGHTSERIF_REGULARSERIF_BOLD
The following image illustrates the fonts available in the FontKorean class:
class FontKorean
FontThai
Class FontThai contains Thai fonts.
Sans Serif
SANSSERIF_LIGHTSANSSERIF_REGULARSANSSERIF_BOLD
Serif
SERIF_LIGHTSERIF_REGULARSERIF_BOLD
The following image illustrates the fonts available in the FontThai class:
class FontThai
Request for Adding Fonts
We welcome suggestions for adding new fonts to our Drawlib library. To ensure compatibility and usability, please consider the following criteria before making a request:
Free License: The font must be available under a free license.
Compatibility: The font should work seamlessly with Drawlib. Note that emoji fonts may not be fully supported at this time.
Language Support: Fonts for languages currently not supported by Drawlib are prioritized, including minor languages.
Global Popularity: The font should be widely recognized and used globally.
Regional Popularity: Fonts for local languages that are popular in specific regions are also highly considered.
Before submitting a request, we recommend testing the font using the FontFile() class to ensure it meets your requirements.
At present, Drawlib does not include decorative or ornamental fonts.
Your input is valuable to us, and if your font suggestion meets these criteria, we will consider adding it in a future release.