-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
Description
Description of the request
I want to use a specific font but also draw characters which are not available in that font. Replace them with characters from another "generic" font, like Arial-Bold for example.
Similarly to how web browsers work when they are missing characters from fonts - the OS fills that void from a default font.
from PIL import Image, ImageFont, ImageDraw
temp_canvas = Image.new("RGBA", (1200, 300), (255, 255, 255, 255))
draw_canvas = ImageDraw.Draw(temp_canvas, "RGBA")
font = ImageFont.truetype(r"C:\fonts\BarlowSemiCondensed-Bold.ttf", size=150)
text_string = "hello ಠಠ world"
draw_canvas.text((100, 100), text_string, fill="#000000", font=font)
temp_canvas.show()
Proposed solution
Add an argument to ImageDraw.Draw().text()
like backup_font
, which would be used when the first font doesn't have the character specified in text_string
. Like ಠ
in this example
hpoul, glader, RealA10N, Jackenmen, upcFrost and 23 more