Next: Using Outlines
Up: Interface to Outlines
Previous: Interface to Outlines
Contents
Index
Outline Format
Before going into implementation details the general structure of a Type 1
outline is described. We will consider the simple fictive character whose
outline is shown in figure
.
Figure:
The outline of a fictive character.
|
We assume that scaling, grid fitting and hinting has already been carried out.
Then, the outline is given by set of points
and segments connecting those
points. There are:
- Move-segments (type =
T1_PATHTYPE_MOVE
): These are straight
segments which cause the current position to be displaced by some offset.
Since the starting point of a segment is always implicitly the current
point, only one argument is needed,
, the destination point. In
the figure,
-
and
-
are Move-segments. In this
simple case they displace from the characters origin to some starting point
of the outline and from the ending point of the outline to the point where
the next character would have to be placed (the horizontal escapement).
- Line-segments (type =
T1_PATHTYPE_LINE
): These are part of the
path to be filled later. In analogy to the Move-segment, one argument,
, is required for Line-segments. In the figure,
-
is
a Line-segment.
- Bezier-segments (type =
T1_PATHTYPE_BEZIER
): These are curve
segments. Their shape is defined by a starting point (always the current
point here), an ending point
and two control points
,
. These four points are the parameters of what is called a third order
Bezier spline.13 The resulting curve has the following
properties:
- It starts at the first point
.
- It ends at the fourth point
.
- The line that goes through the points
and
is the
tangent to the curve from the right side at the starting point
.
- In analogy, the line that goes through the points
and
is the tangent to the curve from the left side at the ending
point
.
- The resulting curve will be enclosed completely by the convex area
that is defined by connecting the definition points with straight line
segments.
Our fictive character outline in figure
has three Bezier-segments,
-
-
-
,
-
-
-
and
-
-
-
. Notice that it is easily possible to
achieve a smooth tangent transition from one curve-segment to the next by
choosing the involved points from a straight line.
For Type 1 fonts in general, the following rules for interpreting coordinate
specifications hold:
- All point specifications are relative to the current
point.
- For Bezier-segments,
,
and
all are relative to
.
- Initially, i.e. when a character outline is started, the current point
is at the origin
of the character.
Additionally, for this special rasterizer implementation, the following terms
apply:
- The vertical coordinate is--in contrast to PostScript--inverted, i.e.,
the
-axis points down.
- Once hinted and gridfitted, the outline point coordinates are described
in fractional pixels. A ``fractpel'' is of type
long
and
describes the location in
th fractions of a pixel. To convert from
pixel to fractional pixel and vice versa, the macros
T1_TOPATHPOINT(p)
and
T1_NEARESTPOINT(fp)
are provided.
Before describing the functions for retrieving outlines the format in which
outlines are presented in C will be described. A point specification is done
in the following structure:
typedef struct {
long x;
long y;
} T1_PATHPOINT;
x
and y
are fractional pixels as described above.
An outline is represented by a linked list of structures which describe path
segments of the type described above.
Line- and Move-segments are described by the following structure:
typedef struct pathsegment {
char type;
unsigned char flag;
short references;
unsigned char size;
unsigned char context;
struct pathsegment *link;
struct pathsegment *last;
T1_PATHPOINT dest;
} T1_PATHSEGMENT;
type
is either T1_PATHTYPE_MOVE
or
T1_PATHTYPE_LINE
. flag
, references
, size
and
context
are internally used by the rasterizer. link
is a pointer
to the next segment structure or NULL
in case it is the last structure
in the list. Finally, the last
-entry is a pointer to
the last structure in the linked list. last
is only set in the first
segment and is reset to NULL
in the remaining segment structures.
A Bezier-segment is described by the following structure:
typedef struct bezierpathsegment {
char type;
unsigned char flag;
short references;
unsigned char size;
unsigned char context;
T1_PATHSEGMENT *link;
T1_PATHSEGMENT *last;
T1_PATHPOINT dest;
T1_PATHPOINT B;
T1_PATHPOINT C;
} T1_BEZIERSEGMENT;
Obviously, the format is identical to that for straight path segments, extended
by the entries B
and C
which specify the control points as
described earlier in this subsection.
The common return type for the outline retrieving functions is a pointer to
T1_OUTLINE
, which is in fact identical to T1_PATHSEGMENT
. This
purely for convention. Although it is quite unlikely, an outline might start
with a Bezier-segment. To access Bezier-segment elements, a cast must be used.
Next: Using Outlines
Up: Interface to Outlines
Previous: Interface to Outlines
Contents
Index
2004-10-04