0

As the title suggests, I want to build a software that can read .ttf and .otf files and then allow user to adjust the kerning, character widths and character spacing. I know about the project freetype but it is written in C and I can code only in C# and Python. How difficult is it to code the .otf and .ttf logic?

Thanks Morph

Morpheus
  • 3,285
  • 4
  • 27
  • 57
  • 1
    Seriously good luck with that! It is really really difficult. And to elaborate, try to accurately read the meta data of any .otf/.ttf and if you find a way, please let us know. – rantanplan Nov 02 '12 at 12:09
  • @rantanplan That definitely dampened my spirits but thanks anyway – Morpheus Nov 02 '12 at 12:16
  • I'm really sorry, but I just want to save you precious time :) Being there and it was a freaking hell. But you could try and read the specs for ttf/ps/otf standard and see for yourself. – rantanplan Nov 02 '12 at 12:18

1 Answers1

3

You asked how hard it is to write software to read TrueType (.ttf) and OpenType (.otf) files, allowing adjustment to kerning, character widths, and character spacing tables. Well, I'll tell you. It's difficult.

Microsoft Typography's The OpenType Font File is a good introduction to the high-level structure of TrueType and OpenType font files. The internal structure is of some global indexing and checksum fields, followed by a number of "tables", each with their own internal structures. You will need to write code to unpack this global structure, parse and modify the tables you want to change, then rebuild the global structure and recompute checksums.

To let your users modify kerning, character widths, and character spacing, you will probably need to modify at least the kern, hmtx, and gpos tables. Changes to these tables may affect values in other tables.

Furthermore, text engines and application software have their own expectations for the contents of an OpenType or TrueType font. These interactions are complex and not always well documented. I expect all capable, reliable fonts which work with demanding text layout software have details about their contents which reflects a great deal of know-how and painful experience.

If you think learning the C language in order to use existing freetype code is hard, just wait until you try debugging why fonts modified by your tools won't work in your text layout software.

You don't say what kind of modifications you want to make to the fonts. Why not buy existing software, instead of making your own? There exists application software, like FontLab's TypeTool, which might let you do all the editing of kerning, character widths, and character spacing which you need. Sure, it costs money, but consider how much your time is worth, and how much time it will take you to make your code work sufficiently well to meet your needs.

If you really want to go ahead with writing your own code, you may find the Adobe Font Development Kit for Opentype (AFDKO) useful. Good luck.

Jim DeLaHunt
  • 10,960
  • 3
  • 45
  • 74