Skip to content

Commit da2d65c

Browse files
committed
Convert to initializing with SplinePointCreate()
1 parent 0f8fc11 commit da2d65c

12 files changed

Lines changed: 74 additions & 127 deletions

File tree

fontforge/cvimages.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -542,23 +542,19 @@ static SplineSet * slurpelipse(FILE *fig,SplineChar *sc, SplineSet *sofar) {
542542

543543
spl = chunkalloc(sizeof(SplinePointList));
544544
spl->next = sofar;
545-
spl->first = sp = chunkalloc(sizeof(SplinePoint));
546-
sp->me.x = dcx; sp->me.y = dcy+dry;
545+
spl->first = sp = SplinePointCreate(dcx, dcy+dry);
547546
sp->nextcp.x = sp->me.x + .552*drx; sp->nextcp.y = sp->me.y;
548547
sp->prevcp.x = sp->me.x - .552*drx; sp->prevcp.y = sp->me.y;
549-
spl->last = sp = chunkalloc(sizeof(SplinePoint));
550-
sp->me.x = dcx+drx; sp->me.y = dcy;
548+
spl->last = sp = SplinePointCreate(dcx+drx, dcy);
551549
sp->nextcp.x = sp->me.x; sp->nextcp.y = sp->me.y - .552*dry;
552550
sp->prevcp.x = sp->me.x; sp->prevcp.y = sp->me.y + .552*dry;
553551
SplineMake3(spl->first,sp);
554-
sp = chunkalloc(sizeof(SplinePoint));
555-
sp->me.x = dcx; sp->me.y = dcy-dry;
552+
sp = SplinePointCreate(dcx, dcy-dry);
556553
sp->nextcp.x = sp->me.x - .552*drx; sp->nextcp.y = sp->me.y;
557554
sp->prevcp.x = sp->me.x + .552*drx; sp->prevcp.y = sp->me.y;
558555
SplineMake3(spl->last,sp);
559556
spl->last = sp;
560-
sp = chunkalloc(sizeof(SplinePoint));
561-
sp->me.x = dcx-drx; sp->me.y = dcy;
557+
sp = SplinePointCreate(dcx-drx, dcy);
562558
sp->nextcp.x = sp->me.x; sp->nextcp.y = sp->me.y + .552*dry;
563559
sp->prevcp.x = sp->me.x; sp->prevcp.y = sp->me.y - .552*dry;
564560
SplineMake3(spl->last,sp);
@@ -634,8 +630,7 @@ static SplineSet * slurppolyline(FILE *fig,SplineChar *sc, SplineSet *sofar) {
634630
SplineMake3(spl->last,sp); spl->last = sp;
635631
} else {
636632
for ( i=0; i<cnt; ++i ) {
637-
sp = chunkalloc(sizeof(SplinePoint));
638-
sp->me = sp->nextcp = sp->prevcp = bps[i];
633+
sp = SplinePointCreate(bps[i].x, bps[i].y);
639634
sp->pointtype = pt_corner;
640635
if ( spl->first==NULL )
641636
spl->first = sp;
@@ -760,17 +755,18 @@ static SplineSet *ApproximateXSpline(struct xspline *xs,int order2) {
760755
FitPoint mids[7];
761756
SplineSet *spl = chunkalloc(sizeof(SplineSet));
762757
SplinePoint *sp;
758+
BasePoint tbp;
763759

764-
spl->first = spl->last = chunkalloc(sizeof(SplinePoint));
765-
xsplineeval(&spl->first->me,0,xs);
760+
xsplineeval(&tbp,0,xs);
761+
spl->first = spl->last = SplinePointCreate(tbp.x, tbp.y);
766762
spl->first->pointtype = ( xs->s[0]==0 )?pt_corner:pt_curve;
767763
for ( i=0; i<(size_t)(xs->n-1); ++i ) {
768764
if ( i==(size_t)(xs->n-2) && xs->closed )
769765
sp = spl->first;
770766
else {
771-
sp = chunkalloc(sizeof(SplinePoint));
772767
sp->pointtype = ( xs->s[i+1]==0 )?pt_corner:pt_curve;
773-
xsplineeval(&sp->me,i+1,xs);
768+
xsplineeval(&tbp,i+1,xs);
769+
sp = SplinePointCreate(tbp.x, tbp.y);
774770
}
775771
for ( j=0, t=1./8; j<sizeof(mids)/sizeof(mids[0]); ++j, t+=1./8 ) {
776772
xsplineeval((BasePoint *) &mids[j].p,i+t,xs);

fontforge/freetype.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,7 @@ static int FT_MoveTo(const FT_Vector *to,void *user) {
553553
if ( context->orig_cpl!=NULL )
554554
context->orig_sp = context->orig_cpl->first;
555555

556-
context->last = context->cpl->first = chunkalloc(sizeof(SplinePoint));
557-
context->last->me.x = to->x*context->scalex;
558-
context->last->me.y = to->y*context->scaley;
556+
context->last = context->cpl->first = SplinePointCreate(to->x*context->scalex, to->y*context->scaley);
559557
if ( context->orig_sp==NULL )
560558
context->last->ttfindex = -2;
561559
else {

fontforge/fvcomposite.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,10 +2430,7 @@ static void DoSpaces(SplineFont *sf,SplineChar *sc,int layer,BDFFont *bdf,int di
24302430
}
24312431

24322432
static SplinePoint *MakeSP(real x, real y, SplinePoint *last,int order2) {
2433-
SplinePoint *new = chunkalloc(sizeof(SplinePoint));
2434-
2435-
new->me.x = x; new->me.y = y;
2436-
new->prevcp = new->nextcp = new->me;
2433+
SplinePoint *new = SplinePointCreate(x, y);
24372434
new->pointtype = pt_corner;
24382435
if ( last!=NULL )
24392436
SplineMake(last,new,order2);

fontforge/fvfonts.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,14 +1310,11 @@ return( head );
13101310
}
13111311

13121312
static void InterpPoint(SplineSet *cur, SplinePoint *base, SplinePoint *other, real amount ) {
1313-
SplinePoint *p = chunkalloc(sizeof(SplinePoint));
1313+
SplinePoint *p = SplinePointCreate(base->me.x + amount*(other->me.x-base->me.x),
1314+
base->me.y + amount*(other->me.y-base->me.y));
13141315
int order2 = base->prev!=NULL ? base->prev->order2 : base->next!=NULL ? base->next->order2 : false;
13151316

1316-
p->me.x = base->me.x + amount*(other->me.x-base->me.x);
1317-
p->me.y = base->me.y + amount*(other->me.y-base->me.y);
1318-
if ( order2 && base->prev!=NULL && (base->prev->islinear || other->prev->islinear ))
1319-
p->prevcp = p->me;
1320-
else {
1317+
if ( !( order2 && base->prev!=NULL && (base->prev->islinear || other->prev->islinear) ) ) {
13211318
p->prevcp.x = base->prevcp.x + amount*(other->prevcp.x-base->prevcp.x);
13221319
p->prevcp.y = base->prevcp.y + amount*(other->prevcp.y-base->prevcp.y);
13231320
if ( order2 && cur->first!=NULL ) {
@@ -1328,9 +1325,7 @@ static void InterpPoint(SplineSet *cur, SplinePoint *base, SplinePoint *other, r
13281325
cur->last->nextcp.y = p->prevcp.y = (cur->last->nextcp.y+p->prevcp.y)/2;
13291326
}
13301327
}
1331-
if ( order2 && base->next!=NULL && (base->next->islinear || other->next->islinear ))
1332-
p->nextcp = p->me;
1333-
else {
1328+
if ( ! ( order2 && base->next!=NULL && (base->next->islinear || other->next->islinear ) ) ) {
13341329
p->nextcp.x = base->nextcp.x + amount*(other->nextcp.x-base->nextcp.x);
13351330
p->nextcp.y = base->nextcp.y + amount*(other->nextcp.y-base->nextcp.y);
13361331
}

fontforge/parsepdf.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,9 +1445,9 @@ static void _InterpretPdf(FILE *in, struct pdfcontext *pc, EntityChar *ec) {
14451445
current.x = stack[sp-2].u.val;
14461446
current.y = stack[sp-1].u.val;
14471447
sp -= 2;
1448-
pt = chunkalloc(sizeof(SplinePoint));
1449-
Transform(&pt->me,&current,transform);
1450-
pt->prevcp = pt->me; pt->nextcp = pt->me;
1448+
BasePoint ini_me;
1449+
Transform(&ini_me,&current,transform);
1450+
pt = SplinePointCreate(ini_me.x, ini_me.y);
14511451
if ( tok==pt_moveto ) {
14521452
SplinePointList *spl = chunkalloc(sizeof(SplinePointList));
14531453
spl->first = spl->last = pt;
@@ -1487,10 +1487,10 @@ static void _InterpretPdf(FILE *in, struct pdfcontext *pc, EntityChar *ec) {
14871487
current = to;
14881488
if ( cur!=NULL && cur->first!=NULL && (cur->first!=cur->last || cur->first->next==NULL) ) {
14891489
Transform(&cur->last->nextcp,&ncp,transform);
1490-
pt = chunkalloc(sizeof(SplinePoint));
1490+
BasePoint ini_me;
1491+
Transform(&ini_me,&current,transform);
1492+
pt = SplinePointCreate(ini_me.x, ini_me.y);
14911493
Transform(&pt->prevcp,&pcp,transform);
1492-
Transform(&pt->me,&current,transform);
1493-
pt->nextcp = pt->me;
14941494
SplineMake3(cur->last,pt);
14951495
cur->last = pt;
14961496
}

fontforge/parsettf.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,8 +1872,7 @@ static SplineSet *ttfbuildcontours(int path_cnt,uint16 *endpt, char *flags,
18721872
sp = NULL;
18731873
while ( i<=endpt[path] ) {
18741874
if ( flags[i]&_On_Curve ) {
1875-
sp = chunkalloc(sizeof(SplinePoint));
1876-
sp->me = sp->nextcp = sp->prevcp = pts[i];
1875+
sp = SplinePointCreate(pts[i].x, pts[i].y);
18771876
sp->ttfindex = i;
18781877
sp->nextcpindex = 0xffff;
18791878
if ( last_off && cur->last!=NULL ) {
@@ -1883,10 +1882,7 @@ static SplineSet *ttfbuildcontours(int path_cnt,uint16 *endpt, char *flags,
18831882
} else if ( last_off ) {
18841883
/* two off curve points get a third on curve point created */
18851884
/* half-way between them. Now isn't that special */
1886-
sp = chunkalloc(sizeof(SplinePoint));
1887-
sp->me.x = (pts[i].x+pts[i-1].x)/2;
1888-
sp->me.y = (pts[i].y+pts[i-1].y)/2;
1889-
sp->nextcp = sp->prevcp = sp->me;
1885+
sp = SplinePointCreate((pts[i].x+pts[i-1].x)/2, (pts[i].y+pts[i-1].y)/2);
18901886
sp->ttfindex = 0xffff;
18911887
sp->nextcpindex = i;
18921888
if ( last_off && cur->last!=NULL )
@@ -1912,19 +1908,13 @@ static SplineSet *ttfbuildcontours(int path_cnt,uint16 *endpt, char *flags,
19121908
/* point. What on earth do they think that means? */
19131909
/* Oh. I see. It's used to possition marks and such */
19141910
if ( cur->first==NULL ) {
1915-
sp = chunkalloc(sizeof(SplinePoint));
1916-
sp->me.x = pts[start].x;
1917-
sp->me.y = pts[start].y;
1918-
sp->nextcp = sp->prevcp = sp->me;
1911+
sp = SplinePointCreate(pts[start].x, pts[start].y);
19191912
sp->ttfindex = i-1;
19201913
sp->nextcpindex = 0xffff;
19211914
cur->first = cur->last = sp;
19221915
}
19231916
} else if ( !(flags[start]&_On_Curve) && !(flags[i-1]&_On_Curve) ) {
1924-
sp = chunkalloc(sizeof(SplinePoint));
1925-
sp->me.x = (pts[start].x+pts[i-1].x)/2;
1926-
sp->me.y = (pts[start].y+pts[i-1].y)/2;
1927-
sp->nextcp = sp->prevcp = sp->me;
1917+
sp = SplinePointCreate((pts[start].x+pts[i-1].x)/2, (pts[start].y+pts[i-1].y)/2);
19281918
sp->ttfindex = 0xffff;
19291919
sp->nextcpindex = start;
19301920
FigureControls(cur->last,sp,&pts[i-1],is_order2);

0 commit comments

Comments
 (0)