Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
splinefont.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3#ifndef _SEEN_SPLINEFONT_H_
4#define _SEEN_SPLINEFONT_H_
5
6#include <glib.h>
7
8G_BEGIN_DECLS
9
10typedef double real;
11typedef double bigreal;
12typedef double extended;
13typedef int BOOL;
14
15#define chunkalloc(size) calloc(1,size)
16#define chunkfree(item,size) free(item)
17
18typedef struct basepoint {
22
23typedef struct ipoint {
24 int x;
25 int y;
27
29typedef struct splinepoint {
31 BasePoint nextcp; /* control point */
32 BasePoint prevcp; /* control point */
33 unsigned int nonextcp:1;
34 unsigned int noprevcp:1;
35 unsigned int nextcpdef:1;
36 unsigned int prevcpdef:1;
37 unsigned int selected:1; /* for UI */
38 unsigned int nextcpselected: 2; /* Is the next BCP selected */
39 unsigned int prevcpselected: 2; /* Is the prev BCP selected */
40 unsigned int pointtype:2;
41 unsigned int isintersection: 1;
42 unsigned int flexy: 1; /* When "freetype_markup" is on in charview.c:DrawPoint */
43 unsigned int flexx: 1; /* flexy means select nextcp, and flexx means draw circle around nextcp */
44 unsigned int roundx: 1; /* For true type hinting */
45 unsigned int roundy: 1; /* For true type hinting */
46 unsigned int dontinterpolate: 1; /* in ttf, don't imply point by interpolating between cps */
47 unsigned int ticked: 1;
48 unsigned int watched: 1;
49 /* 1 bits left... */
50 uint16_t ptindex; /* Temporary value used by metafont routine */
51 uint16_t ttfindex; /* Truetype point index */
52 /* Special values 0xffff => point implied by averaging control points */
53 /* 0xfffe => point created with no real number yet */
54 /* (or perhaps point in context where no number is possible as in a glyph with points & refs) */
55 uint16_t nextcpindex; /* Truetype point index */
56 struct spline *next;
57 struct spline *prev;
58 /* Inkscape: not used; HintMask *hintmask; */
59 char* name;
61
62
63typedef struct spline1d {
64 real a, b, c, d;
66
67typedef struct spline {
68 unsigned int islinear: 1; /* No control points */
69 unsigned int isquadratic: 1; /* probably read in from ttf */
70 unsigned int isticked: 1;
71 unsigned int isneeded: 1; /* Used in remove overlap */
72 unsigned int isunneeded: 1; /* Used in remove overlap */
73 unsigned int exclude: 1; /* Used in remove overlap variant: exclude */
74 unsigned int ishorvert: 1;
75 unsigned int knowncurved: 1; /* We know that it curves */
76 unsigned int knownlinear: 1; /* it might have control points, but still traces out a line */
77 /* If neither knownlinear nor curved then we haven't checked */
78 unsigned int order2: 1; /* It's a bezier curve with only one cp */
79 unsigned int touched: 1;
80 unsigned int leftedge: 1;
81 unsigned int rightedge: 1;
82 unsigned int acceptableextrema: 1; /* This spline has extrema, but we don't care */
85 Spline1D splines[2]; /* splines[0] is the x spline, splines[1] is y */
87 /* Possible optimizations:
88 Precalculate bounding box
89 Precalculate min/max/ points of inflection
90 */
92
93typedef struct splinepointlist {
96 /* Not used: spiro_cp *spiros; */
98 /* These could be bit fields, but bytes are easier to access and we */
99 /* don't need the space (yet) */
100 uint8_t ticked;
101 uint8_t beziers_need_optimizer; /* If the spiros have changed in spiro mode, then reverting to bezier mode might, someday, run a simplifier */
102 uint8_t is_clip_path; /* In type3/svg fonts */
103 int start_offset; // This indicates which point is the canonical first for purposes of outputting to U. F. O..
106
111
112typedef struct quartic {
115
116
119
120Spline *SplineMake(SplinePoint *from, SplinePoint *to, int order2);
124
128void SplineFindExtrema(const Spline1D *sp, extended *_t1, extended *_t2 );
130
134
138
139int _CubicSolve(const Spline1D *sp,bigreal sought, extended ts[3]);
142 BasePoint *line1_1, BasePoint *line1_2,
143 BasePoint *line2_1, BasePoint *line2_2);
144
145#define IError(msg) g_warning(msg)
146#define TRACE g_message
147
149
150typedef struct linelist {
152 struct linelist *next;
153 /* The first two fields are constant for the linelist, the next ones */
154 /* refer to a particular screen. If some portion of the line from */
155 /* this point to the next one is on the screen then set cvli_onscreen */
156 /* if this point needs to be clipped then set cvli_clipped */
157 /* asend and asstart are the actual screen locations where this point */
158 /* intersects the clip edge. */
162
163typedef struct linearapprox {
165 unsigned int oneline: 1;
166 unsigned int onepoint: 1;
167 unsigned int any: 1; /* refers to a particular screen */
171
173
175
177 // Point selection (mutually exclusive)
182 // Conversion modes (mutually exclusive)
187 // Additional
188 pconvert_flag_hvcurve = 0x4000
190
192
193G_END_DECLS
194
195#endif // _SEEN_SPLINEFONT_H_
const double fudge
Definition mesh-grad.cpp:24
Spline * SplineMake3(SplinePoint *from, SplinePoint *to)
int BOOL
Definition splinefont.h:13
G_BEGIN_DECLS typedef double real
Definition splinefont.h:10
int SplineIsLinear(Spline *spline)
int IntersectLines(BasePoint *inter, BasePoint *line1_1, BasePoint *line1_2, BasePoint *line2_1, BasePoint *line2_2)
void SplineFindExtrema(const Spline1D *sp, extended *_t1, extended *_t2)
struct spline1d Spline1D
linelist_flags
Definition splinefont.h:148
@ cvli_onscreen
Definition splinefont.h:148
@ cvli_clipped
Definition splinefont.h:148
Spline * SplineMake2(SplinePoint *from, SplinePoint *to)
int RealWithin(real a, real b, real fudge)
struct basepoint BasePoint
double extended
Definition splinefont.h:12
int Within16RoundingErrors(bigreal v1, bigreal v2)
pointtype
Definition splinefont.h:28
@ pt_hvcurve
Definition splinefont.h:28
@ pt_curve
Definition splinefont.h:28
@ pt_tangent
Definition splinefont.h:28
@ pt_corner
Definition splinefont.h:28
struct ipoint IPoint
struct linearapprox LinearApprox
struct dbounds DBounds
void LinearApproxFree(LinearApprox *la)
struct splinepointlist SplinePointList
struct spline Spline
void SplineRefigure3(Spline *spline)
int _QuarticSolve(Quartic *q, extended ts[4])
struct linelist LineList
Spline * SplineMake(SplinePoint *from, SplinePoint *to, int order2)
SplinePoint * SplinePointCreate(real x, real y)
BasePoint BPRev(BasePoint v)
pconvert_flags
Definition splinefont.h:176
@ pconvert_flag_force_type
Definition splinefont.h:184
@ pconvert_flag_smooth
Definition splinefont.h:180
@ pconvert_flag_incompat
Definition splinefont.h:181
@ pconvert_flag_hvcurve
Definition splinefont.h:188
@ pconvert_flag_check_compat
Definition splinefont.h:186
@ pconvert_flag_none
Definition splinefont.h:178
@ pconvert_flag_downgrade
Definition splinefont.h:185
@ pconvert_flag_all
Definition splinefont.h:179
@ pconvert_flag_by_geom
Definition splinefont.h:183
bigreal BPCross(BasePoint v1, BasePoint v2)
BOOL RealNear(real a, real b)
struct splinepoint SplinePoint
bigreal BPDot(BasePoint v1, BasePoint v2)
void SplinesRemoveBetween(SplinePoint *from, SplinePoint *to, int type)
int _CubicSolve(const Spline1D *sp, bigreal sought, extended ts[3])
struct splinepointlist SplineSet
double bigreal
Definition splinefont.h:11
struct quartic Quartic
void SplineFree(Spline *spline)
bigreal SplineMinDistanceToPoint(Spline *s, BasePoint *p)
void SplinePointFree(SplinePoint *sp)
void SplineRefigure(Spline *spline)
void SplinePointListFree(SplinePointList *spl)
real miny
Definition splinefont.h:109
real maxx
Definition splinefont.h:108
real minx
Definition splinefont.h:108
real maxy
Definition splinefont.h:109
int y
Definition splinefont.h:25
int x
Definition splinefont.h:24
struct linearapprox * next
Definition splinefont.h:169
unsigned int onepoint
Definition splinefont.h:166
struct linelist * lines
Definition splinefont.h:168
unsigned int oneline
Definition splinefont.h:165
unsigned int any
Definition splinefont.h:167
enum linelist_flags flags
Definition splinefont.h:159
struct linelist * next
Definition splinefont.h:152
IPoint here
Definition splinefont.h:151
IPoint asend
Definition splinefont.h:160
IPoint asstart
Definition splinefont.h:160
bigreal c
Definition splinefont.h:113
bigreal a
Definition splinefont.h:113
bigreal e
Definition splinefont.h:113
bigreal b
Definition splinefont.h:113
bigreal d
Definition splinefont.h:113
unsigned int order2
Definition splinefont.h:78
unsigned int knowncurved
Definition splinefont.h:75
unsigned int acceptableextrema
Definition splinefont.h:82
unsigned int ishorvert
Definition splinefont.h:74
SplinePoint * from
Definition splinefont.h:83
unsigned int isquadratic
Definition splinefont.h:69
unsigned int islinear
Definition splinefont.h:68
unsigned int exclude
Definition splinefont.h:73
Spline1D splines[2]
Definition splinefont.h:85
unsigned int leftedge
Definition splinefont.h:80
unsigned int isunneeded
Definition splinefont.h:72
SplinePoint * to
Definition splinefont.h:84
unsigned int knownlinear
Definition splinefont.h:76
unsigned int touched
Definition splinefont.h:79
unsigned int isticked
Definition splinefont.h:70
unsigned int rightedge
Definition splinefont.h:81
unsigned int isneeded
Definition splinefont.h:71
struct linearapprox * approx
Definition splinefont.h:86
uint16_t nextcpindex
Definition splinefont.h:55
unsigned int flexy
Definition splinefont.h:42
unsigned int isintersection
Definition splinefont.h:41
unsigned int pointtype
Definition splinefont.h:40
BasePoint me
Definition splinefont.h:30
unsigned int noprevcp
Definition splinefont.h:34
unsigned int prevcpselected
Definition splinefont.h:39
unsigned int nextcpselected
Definition splinefont.h:38
uint16_t ptindex
Definition splinefont.h:50
unsigned int roundy
Definition splinefont.h:45
unsigned int nonextcp
Definition splinefont.h:33
unsigned int selected
Definition splinefont.h:37
unsigned int flexx
Definition splinefont.h:43
struct spline * prev
Definition splinefont.h:57
BasePoint nextcp
Definition splinefont.h:31
unsigned int ticked
Definition splinefont.h:47
unsigned int watched
Definition splinefont.h:48
unsigned int roundx
Definition splinefont.h:44
unsigned int prevcpdef
Definition splinefont.h:36
BasePoint prevcp
Definition splinefont.h:32
unsigned int nextcpdef
Definition splinefont.h:35
char * name
Definition splinefont.h:59
uint16_t ttfindex
Definition splinefont.h:51
unsigned int dontinterpolate
Definition splinefont.h:46
struct spline * next
Definition splinefont.h:56
uint8_t beziers_need_optimizer
Definition splinefont.h:101
uint16_t spiro_max
Definition splinefont.h:97
struct splinepointlist * next
Definition splinefont.h:95
char * contour_name
Definition splinefont.h:104
uint16_t spiro_cnt
Definition splinefont.h:97
SplinePoint * first
Definition splinefont.h:94
SplinePoint * last
Definition splinefont.h:94
uint8_t is_clip_path
Definition splinefont.h:102