Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I avoid generating not text characters #105

Closed
neouyghur opened this issue Apr 7, 2018 · 3 comments
Closed

How can I avoid generating not text characters #105

neouyghur opened this issue Apr 7, 2018 · 3 comments

Comments

@neouyghur
Copy link

neouyghur commented Apr 7, 2018

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

@ankush-me
Copy link
Owner

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.

@neouyghur
Copy link
Author

neouyghur commented Apr 18, 2018

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

@ayumiymk
Copy link

ayumiymk commented Oct 21, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants