Contains objects definitions used in the FreeType (TrueType) library.

The four important objects managed by the library are:

Face
  The object for a given typeface.
Instance
  The object for a given pointsize/transform in a typeface.
Context
  The object for a loading/hinting execution in a typeface.
Glyph
  The object for a given glyph (outline and metrics).

A Face object is described by a TFace record, and its associated sub-tables. It is created through a call to the 'TT_Open_Face' API.

An Instance object is described by a TInstance record, and sub-tables. It is created for a given face through a call to the 'TT_Open_Instance' API. Several instances can share the same face.

The point size and/or transform of a given instance object can be changed on the fly through a call to the 'TT_Reset_Instance' API.

A Glyph object is used to describe a glyph to the client application It is made of a TGlyph_Record header, with several sub-tables used to store, for example, point coordinates or outline info. It can hold metrics information and other attributes, as well as the glyph's outline. A client application can request any kind of info to the library on a given glyph through the 'TT_Get_Glyph' call.

A Context is described by a TExec_Context record, and sub-tables Execution contexts are created on demand during the following operations:

- Creating a new instance (to read and execute the font program).
- Setting/resetting the point size (to execute the CVT program).
- During glyph loading (when hinting is on).

They are used to run TrueType instructions and load/store glyph data that are not part of the Glyph object ( as they're of no meaning to a client application ).

The library keeps track of all objects related to a given face.

A face's instances are kept in two linked lists: one is the 'active' list, which tracks the face's current opened instances, while the other is the 'idle' list used to collect/recycle instance objects when they become unuseful after a 'TT_Close_Instance' call.

In the same way, a face's execution contexts are kept in two similar lists. Note that, as contexts are created on demand, the active and idle contexts lists should always contain few elements.

Look also for the following files:

Face manager
  TTFace.pas
Instance manager
  TTInst.pas
Context manager
  TTExec.pas
Glyph manager
  TTGlyph.pas

Pointer to a TGraphicsState record type.
Graphics State.

The Graphics State (GS) is managed by the instruction field, but does not come from the font file. Thus, we can use int data types where needed.

Maximum number of code ranges.

There can only be 3 active code ranges at once:

- The Font Program
- The CVT Program
- The glyph instructions set

Defines a code range.

Code ranges can be resident to a glyph (i.e. the Font Program), while some others are volatile (Glyph instructions). Tracking the state and presence of code ranges allows function and instruction definitions within a code range to be forgotten when the range is discarded.

Defines a code range.

Code ranges can be resident in a glyph (i.e. the Font Program), while some others are volatile (Glyph instructions). Tracking the state and presence of code ranges allows function and instruction definitions within a code range to be forgotten when the range is discarded.

Defines a function / instruction definition record.
In which code range is it located?
Where does it start?
Function number or instruction code.
Is the entry active?
Defines a call record used to manage function calls.
Defines a simple call stack.
Original (scaled) coordinates.
Current coordinates.
Rounding function, as used by the interpreter.
Point displacement along the freedom vector routine, as used by the interpreter.
Distance projection along one of the proj. vectors, as used by the interpreter.
Reads a CVT value.
Take care of non-square pixels when needed.
Setting or Moving a CVT value.
Take care of non-square pixels when needed.

A note regarding non-squared pixels:

(This text will probably go into some docs at some time, for now, it is kept there to explain some definitions in the TIns_Metrics record).

The CVT is a one-dimensional array containing values that control certain important characteristics in a font, like the height of all capitals, all lowercase letter, default spacing or stem width/height.

These values are found in FUnits in the font file, and must be scaled to pixel coordinates before being used by the CVT and glyph programs. Unfortunately, when using distinct x and y resolutions ( or distinct x and y pointsizes ), there are two possible scalings.

A first try was to implement a 'lazy' scheme were all values were scaled when first used. However, some values are always used in the same direction, and some other are used in many different circumstances and orientations.

I have found a simpler way to do the same, and it even seems to work in most of the cases:

- All CVT values are scaled to the maximum ppem size.
- When performing a read or write in the CVT, a ratio factor is used to perform adequate scaling.

Example:

x_ppem = 14 y_ppem = 10

We chose ppem = x_ppem = 14 as the CVT scaling size. All CVT entries are scaled to it.

x_ratio = 1.0 y_ratio = y_ppem/ppem (<1.0)

We compute the current ratio like:

- if projVector is horizontal, ratio = x_ratio = 1.0
- if projVector is vertical, ratop = y_ratio
- else, ratio = sqrt( (proj.x*x_ratio)**2+(proj.y*y_ratio)**2 )

Reading a CVT value returns:

ratio*cvt[index]

Writing a CVT value in pixels:

cvt[index]/ratio

The current ppem is simple:

ratio*ppem
For non-square pixels.
For non-square pixels.
Flag value.
Flag value.
The FreeType Face object.
Input / output stream.
TrueType collection header.
TrueType collection header, if any was found.
Maximum profile table.

Maximum profile table, as defined by the TrueType Specification.

Note:

It seems that some maximum values cannot be taken directly from this table, but rather by combining some of its fields ( e.g. the max. number of points seems to be given by MAX(maxPoints, maxCompositePoints).

For this reason, we define later our own max values that are used to load and allocate further tables.

The font header.

The font header as defined by the TrueType Specification.

The horizontal header.

The horizontal header, as defined in the TrueType specification.

Set to true when vertical data is in the font.
Vertical header table.
OS/2 table.
Postscript table.
Horizontal device metrics table.
Name table.

The directory of the TrueType tables found in this face's stream.

The directory of character mapping tables found in the typeface.

The glyph locations table.

The font program, if any.

The CVT (or 'prep') program, if any.

The original, unscaled control value table.

Total number of glyphs in the typeface.

The value must be set by the maximum profile loader.

Maximum number of glyph points, simple and composite.

The value must be set by the maximum profile loader.

Maximum number of glyph contours, simple and composite.

The value must be set by the maximum profile loader.

Maximum number of components in a composite glyph.

The value must be set by the maximum profile loader.

The list is used to track active instance and context objects, as well as to recycle them. See TTLists.

The list is used to track active instance and context objects, as well as to recycle them. See TTLists.

Various caches for this face's child objects. The list is used to track active instance and context objects, as well as to recycle them. See TTLists.

A typeless pointer to the face object's extensions.

A generic pointer. See TT_Set/Get_Face_Pointer.

FreeType Instance Object.
Number of function definitions.
Table of FDefs entries.
Number of instruction definitions.
Table of IDefs entries.
Maximum function number.
Maximum instruction number.
The storage area.
The scaled Control Value Table.
The instance's twilight zone.
Debugging variable.

When using the debugger, we must keep the execution context with the instance object rather than asking it on demand.

Generic pointer.

See TT_Set/Get_Instance_Pointer.

FreeType Execution Context Object.
Size of instance stack.
Current instance stack.
Current code range number.
Current code range.
Current instruction pointer.
Size of current range.
Used by the interpreter.
If true, go to the next instruction.
The load stack used to load composite glyphs.
Glyph instructions.
Glyph instruction size.
Interpreter call stack.
Value used for SuperRounding.
Value used for SuperRounding.
Number of function definitions.
Table of FDefs entries.
Number of instruction definitions.
Table of IDefs entries.
Maximum function number.
Maximum instruction number.
Size of the current storage.
Storage area.

Used by the full-screen debugger. If set, the interpreter will exit after executing one opcode. Used to perform single-stepping.

This flag is True when the glyph is a composite one. In this case, we measure original distances in the loaded coordinates (font units), then scale them appropriately. This get rid of transformation artifacts (like symmetries).

The dot product of the free and projection vector is used in frequent operations.

FreeType Glyph Object.

Temporary. Used for debugging purposes.

Temporary. Used for debugging purposes.

Temporary. Used for debugging purposes.

Index of the font in the collection.
Go to a specified code range.
Returns a pointer to a given code range record.

Used only by the debugger.

Sets properties for the given code range.
Clear a given code range.

Get a new execution context, either fresh or recycled, for an instance of the face 'res'. Called by 'New_Face_Context'. Assumes that the face mutex is acquired.

Releases an execution context. The context can be destroyed or recycled, depending on implementation. Called by 'Done_Face_Context'. Assumes that the face mutex is acquired.

Update exec's data with the one found in 'ins'. Typically before an execution.

Update ins's data with the one found in 'exec'. Typically after an execution.

Initialize the object manager.
Finalize the object manager.