473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

getting ttf font/family name; fontTools?


I would like to extract the font and family name from a TTF file. I
have been looking at fontTools ttLib, which parses the ttf file and
provides lots of helpful information, but cannot find the name.
from fontTools import ttLib
tt = ttLib.TTFont("cour.ttf")
tt['head'] seems like a good place to find it, but I can't.

The data appear to be in the 'name' field
s = tt.getTableData('name')
s.find('Courier')

4197

But I still don't know how to extract this information if I don't know
the family/font name in advace. Any ideas on how to best extract this
info using fontTools or otherwise?

What I am trying to do is find the best ttf font file for a given
fontname, fontangle, and fontweight. I plan to write my own font
finder given a font name and font family from the ttf file, but if
there is a better way to find ttf fonts let me know. Eg, what I want
to do is

ttfile = findfont('Courier', 'Italic', 'Bold')

and have findfont search some PATH containing TTF files and return the
closest match, or a default if no good match is found.

Thanks,
John Hunter

Jul 18 '05 #1
0 2817

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

Similar topics

11
by: Samantha | last post by:
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 >...
15
by: middletree | last post by:
How do I request the actual page name that I'm on? This is going to go into an include file, and depending on which page I'm on, I'd like to do different things. I'm looking for "pagename.asp"
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
2
by: Melisa | last post by:
Hi, I am trying to list all font families in a combo box control. But all font families does not support all font styles . How can i get the list of all font style and font size supported by a...
9
by: Dr. Locke Z2A | last post by:
So I'm writing a bot in python that will be able to do all kinds of weird shit. One of those weird shit is the ability to translate text from one language to another, which I figured I'd use google...
1
by: Dancina | last post by:
String x=""; Vector DatesFrom = (Vector)session.getAttribute("REPORTDATESFROM"); int isize = vRptDatesFrom.size(); Vector DatesTo = (Vector)session.getAttribute("REPORTDATESTO"); int isize2...
14
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
2
by: kheitmann | last post by:
OK, so I have a blog. I downloaded the "theme" from somewhere and have edited a few areas to suit my needs. There are different font themes within the page theme. Long story short, my "Text Posts"...
1
by: neovantage | last post by:
Hey, I have read an email template and sending emails through php mail function. It shows html code when i open that received email in outlook express but it shows normal content in hotmail, yahoo,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.