freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Freetype] TrueType Font implementation query


From: Antoine Leca
Subject: Re: [Freetype] TrueType Font implementation query
Date: Wed, 23 May 2001 12:22:18 +0200

Sam Chapman wrote:
> 
> The glyf table headers, (offset by the 'loca' table), are clear enough the
> confusion I have is with the Glyph description.
> 
> Simple cases are defined as so.
> 
> Type                    Name
> USHORT          endPtsOfContours[n]     n is the number of contours.
> USHORT          instructionLength
> BYTE            instructions[n]         n is the number of instructions.
> BYTE            flags[n]                n is the number of flags.
> BYTE or SHORT   xCoordinates[ ]
> BYTE or SHORT   yCoordinates[ ]
> 
> Knowing the number of contours it is possible to size and extract the first
> and second components. This then allows the instructions themselves to be
> loaded. The number of flags is currently unknown to me (so where do I get
> this value?).

First, as Just explained, flags are stored as a compressed array; and the
only way to know the number of elements in the stored array... is to walk
along the whole array, to look after each "repeated" flag, to get the next
byte, and to repeat the said flag in the expanded array.

Now, what you are asking is how to know when we are done? The answer is,
you are done when there are enough flags in the expanded array. And
"enough" is defined as the content of the last element of the
endPtsOfCountours array, i.e. the total number of points (except the 2/4
phantom points that represent the metrics).


> Any pointers would be appreciated.

In addition to a careful review of Freetype code (!), I can direct you
to Just's implementation, contained in his excellent FontTools package,
written in Python.

;-)


Antoine



reply via email to

[Prev in Thread] Current Thread [Next in Thread]