I'm developing a module for generate CAPTCHA. This module needs a font file, but the fonts directory path are different in different operating system. Is there a universal way to get the fonts directory path that can be used in different OS?
I don't think there is any such library, atmost wxPython have a wxStandarPaths which can give OS specific paths, may be you can use that to get fonts folder.
But I think even with that you will have to do tweaks per OS, so easiest way is to just create you own function get_font_folder and keep on adding OS to font folder mapping as you test or find bugs :)
Do it with pycairo. You don't even need to know the system font path. You just do
font_map = pangocairo.cairo_font_map_get_default()
families = font_map.list_families()
and you have a list of all the font families.
You can also get a font by its name like
font = pango.FontDescription("Utopia 22")
If you're on a Unix ecosystem then it's the way to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With