1 /* Copyright (C) 2000-2008 by George Williams */
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
13 * The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include "splinefont.h"
31 typedef struct hints
{
35 unsigned int adjustb
: 1;
36 unsigned int adjuste
: 1;
40 /* Instead of y and x coordinates these are based on major and other */
41 /* major maybe either x or y depending on what we're interested in */
42 /* at the moment, and other will be the other one. Of course it's */
43 /* consistant accross the datastructure at any given time */
45 real mmin
, mmax
; /* relative to es->mmin */
49 real t_cur
, o_cur
, m_cur
;
50 unsigned int up
: 1; /* line is directed up in the spline list */
51 unsigned int max_adjusted
: 1; /* by hstem hints */
52 unsigned int min_adjusted
: 1;
53 Spline
*spline
; /* spline which generated this segment */
54 struct edge
*esnext
, *aenext
;
55 struct edge
*before
, *after
;
56 int last_opos
, last_mpos
;
57 real oldt
; /* only used for FindIntersections of RemoveOverlap */
60 typedef struct edgelist
{
68 Edge
*last
, *splinesetfirst
;
73 unsigned int genmajoredges
: 1; /* generate a list of edges parallel to the major axis */
74 Edge
*majors
; /* ordered so that lowest edge is first */
75 Edge
*majorhold
; /* to hold major edges as we pass them and they become useless */
76 Hints
*hhints
, *vhints
;
78 DBounds bbox
; /* Not always set. {m,o}{min,max} a provide scaled bbox, this is in glyph units */
81 extern void FreeEdges(EdgeList
*es
);
82 extern double TOfNextMajor(Edge
*e
, EdgeList
*es
, double sought_y
);
83 extern void FindEdgesSplineSet(SplinePointList
*spl
, EdgeList
*es
, int ignore_clip
);
84 extern Edge
*ActiveEdgesInsertNew(EdgeList
*es
, Edge
*active
,int i
);
85 extern Edge
*ActiveEdgesRefigure(EdgeList
*es
, Edge
*active
,real i
);
86 extern Edge
*ActiveEdgesFindStem(Edge
*apt
, Edge
**prev
, real i
);
88 /* Version which is better for everything other than rasterization */
90 typedef struct edgeinfo
{
91 /* The spline is broken up at all extrema. So... */
92 /* The spline between tmin and tmax is monotonic in both coordinates */
93 /* If the spline becomes vert/horizontal that will be at one of the */
101 unsigned int hvbottom
: 1;
102 unsigned int hvtop
: 1;
104 unsigned int vert
: 1;
105 unsigned int almosthor
: 1;
106 unsigned int almostvert
: 1;
107 unsigned int horattmin
: 1;
108 unsigned int horattmax
: 1;
109 unsigned int vertattmin
: 1;
110 unsigned int vertattmax
: 1;
113 real tcur
; /* Value of t for current major coord */
114 real ocur
; /* Value of the other coord for current major coord */
115 struct edgeinfo
*next
;
116 struct edgeinfo
*ordered
;
117 struct edgeinfo
*aenext
;
118 struct edgeinfo
*splinenext
;
123 typedef struct eilist
{
129 char *ends
; /* flag to say an edge ends on this line */
133 EI
*splinelast
, *splinefirst
;
134 EI
**bottoms
, **tops
; /* Used only be FindNeeded in RemoveOverlap */
135 unsigned leavetiny
: 1;
136 enum overlap_type ot
;
139 extern void ElFreeEI(EIList
*el
);
140 extern void ELFindEdges(SplineChar
*sc
, EIList
*el
);
141 extern void ELOrder(EIList
*el
, int major
);
142 extern real
EITOfNextMajor(EI
*e
, EIList
*el
, real sought_m
);
143 extern int EISameLine(EI
*e
, EI
*n
, real i
, int major
);
144 extern int EISkipExtremum(EI
*e
, real i
, int major
);
145 extern EI
*EIActiveEdgesFindStem(EI
*apt
, real i
, int major
);
146 extern EI
*EIActiveListReorder(EI
*active
,int *change
);
147 extern EI
*EIActiveEdgesRefigure(EIList
*el
, EI
*active
,real i
,int major
,