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

ImageFont.truetype problem #50

Open
paapu88 opened this issue Dec 10, 2020 · 4 comments
Open

ImageFont.truetype problem #50

paapu88 opened this issue Dec 10, 2020 · 4 comments
Labels

Comments

@paapu88
Copy link

paapu88 commented Dec 10, 2020

Dear Developers,
I have Ubuntu 20.04
python 3.8.5
pycoast==1.4.0

I followed:
https://github.com/pytroll/pycoast/blob/master/docs/source/graticule.rst

This did work fine:

 img = Image.open(os.path.join(outDir, outFileName))
 cw = ContourWriterAGG('/home/hu-mka/git/cyclonesatpy/cyclonesatpy/dev/shapefiles/')
 font=aggdraw.Font('black', '/usr/share/fonts/truetype/ubuntu/Ubuntu-B.ttf',opacity=127, size=16)
 cw.add_coastlines(img, areadef, resolution='l', level=4, outline=(255, 0, 0))
 cw.add_grid(img, areadef, (2.0, 2.0), (1.0, 1.0), font, fill='blue',
 outline = 'blue', minor_outline = 'blue')

But if i replace font by:
font = ImageFont.truetype('/usr/share/fonts/truetype/freefont/FreeSans.ttf', 16)
I get:

TypeError: text() argument 2 must be Font, not FreeTypeFont
Terveisin, Markus

@djhoese
Copy link
Member

djhoese commented Dec 10, 2020

If the aggdraw.Font works for you, is there a reason you need to use the ImageFont.truetype option?

The basic excuse on our end is that there are some incompatibilities between the old "PIL" based writer and the AGG-based writer. The AGG writer depends on "aggdraw" which is the real problem here as that library doesn't support PIL's ImageFont objects and pycoast does not currently have a way to wrap/workaround that (ex. convert ImageFont objects from the user to Font objects for aggdraw).

@paapu88
Copy link
Author

paapu88 commented Dec 10, 2020

Hei,
I'm fine now, but please remove ImageFont.truetype if you have it in the documentation (not sure that's the case) so other people will not waste their time (I wasted 15min of my precious time...).
But really a great package!! Thanks!
Markus

@djhoese
Copy link
Member

djhoese commented Dec 10, 2020

ImageFont.truetype if you have it in the documentation (not sure that's the case)

ImageFont objects can still be used with the PIL writer which is still available and used to be the default writer. If you aren't sure it is in the documentation, then where did you see that you should use it? Is there something that needs updating? Any help would be greatly appreciated.

@paapu88
Copy link
Author

paapu88 commented Dec 10, 2020

Aa, it was here (first thing google gave me)
https://github.com/pytroll/pycoast/blob/master/docs/source/graticule.rst

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

No branches or pull requests

2 participants