ankush-me/SynthText

How can I avoid generating not text characters

neouyghur opened this issue · 3 comments

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?

sample image

Could be a coloring, or a font problem.

  1. Make sure the text can be rendered in the font you are using for it.
  2. If 1 is ok, then you can do a simple alpha blend and see if that helps.

How can I do the step 1? is there any function do that? Thanks. is there a good way to do that?

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')