16

I am looking for a library that allows me to edit true type fonts.

basically i want to replace certain glyps with my custom vector graphics programmatically/

the language doesnt matter so much, i'm pretty flexible.

thanks!

3 Answers 3

13
+50

If you don't mind Python, there are a couple of good possibilities

I'd suggest having a look at FontForge. It can be built both to embed a Python interpreter, and to run as a library from within Python. Another nice feature is that its native file format, the spline font database is ascii and fairly well documented and quite easy to manipulate with your own programs.

Another alternative that I have less experience with is TTX and TTLib. The later is a Python library and the former is wrapper around it which roundtrips TTF to XML and back.

3
  • thanks i have been looking into fontforge already, but my python skills are limited. what i need to do is mass replacing certain glyphs with others (coming from SVGs) in many fonts.
    – clamp
    Commented Oct 18, 2011 at 7:44
  • 1
    Fontforge may still be the easiest, then. It shouldn't be more than five lines of Python each way (with numerous examples - see rbrito's links) to convert to and from TTF and SFD. Once in SFD, the description of the glyphs isn't too dissimiliar from SVG: move to, line to, curve to, etc. You should be able to rewrite the SFD with the converted glyphs using any language you'd like. (If you do learn Python, though, FF already has tools to import the SVG for you.)
    – Boojum
    Commented Oct 18, 2011 at 9:01
  • The link for TTX is dead. It should probably be changed to this PyPI project. Note that "TTLib" seems to be a component within FontTools; it's probably best to refer to FontTools unless specifically talking about that particular piece of FontTools.
    – John Y
    Commented Sep 28, 2018 at 16:17
9

As you are flexible with regard to the programming language, you can use Fontforge, like @Boojum said, and you will have available to you two interfaces: both its native language (called in the manual the "legacy" interface) and a python interface that is very carefully detailed.

Fontforge is available in many Linux distributions, including Debian and Ubuntu, among others (disclaimer: I am a member of the team that maintains fontforge in Debian, and, by transition, in Ubuntu).

It is also available for Macs and, perhaps, Windows, but I'm not sure if they are available as ready, built executables.

OK, back to Fontforge.

Fontforge is able to read and write fonts in many formats, and, its "native" format (called Spline Font Database) is a plain-text format that is very easy to read and manipulate with a text editor, if you do that carefully.

From the programming side, you can see a very basic Python script that creates an OpenType font from a spline font database file (SFD) with the script listed at https://github.com/rbrito/urw-garamond/blob/master/scripts/generate.py. But fear not: the very same way (functions) that you use to read an SFD file is the way that you would read a TrueType, OpenType, Postscript etc. font.

As another example of a simple manipulation of fonts, you can see one script that takes a font as input and creates a slanted version of that font: https://github.com/rbrito/urw-garamond/blob/master/scripts/to-slant.py.

Regarding "learnability", you have plenty of projects that make their scripts available and you can easily learn by example from them. For example, the DejaVu project and Barry Schwartz's sortsmill scripts.

So, only your creativity is the limit.

2
  • thanks i have been looking into fontforge already, but my python skills are limited. what i need to do is mass replacing certain glyphs with others (coming from SVGs) in many fonts.
    – clamp
    Commented Oct 18, 2011 at 7:43
  • @clamp, I only noticed this comment of yours now. If you need assistance, please let me know and I will try to help.
    – rbrito
    Commented Jan 29, 2014 at 3:03
1

This website allows you to add your svg, edit them, or include more and then export it as a Font, choosing name size etc.

https://icomoon.io/app/#/select/font

Not the answer you're looking for? Browse other questions tagged or ask your own question.