How do I get the OS System Font Directory(Cross-Platform) in python?

Metallicow metaliobovinus at gmail.com
Fri Jul 12 00:24:00 EDT 2013


On Thursday, July 11, 2013 8:27:04 PM UTC-5, Christian Heimes wrote:
> Am 11.07.2013 19:19, schrieb Metallicow:
> 
> > @ Chris �Kwpolska� Warrick
> 
> > Thanks, that is a start anyway. 
> 
> > a Pure-Python way was what I was wanting, not win32api stuff.
> 
> > 
> 
> > "C:\Windows\Fonts"
> 
> > The windows path proves valid. Works on XP, Vista, 7. Not sure about win8....?
> 
> 
> 
> That's the wrong way to do it. You have to use the proper Windows API to
> 
> get to the font directory. It's SHGetKnownFolderPath() with
> 
> FOLDERID_Font or SHGetFolderPath() with CSIDL_FONTS.
> 
> 
> 
> See http://bugs.python.org/issue1763
> 
> 
> 
> Christian

typo'd instead of copy/pasted. What I meant was... Chris's code...

>>> FONTDIRS = os.path.join(os.environ['WINDIR'], 'Fonts') 
'C:\\WINDOWS\\Fonts'

returned valid as returned string. Forgot to add >>> part.
Is there any way to edit posts? Don't see an edit linky anywhere.
Is there something wrong with using os.environ...?
win32api stuff is another dependency. Is it really needed?



More information about the Python-list mailing list