-
-
Notifications
You must be signed in to change notification settings - Fork 442
Description
Checklist
- I am using an up-to-date version.
- I have read the documentation.
- I have searched existing issues.
Description
the _text_thumb method renders the thumbnail for text files. Unfortunately, it does not specify a font. Because of this, a large number of characters show up as placeholder boxes, which isn't ideal:
Solution
For thumbnails, the only thing needed to fix this is to use font(s) with wide Unicode support. System fonts (such as Meiryo on Windows) tend to have great support. Another good option, if available, is using Google's Noto family of fonts.
For the preview pane, I certainly think that using a rich preview of the text (ie, actually render the text) instead of the thumbnail would be ideal.
I tested it, and indeed this fixes the problem (minimal version):
+ font = None
+ meiryo_path = Path("C:/Windows/Fonts/meiryo.ttc")
+ try:
+ font = ImageFont.truetype(str(meiryo_path), size=16)
+ except OSError:
+ font = ImageFont.load_default()
+ draw.text((16, 16), text, fill=fg_color, font=font)
- draw.text((16, 16), text, fill=fg_color)And indeed, the thumbnail now renders the text.
Alternatives
I find rich text highly desirable - text in images will always be flawed.
