473,837 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Probably over my head... Trying to get Font Names

I am attempting to extract the Font Names from the installed windows fonts.
I am having a heck of a time getting these rather than the file names.
Examples can be seen by going to Control Panel > Fonts

Any help or direction is appreciated.
S
Jul 18 '05 #1
11 4005
If you don't have a GUI library to use, TTFQuery+Fontto ols will retrieve
this information:

from ttfquery import _scriptregistry
fonts = _scriptregistry .registry.fonts .keys()
fonts.sort()
for name in fonts:
print name

if you do have a GUI, your GUI library will almost certainly have a
mechanism to retrieve the list of fonts. With wxPython, for instance,
it's called wxFontEnumerato r. If you just want the user to choose a
font, most GUI libraries already have controls/dialogues that can handle it.

TTFQuery is going out, reading the .ttf fonts with Fonttools and storing
their metadata in an index for faster access, whereas your GUI library
will be using a simple API call to retrieve the metadata. That means
TTFQuery is going to be heavier, but it can, for instance, also give you
information about fonts not installed on the system.

HTH,
Mike

TTFQuery:
http://ttfquery.sourceforge.net/
Samantha wrote:
I am attempting to extract the Font Names from the installed windows fonts.
I am having a heck of a time getting these rather than the file names.
Examples can be seen by going to Control Panel > Fonts

Any help or direction is appreciated.
S

_______________ _______________ _______________ ___
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com
PyCon is coming...

Jul 18 '05 #2
Thanks Mike. I must have not installed the ttfquery and font tools
correctly. I get an error. This error:

Traceback (most recent call last):
File "C:\Python24\Li b\font-getter.py", line 1, in -toplevel-
from ttfquery import _scriptregistry
File "C:\Python24\Li b\site-packages\ttfque ry\_scriptregis try.py", line 1,
in -toplevel-
from ttfquery import ttffiles
File "C:\Python24\Li b\site-packages\ttfque ry\ttffiles.py" , line 10,
in -toplevel-
from ttfquery import describe, findsystem
File "C:\Python24\Li b\site-packages\ttfque ry\describe.py" , line 2,
in -toplevel-
from fontTools import ttLib
ImportError: No module named fontTools

Like I said I think I am way in over my short head.
S
"Mike C. Fletcher" <mc******@roger s.com> wrote in message
news:ma******** *************** *************** *@python.org...
If you don't have a GUI library to use, TTFQuery+Fontto ols will retrieve
this information:

from ttfquery import _scriptregistry
fonts = _scriptregistry .registry.fonts .keys()
fonts.sort()
for name in fonts:
print name

if you do have a GUI, your GUI library will almost certainly have a
mechanism to retrieve the list of fonts. With wxPython, for instance,
it's called wxFontEnumerato r. If you just want the user to choose a font,
most GUI libraries already have controls/dialogues that can handle it.

TTFQuery is going out, reading the .ttf fonts with Fonttools and storing
their metadata in an index for faster access, whereas your GUI library
will be using a simple API call to retrieve the metadata. That means
TTFQuery is going to be heavier, but it can, for instance, also give you
information about fonts not installed on the system.

HTH,
Mike

TTFQuery:
http://ttfquery.sourceforge.net/
Samantha wrote:
I am attempting to extract the Font Names from the installed windows
fonts. I am having a heck of a time getting these rather than the file
names. Examples can be seen by going to Control Panel > Fonts

Any help or direction is appreciated.
S

_______________ _______________ _______________ ___
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com
PyCon is coming...

Jul 18 '05 #3
[Samantha: your email has been bouncing, might want to clear your inbox]

Samantha wrote:
Thanks Mike. I must have not installed the ttfquery and font tools
correctly. I get an error. This error:

....
ImportError: No module named fontTools

Like I said I think I am way in over my short head.
S

Does look as though you missed getting FontTools installed. You realise
it's a separate package from TTFQuery, right?

http://sourceforge.net/projects/fonttools/

You'll have to do the standard:

python setup.py install

to get it installed on your system.

HTH,
Mike

_______________ _______________ _______________ ___
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com
PyCon is coming...
Jul 18 '05 #4
Mike,
Not sure why that email bounced.
I downloaded these files:
WinTTX2.0b1.exe
TTFQuery-1.0.0.win32.exe
numarray-1.1.1.win32-py2.4.exe

They all seemed to install. Is WinTTX2.0b1.exe not the fontTools file?
S

"Mike C. Fletcher" <mc******@roger s.com> wrote in message
news:ma******** *************** *************** *@python.org...
[Samantha: your email has been bouncing, might want to clear your inbox]

Samantha wrote:
Thanks Mike. I must have not installed the ttfquery and font tools
correctly. I get an error. This error:

...
ImportError : No module named fontTools

Like I said I think I am way in over my short head.
S

Does look as though you missed getting FontTools installed. You realise
it's a separate package from TTFQuery, right?

http://sourceforge.net/projects/fonttools/

You'll have to do the standard:

python setup.py install

to get it installed on your system.

HTH,
Mike

_______________ _______________ _______________ ___
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com
PyCon is coming...

Jul 18 '05 #5
"Samantha" <sa**********@h otmail.com> wrote:
I am attempting to extract the Font Names from the installed windows fonts. I am having a heck of a
time getting these rather than the file names. Examples can be seen by going to Control Panel >
Fonts


here's one way to do it (using Tkinter):
import Tkinter, tkFont
tk = Tkinter.Tk()
tkFont.families ()

('System', 'Terminal', 'Fixedsys', 'Roman', 'Script', 'Modern', 'Small Fonts', 'MS Serif', ...)

here's another way (using PIL):

import os
from PIL import ImageFont

fontdir = os.path.join(os .environ["windir"], "fonts")

for fontfile in os.listdir(font dir):
try:
font = ImageFont.truet ype(os.path.joi n(fontdir, fontfile), 1)
except IOError:
pass
else:
print font.font.famil y, font.font.style

(this prints a list of family/style combinations). You can get PIL from

http://www.pythonware.com/products/pil/ (1.1.4)
http://effbot.org/downloads/#pil (1.1.5 betas)

</F>

Jul 18 '05 #6
Samantha wrote:
Mike,
Not sure why that email bounced.

That last one bounced too, btw.
I downloaded these files:
WinTTX2.0b1.ex e
TTFQuery-1.0.0.win32.exe
numarray-1.1.1.win32-py2.4.exe

They all seemed to install. Is WinTTX2.0b1.exe not the fontTools file?

I believe WinTTX is a font-editing program from which fontTools was
split out into a separate project.

As well, though I don't *know* that this will cause problems, I'd
thought fontTools required Numeric (Numpy) rather than Numarray. Would
try the fontTools package first with the Numarray you've installed, and
if you then find problems with it not being able to find Numeric,
install the Numpy release.

HTH,
Mike

_______________ _______________ _______________ ___
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com
PyCon is coming...

Jul 18 '05 #7
"Samantha" <sa**********@h otmail.com> wrote in message news:<B8******* *************@a delphia.com>...
I am attempting to extract the Font Names from the installed windows fonts.
I am having a heck of a time getting these rather than the file names.
Examples can be seen by going to Control Panel > Fonts

Any help or direction is appreciated.
S


Try this :

Python 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright" , "credits" or "license" for more information.
from Tkinter import Tk
import tkFont
root=Tk()
print tkFont.families (root)

Jul 18 '05 #8
Thanks Fredrik,
The Tkinter method didn't give any results but using PIL did. I'll have to
play with it a little.
Thanks again,
S
"Fredrik Lundh" <fr*****@python ware.com> wrote in message
news:ma******** *************** *************** *@python.org...
"Samantha" <sa**********@h otmail.com> wrote:

Jul 18 '05 #9
Mike,
Strange Hotmail.
I'll start over with the installs and you are correct on it being Numpy. I
got the wrong file.
I'll give it a go and let you know.
Thanks!!!!
S
"Mike C. Fletcher" <mc******@roger s.com> wrote in message
news:ma******** *************** *************** *@python.org...
Samantha wrote:

Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4303
by: Eric | last post by:
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works fine, however, when the checkbox is only field that has been modified/clicked the form doesn't always submit. When it does work, a Stored procedure is passed form variables and updates to the db are made. When it doesn't, its as if the form wasn't submitted, it reloads and resets the page, but...
1
4127
by: Robert Muchacki | last post by:
Hello all! I'm fighting with this little problem. I'm trying to retrieve data from a table in SQL Server 2k. I'm dead. The only result I get is retrieving the headers of the columns - no data in it actually :/ I'm probably missing something on the way. Could somebody explain me how do I get data and even WHERE I should retrieve it to? Explain like to an idiot - really. Greets,
4
1215
by: Paul | last post by:
Hi, noticed high activity on this newsgroup as the last few posts I have made have not received a response. Anyhow I noticed that with a .NET web application when the webform opens if the user hits the tab key it goes to the address bar at the top of the browser. I would like it to go to a control and have set the tab index to 0 and 1 but still goes to the address bar. Thanks. -- Paul G Software engineer.
2
1292
by: androoo | last post by:
Hi I am learing how to use the grid in asp.net. Im trying to replace the button columns with nice friendly images. So : <asp:ButtonColumn Text="Delete" CommandName="Delete"></asp:But≠tonColumn>
1
2025
by: Neal | last post by:
Bit puzzling, This Style works in some IE browsers (all are at least 5.50) , some not however. ie style="FILTER:progid:DXImageTransform.Microsoft.Gradient(startColorstr='skyBlue',endColorstr='DarkBlue');LEFT:0px;OVERFLOW:hidden;WIDTH:1447px;POSITION:absolute;TOP:0px;HEIGHT:75px"> I Would like to know why. (Other browsers don't seem to like it at all either, if there are any indications why I would appreciate it)
2
6576
by: Patti | last post by:
I am building an application using VB.NET 1.1 and I have an issue with Font properties in my Radio Button Lists and Check Box Lists. My issue is that the Font Names and Font Size for these controls have become "Read Only" and I have no idea how they became read only. I didn't set anything to read only and was able to change these fonts just last week - so I must have messed something up. Below is a snippet of my HTML code I used...
1
1629
by: comp.lang.php | last post by:
Consider my code: /** * Set the TTF array property $ttfArray * * @access private * @see actual_path */ function &setTTFArray() { // STATIC VOID METHOD
0
1120
by: dengel | last post by:
I'm a classic ASP/VbScript user, transitioning to c# and .NET. I'm making a little PW change utility which does this: 1. User inputs an email address/username (into a textbox) 2. User inputs their current Password(into a textbox) 3. User presses a submit button 4. Server checks the value of the text in the currentPassword textbox against the user's stored password in the DB. If they don't match, then it displays an error. 5. Else, a...
14
2835
by: Roedy Green | last post by:
Is there a shortcut way to define the default font family (and characteristics) to be applied to all styles? -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
0
9833
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
10562
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10617
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10263
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6989
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5666
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5842
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4469
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3122
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.