Page 1 of 1

High Level Language for Hinting

Posted: Thu Jun 30, 2005 7:22 pm
by johnmcork
High Level Language for Hinting

Hi all

Given previous postings, auto-manual hinting is popular, but as one member remarked, hinting language are such a BLANK that its doubtful that anyone would use them. I check a specification and I see the point. Also, I’m working with Gold parser generator and am about to start writing some code and a high level font hinting language could make a useful “contrasting” language as part of the project.

So, any opinions but like deeper “than that’s a good idea.” The first step would be to produce the grammar working back from how you would like to write the code, and that’s probably an education in itself :shock: .

John Cork

Posted: Fri Jul 01, 2005 6:06 pm
by William
I have had a look at your post and indeed looked up Gold parser generator at yet I have not, as yet, mangaed to undestand what it is that you are seeking to achieve.

For example, if the High Level Language for Hinting which you suggest were produced, how would it be used?

For example, would someone who makes fonts using Font Creator 5.0 and has produced a file A.TTF, then write a program in High Level Language for Hinting using a text editor such as WordPad to produced a file B.TXT, and then run a yet-to-be-produced .exe executable program Z.EXE with three parameters namely A.TTF, B.TXT and C.TTF so as to produce a new file C.TTF which has the glyphs of A.TTF together with hinting information?

You write "am about to start writing some code": is that to produce Z.EXE as above, or what?

I may well have speculated wide of the mark above, but please know I am interested to know what this project is about and hopefully learn in the process.

> The first step would be to produce the grammar working back from how you would like to write the code, and that’s probably an education in itself.

In "how you would like to write the code", does "you" mean "a person with an unhinted font who would like it to become hinted" or does "you" in that context mean someone else?

William Overington

Posted: Sat Jul 02, 2005 8:40 am
by William
I have been studying this matter further this morning and have found that looking for "hinting language" at is interesting.

One link I found is as follows.

It appears that TrueType has a hinting language which is a low level construct with a virtual machine with a stack-based architecture. I remember using a language with a stack-based architecture many years ago, nothing to do with fonts, a language named FORTH. It is an interesting language. Originally it only had integer data. A 2 would push the number 2 onto the stack. A 24 would push 24 onto the stack. A + would pop the top two numbers from the stack, add them and push the result onto the stack. Thus 2 24 + would end with 26 on the stack. A DUP would duplicate the top item of the stack, so that 3 DUP * would end with 9 on the stack as after the DUP had been obeyed the stack would have 3 3 on it and the * would pop the top two numbers from the stack, multiply them and push the result onto the stack.

I have also used high level languages such as FORTRAN, Pascal and, to a small extent, Java. They are certainly easier to program for many applications, though FORTH does have its uses, I seem to remember that it was originally devised for controlling stepper motors at an observatory so that a telescope which was moved using stepper motors could be more readily commanded to move from one position to another position.

So, it appears that in this thread is being suggested a high-level language which can be compiled using a specially produced compiler program to produce commands in the stack-based hinting language.

It appears that the hinting language exists because various font designers have various opinions on how a font should be hinted.

So, it appears that the first stage is to understand how the hinting language works. After that we need to discuss how the things which we would like to do in the hinting language can be expressed in a more user-friendly manner.

That sounds fascinating, because the high-level language need not necessarily be like a programming language like Pascal, it could have features specific to the needs of font hinting. An interesting project with potentially far reaching possibilities for font design.

I am now going to try to find out the specification of the hinting language and of its virtual machine. Hopefully these are available on the web.

In relation to the post which starts this thread, I am still puzzled by the meaning of the phrase a useful "contrasting" language.


Posted: Sat Jul 02, 2005 9:12 am
by William
I searched for hinting language specification at and found the following web page. ... rview.mspx

At the bottom of that page, at the left is the following.


TrueType Specification
The TrueType 1.66 specification is provided here in Word format for historical purposes.

end quote

Is this 1.66 specification what we need for learning how to do the hinting or do we need something from the OpenType specification at the right of the page please?

In looking at the hinting language search results I found the following. ... fault.aspx

This is from the June 2005 issue of MSDN magazine. This refers to ClearType technology.


Many of the problems associated with displaying readable type on the screen are dramatically reduced by ClearType®, which Bert Keely, Greg Hitchcock, Mike Duggan, and I invented back in 1998. Font hinting has become simpler in many ways, and now needs a lighter touch.

end quote

After that quote the article continues as follows.


ClearType has evolved a lot over the years, and the latest and best version of it will ship as part of "Avalon," the code name for the presentation subsystem class libraries in WinFX. When the next version of Windows, code-named "Longhorn," ships, it will contain seven new fonts, specially designed to take maximum advantage of ClearType. There will be six new fonts for Latin-based languages—including a brand-new monospaced font, Consolas, designed to make your lines of code much easier to read. They've been created by some of the world's top font designers, and hinted to the highest standards possible.

end quote

I had not known of ClearType existing before reading that, so I am at present uncertain as to how, if at all, it relates to the project to design a high level language.


Posted: Sat Jul 02, 2005 1:02 pm
by johnmcork
reply to first posing will read others now

WILLIAM WROTE “I am interested to know what this project is?”
FIRST TECHNO-SYNCH so we are using the same meaning of the terms.
Commonly we use a programming language to write programs that a computer can execute. Examples: a program to controls a CNC milling machine, a database, a web browser and Font Creator. The four “text book” representations are:
1. The source code in say C++,
2. The intermediary representation in some abstract generic machine code,
3. The processor’s machine code that gets executed,
4. Below that the processor’s control unit contains micro-code that executes primitives for each instruction such as setting the ALU code, loading registers, fetching the next instruction.
A CNC milling machine includes a process to read CNC data but if the machine were a robot we would have a different language to tell the robot what to do and the program controlling the robot would execute a program written in this language.
SQL is a language we use to manipulate databases and again the database program not the processor executes SQL programs.
HTML is a “mark up” language that describes the way text, tables etc are rendered on the screen and the web browser not the processor executes it. Web browser also includes a virtual machine that executes applets written in Java. The VM executes the Java intermediary representation but may have a JIT compiler so the processor can execute the program directly.
A “text book” compiler-compiler is a tool that takes a grammar and semantic for a new language, and generates the source code framework for the new language’s compiler in C++. You add to and compile that source code on a C++ compiler, and get the compiler for the new language.
Gold Parser generator (www devincook com) is different. It takes a grammar and in effect generates the micro-code (state machine tables) for a generic parser engine. This means that you can take the parser engine pseudo code as a guide and write your own engine in a language of your choice and not be limited to the normal C/C++ compiler-compiler implementations. More interestingly, you can mix source languages such as ad hoc to-this-need languages like LISP, Prolog with engineering languages such as C++ for the application framework. Add a virtual machine and you can build an application with an integral scripting language.
My project is to develop the virtual machines and other tools and in particular add diagrammatic languages. There is a lot of background work gone into this, not least of which is the fundamental theory that guarantees that the intermediary representation is truly Turing Complete, which means that the term Turing Complete must have an exact definition.
In preparation, I used Font Creator to produce a set of connection point symbols. I got to the hinting stage, found a specification, I think on the Apple site, opened, read a bit, found the language and went Ahhhh I’ll leave this to latter.
My understand is; the hinting code is a language that is executed by the font rendering engine, like a database executes SQL code and the web browser executes HTML code. The hinting code is not a regular executable or a separate entity, rather it is embedded into the font.
WILLIAM WROTE “how would it be used?”
There are two possibilities.
First create a new font. Right mouse click on a glyph and edit. Draw the glyph as with Font Creator. You also do other things like add the postscript name and edit the code mapping. Say we now have the complete font created and tested.
Then you could right mouse click on a glyph and select “add hinting” which is the imaginary extra menu item (that Font Creator developers added to the context sensitive men.) This would invoke the hinting language editor (that I helped write.) This language editor would have a text editor with syntax highlighting and IF it had a visual view to give the designer some clue as to the results of his hitting THEN it would also require a rendering simulator.
The second possibility is that it could be a stand alone executable. In either case there is only one font file for each font. Actually you would have courier.ttf and courier-temp.ttf during the design and courier.ttf and courier-original.ttf after be design.
Obviously the language requires a set of common features such as
“class Glyph” to represent the data properties of a glyph including the vertices and edges of the outline and mapping and glyph name. And standard operators (+, -, * /) and flow control such as while and switch.
The questions for the experienced font developer are “what else would you like to see” as you dream about using it. Then I can back translator that into a grammar.
It’s a challenge and sufficiently different to demonstrate the benefits of a minimal standard intermediary language representation (part of my project). The target (a font file) will has a format that is significantly for a normal program and as such is a reminder to me not to assume things in my code. So there are issues that are valuable to me as a test case project.

Posted: Sat Jul 02, 2005 1:41 pm
by johnmcork
You got it.
“contrasting” you understood it, you wrote “it would not necessarily be like Pascal.”
Do not worry about virtual machine. Nearly all hardware machines require the translation from y = a + b to ab+y= and a stack just makes the language easier to translate to machine code. Check for details of theory behind a universal Turing machine and which defines a stack as a feature of a Turing Complete machine. “Do not worry about virtual machine” because my intermediary and VM will be a minimal high level language and not a some abstraction of a real processor. That stack stuff is only introduced at the back-end code generation for some other target that could be a Java VM. Again my VM will execute y = a + b and will not require translation to ab+y=.
True type - Clear type – Open type
I will check your references later. I am in your hands when it comes to font standards and specifications. I read that Apple had something to do with true type. In general we need a standard specification for a non-deprecated base standard for the font file format and hinting language, which (I think) is true type.

Posted: Sun Jul 03, 2005 8:34 am
by William
Thank you for your posts.

I notice that you wrote the following.


In preparation, I used Font Creator to produce a set of connection point symbols. I got to the hinting stage, found a specification, I think on the Apple site, opened, read a bit, found the language and went Ahhhh I’ll leave this to latter.

end quote

You might perhaps find the following two threads of interest.

The thread "Loss of Clarity of Fonts" in the Discussion forum.


The thread "Spacing problem for symbol font" in the Support forum.