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

Chris Angelico rosuav at gmail.com
Fri Jul 12 00:58:49 EDT 2013


On Fri, Jul 12, 2013 at 2:24 PM, Metallicow <metaliobovinus at gmail.com> wrote:
> 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?

No, you fundamentally cannot edit posts. This is a Usenet newsgroup
and a mailing list; once your post is sent, it gets carried by lots of
different servers separately. Just send a followup, same as you did
there.

Since you seem to be using Google Groups, please read this to learn
how to avoid antagonizing a significant proportion of the list's best
responders:

http://wiki.python.org/moin/GoogleGroupsPython

ChrisA



More information about the Python-list mailing list