Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50462
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.134.4.91.MISMATCH!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <kwpolska@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.022 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'else:': 0.03; 'elif': 0.05; 'attribute': 0.07; 'linux,': 0.07; 'skip:` 10': 0.07; 'python:': 0.09; 'subject:How': 0.10; 'devise': 0.16; 'exists,': 0.16; 'fancy': 0.16; 'gpg': 0.16; 'portable': 0.16; 'skip:[ 30': 0.16; 'subject: \n ': 0.16; 'tags.': 0.16; 'tool.': 0.16; 'windows:': 0.16; 'subject:python': 0.16; 'apps': 0.16; 'wrote:': 0.18; 'commit': 0.19; 'thu,': 0.19; 'install': 0.23; 'header:User- Agent:1': 0.23; 'parse': 0.24; 'skip:% 10': 0.24; 'file.': 0.24; 'header:In-Reply-To:1': 0.27; 'testing': 0.29; 'subject:) ': 0.29; 'xml': 0.29; 'url:mailman': 0.30; '-0700,': 0.31; 'font': 0.31; 'file': 0.32; 'probably': 0.32; 'checked': 0.32; 'stuff': 0.32; 'text': 0.33; 'open': 0.33; 'url:python': 0.33; 'running': 0.33; 'checking': 0.33; 'mac': 0.33; 'subject:the': 0.34; 'skip:s 30': 0.35; 'received:google.com': 0.35; 'url:support': 0.36; 'url:listinfo': 0.36; 'useful': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'virtual': 0.37; 'easiest': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'skip:o 30': 0.61; 'from:charset:utf-8': 0.61; 'first': 0.61; 'content- disposition:inline': 0.62; 'hints': 0.68; 'rendering': 0.68; 'jul': 0.74; 'received:178': 0.74; 'guaranteed': 0.75; 'skip:$ 10': 0.81; 'subject:get': 0.81; 'etc..': 0.84; 'fonts': 0.84; 'it\xe2\x80\x99s': 0.84; 'oh:': 0.84; 'subject:Platform': 0.84; 'do:': 0.91; 'url:tk': 0.95; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=9Q8YuwNfGd65SGwY+6lRRsE+7pvvsb2g2Yd8d92HXpY=; b=op9Y064g2hzygsb2TNxhebtZRqtKAYOsww2idOAmZf33dTkL8qYAuFdP359Ke+8BQN NeJHwzUmMQbDS8SwbbwmP4wueFsiwMdjh2DsAbkP4JHJ5hd3Sg83uwe9K/40HDqtj0hi 90Y9bgPW0yQvkOnIQCLcEJvsPVVdxmq7rak7X2y7K6i+TbPqfzgcT+Fgr+GQrMHhhJ0A 2lAqFI2/2U4sB8IiKtj5I1Q4y+Jr5rsa1pBhOUbiIVsgURBAl3u/k8bX6Yvw4ZcAc29D WDd7e2Ov7TiogNau1OAmW39NH/UMOp9pPD78NoHUY57KEnR8UE4J3S3atVyUT1eVCSDm sJaQ== |
| X-Received | by 10.204.228.207 with SMTP id jf15mr5830197bkb.16.1373559176946; Thu, 11 Jul 2013 09:12:56 -0700 (PDT) |
| Date | Thu, 11 Jul 2013 18:12:43 +0200 |
| From | Chris “Kwpolska” Warrick <kwpolska@gmail.com> |
| To | python-list@python.org |
| Subject | Re: How do I get the OS System Font Directory(Cross-Platform) in python? |
| References | <3d97de86-f690-40ad-aba8-972120af7ff3@googlegroups.com> <faa7fdb3-99e9-40ed-8a62-1df85d49edd4@googlegroups.com> |
| MIME-Version | 1.0 |
| Content-Type | multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jI8keyz6grp/JLjh" |
| Content-Disposition | inline |
| In-Reply-To | <faa7fdb3-99e9-40ed-8a62-1df85d49edd4@googlegroups.com> |
| User-Agent | Mutt/1.5.21 (2010-09-15) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4594.1373559184.3114.python-list@python.org> (permalink) |
| Lines | 70 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1373559184 news.xs4all.nl 15969 [2001:888:2000:d::a6]:60062 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:50462 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Thu, Jul 11, 2013 at 08:54:17AM -0700, Metallicow wrote:
> For a portable font install tool.
>
> Finding if a particular font exists,
> useful when testing apps in virtual environent,
> rendering text from a font,
> Font file manipulations,
> etc..
> --
> http://mail.python.org/mailman/listinfo/python-list
Then do a nice little `if` checking the user’s OS.
http://docs.python.org/2/library/sys.html#sys.platform hints what to use,
and you need to do:
if sys.platform.startswith('win') or sys.platform.startswith('cygwin'):
FONTDIRS = [os.path.join(os.environ['WINDIR'], 'Fonts')
elif sys.platform.startswith('darwin'):
# [see below and devise it yourself]
else: # linux, *bsd and everything else
# [see below, commit suicide and develop this bit]
Windows:
The easiest of those three, all the fonts are in %WINDIR%/Fonts.
In Python: os.path.join(os.environ['WINDIR'], 'Fonts')
Mac OS X:
http://support.apple.com/kb/ht2435 (and not all of them are
guaranteed to exist). `os.expanduser()` may be useful for
that first one.
Linux, and everything else running that fancy open stuff (eg. *BSD):
Hardcore. You just need to parse a nice tiny 155-line XML file.
It’s /etc/fonts/fonts.conf, and it has some <dir> tags.
Some of them may have a `prefix="xdg"` attribute which makes you
prepend the value with $XDG_DATA_HOME (~/.local/share if that is
empty). You also need `os.expanduser()`.
Oh: and you need to go recursively through them, as subdirectories
are also checked for fonts (and it probably goes further)
--
Kwpolska <http://kwpolska.tk> | GPG KEY: 5EAAEA16
stop html mail | always bottom-post
http://asciiribbon.org | http://caliburn.nl/topposting.html
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How do I get the OS System Font Directory(Cross-Platform) in python? Metallicow <metaliobovinus@gmail.com> - 2013-07-11 08:32 -0700
Re: How do I get the OS System Font Directory(Cross-Platform) in python? Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-07-11 17:48 +0200
Re: How do I get the OS System Font Directory(Cross-Platform) in python? Metallicow <metaliobovinus@gmail.com> - 2013-07-11 08:54 -0700
Re: How do I get the OS System Font Directory(Cross-Platform) in python? Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-07-11 18:12 +0200
Re: How do I get the OS System Font Directory(Cross-Platform) in python? Metallicow <metaliobovinus@gmail.com> - 2013-07-11 10:19 -0700
Re: How do I get the OS System Font Directory(Cross-Platform) in python? Christian Heimes <christian@python.org> - 2013-07-12 03:27 +0200
Re: How do I get the OS System Font Directory(Cross-Platform) in python? Metallicow <metaliobovinus@gmail.com> - 2013-07-11 21:24 -0700
Re: How do I get the OS System Font Directory(Cross-Platform) in python? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-12 04:55 +0000
Re: How do I get the OS System Font Directory(Cross-Platform) in python? Chris Angelico <rosuav@gmail.com> - 2013-07-12 14:58 +1000
Re: How do I get the OS System Font Directory(Cross-Platform) in python? Nobody <nobody@nowhere.com> - 2013-07-11 18:47 +0100
Re: How do I get the OS System Font Directory(Cross-Platform) in python? Metallicow <metaliobovinus@gmail.com> - 2013-07-11 11:25 -0700
Re: How do I get the OS System Font Directory(Cross-Platform) in python? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-07-11 20:13 -0400
Re: How do I get the OS System Font Directory(Cross-Platform) in python? Tim Roberts <timr@probo.com> - 2013-07-12 22:36 -0700
Re: How do I get the OS System Font Directory(Cross-Platform) in python? Metallicow <metaliobovinus@gmail.com> - 2013-07-12 23:38 -0700
Re: How do I get the OS System Font Directory(Cross-Platform) in python? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-13 07:20 +0000
csiph-web