Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programming library for editing ttf fonts [closed]

Tags:

fonts

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!

like image 230
clamp Avatar asked Oct 07 '11 11:10

clamp


3 Answers

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.

like image 158
Boojum Avatar answered Nov 17 '22 18:11

Boojum


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.

like image 36
rbrito Avatar answered Nov 17 '22 17:11

rbrito


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

like image 38
Pauls Avatar answered Nov 17 '22 17:11

Pauls