By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,106 Members | 2,474 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,106 IT Pros & Developers. It's quick & easy.

Tkfont.families does not list all installed fonts

P: n/a
Hi,

I have installed a truetype font (.ttf) on a linux machne (SUSE linux
10, KDE) by copying it to my .fonts folder. I can use the font in all
applications like open-office and firefox browser.

However, I cannot use the font in a python app that I am writing. The
list returned by Tkfont.families does not contain this particular font.

Any suggestions ?

Regards,

May 8 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 7 May 2006 23:55:05 -0700, Atul <at*******@gmail.com> wrote:
Hi,

I have installed a truetype font (.ttf) on a linux machne (SUSE linux
10, KDE) by copying it to my .fonts folder. I can use the font in all
applications like open-office and firefox browser.

However, I cannot use the font in a python app that I am writing. The
list returned by Tkfont.families does not contain this particular font.


I don't know the Suse distro, but it seems on "modern" Linux
distributions, there are 2 levels of font support: the first is the
"native" X support, the second is provided by the graphical toolkit you're
using (Qt with KDE, but I think OpenOffice & FireFox use Gtk).
Unfortunately, tk - and therefore Tkinter - only sees the fonts at the X
level, and not those at the Qt/Gtk level. But apparently, dropping your
font file in your .fonts directory only makes the font available for
Qt/Gtk, not for X. You can check that by running the command xlsfonts in a
terminal: I really suspect your font will not appear in the list.

To make the font visible at X level, you should make your .fonts directory
a component of the X font path:
- Go to your .fonts directory.
- Check if the directory contains file named fonts.dir; If it does, check
that the file contains a line referencing your .ttf file. If it does, skip
the next 2 steps.
- Create the fonts.scale file describing your TrueType fonts; this is done
via a distribution-dependent utility, usually mkfontscale or ttmkfdir.
- Create the fonts.dir file describing all the fonts in the directory by
running mkfontdir in it.
- Add the directory to you X font path by running the command: xset +fp
~/.fonts

This last step is for testing purposes only, since its results won't
survive your X session. You'll have to find a way to do it each time you
log to your session, or each time your X server is restarted. You may also
add your font file to a global font directory so that X will automatically
see it when it starts (you'll have to rebuild the fonts.scale and
fonts.dir files as above).

HTH
--
python -c "print ''.join([chr(154 - ord(c)) for c in
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
May 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.