You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Side note: The temp fix does fail sometimes. I have tracked this down the the library we use for determining the encoding returning an incorrect result. As a quickfix to this, a UnicodeDecodeError can fall back to UTF-8 before bailing out completely.
Activity
mm12 commentedon Jan 18, 2026
Side note: The temp fix does fail sometimes. I have tracked this down the the library we use for determining the encoding returning an incorrect result. As a quickfix to this, a
UnicodeDecodeErrorcan fall back toUTF-8before bailing out completely.TrigamDev commentedon Mar 1, 2026
This would be closed by #1226, since it replaces text files previews with a text box, rather than a rendered image