Writing a Python font viewer/manager

B

Bats

Hello.
On Windows, I used to have a little app that would let me navigate visually
through my 20,000+ fonts and I could create groups of them for quick
install/remove from the system. It was great to be able to type in a word
(say for a logo) and then see it in all the fonts.

I would like to write something similar for Linux (and maybe it'll work on
others) in Python.

I am not really a pro - this would be my first significant Python attempt
and I was wondering if anyone had any pointers.

I have looked at the demos for WxPython - it looks quite good. It crashed
badly on an example where you can drag playing cards around. I tried to
drag the font (or the text) and it hung, not a good sign!

I see that KDE has a way to see ttf files - is there a way to get at that
control via PyQT?

Is an HTML control of some kind the way to go?

It should be able to list hundreds of font samples and allow one to scroll
through them. Being able to 'select' a font by clicking the visual would
also be good.

Any thoughts would be great.
 
M

Maciej Dziardziel

Bats said:
Hello.
On Windows, I used to have a little app that would let me navigate
visually through my 20,000+ fonts and I could create groups of them for
quick install/remove from the system. It was great to be able to type in a
word (say for a logo) and then see it in all the fonts.

Perhaps take a look at gfontview - not python app, but may show you how to
access fonts.
 
J

Jaime Wyant

The code below works in windows. I assume it works in linux also.

The code illustrates how to create a "font-picker". If you want
something more advanced, you could roll up your sleeves and create
your own. It wouldn't be too bad. Check out wx.FontEnumerator.
wx.FontEnumerator will enumerate the fonts on your system (duhhh...)

import wx

app = wx.PySimpleApp()
dlg = wx.FontDialog(None, wx.FontData())
if dlg.ShowModal() == wx.ID_OK:
fontdata = dlg.GetFontData()
font = fontdata.GetChosenFont()
wx.MessageBox("You chose the `%s' font." % font.GetFaceName())
else:
wx.MessageBox("You pressed cancel and didn't choose any fonts.")

app.MainLoop()

HTH,
jw
 
B

Bats

Jaime Wyant had this to say:
The code below works in windows. I assume it works in linux also.

The code illustrates how to create a "font-picker". If you want
something more advanced, you could roll up your sleeves and create
your own. It wouldn't be too bad. Check out wx.FontEnumerator.
wx.FontEnumerator will enumerate the fonts on your system (duhhh...)
Thanks for that code. I am still new to wx and guis via Python.
The area that actually displays the font - is that a 'control' or something
I can directly work with? Maybe it can be made longer, have a scroll-bar
and show multiple lines of differing fonts - something like that?

Any QT suggestions?
 
B

Bats

Maciej Dziardziel had this to say:
Perhaps take a look at gfontview - not python app, but may show you how to
access fonts.
Thanks - I will look at it. Would like to do my own anyway, but it'll be
interesting ;)
 
B

Bats

Well, I feel a little stupid - I just found /usr/share/docs/PyQt-examples/
and in there I found some font examples - at least I have something to hang
my hacking on now.

Cheers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,209
Messages
2,571,089
Members
47,689
Latest member
kilaocrhtbfnr

Latest Threads

Top