How can I avoid generating not text characters
neouyghur opened this issue · 3 comments
neouyghur commented
I am using my own fonts to generate texts. However, in many cases, small rectangles are drawn to image instead of actual text. How can I avoid that?
ankush-me commented
Could be a coloring, or a font problem.
- Make sure the text can be rendered in the font you are using for it.
- If 1 is ok, then you can do a simple alpha blend and see if that helps.
neouyghur commented
How can I do the step 1? is there any function do that? Thanks. is there a good way to do that?
ayumiymk commented
import fontconfig
# the given char
char = ''
char = char.decode('utf-8')
# the list of font paths
font_conf = fontconfig.FcFont(font_path)
if font_conf.has_char(char):
print('1')
else:
print('0')