Open MetPhoto opened 7 years ago
The font path thing was added in #98 and yes you are correct it looks like there is no readme info about it or the size attribute.
There is a font size attribute mentioned in the command line section but it also mentions there an x and y location which I'm not sure actually work either.
@francesco-vannini shall we go through all the readme API examples at some point in the next couple of weeks and make sure it's all fully and correctly documented?
Thanks for the heads up @MetPhoto
@MetPhoto How do you properly specify the font path. I have a /fonts folder in the same folder as my python script. It finds the fonts and works correctly if I execute the script like python myApp.py
. But if I try to go to the parent folder and execute python myAppFolder/myApp.py
it can't find the font file. I would like it to work in both scenarios.
Did you try it like suggested text.write("Text, font_size, font_path='path to font')
?
Actually there's a typo there. Should be text.write("Text", font_size, font_path='path to font')
Sorry, wasn't clear on my question. I am having issue with the actual font path working if i execute my python script from another folder. It might be more of a python question (this is literally my first python project so I am learning on the go), than specific to this function.
Basically:
python MyApp.py
the font works just fine.python MyAppFolder/MyApp.py
the script fails because it can't find the font file.I will ideally like it to work regardless if I execute with or without the folder.
How have you declared the font path in the code? Can you copy and paste the line of code here?
I just figured it out -- and it appears to work:
fontPath = os.path.dirname(os.path.abspath(__file__)) + /fonts/benton-sans-regular.ttf
Then to write, I am just simply using the variable:
text.write("Text", font_size, font_path=fontPath)
Yeah I was going to say that it probably because you were using a relative path both an absolute path from root
@francesco-vannini perhaps we should add a demo to readme showing the font path stuff?
The font size attribute appears not to be documented.
The syntax appears to be text.write("Text, font_size, font_path='path to font')
Example, text in 12 point using the default font: text.write("Hello world!", 12)