diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2007-11-28 22:38:47 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2007-11-28 22:38:47 +0000 |
commit | 068f23e738bb4d158c6e5986cb24ea6bddcee0eb (patch) | |
tree | bde51f1a1de612c002e6d9eaac407fd789ea9a1f /Build/source/texk/web2c/mpdir | |
parent | efd2ea1905cc57421e4d5b3123797164601993a4 (diff) |
MetaPost version 1.002
git-svn-id: svn://tug.org/texlive/trunk@5639 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/mpdir')
-rw-r--r-- | Build/source/texk/web2c/mpdir/Makefile.in | 4 | ||||
-rw-r--r-- | Build/source/texk/web2c/mpdir/mp.defines | 2 | ||||
-rw-r--r-- | Build/source/texk/web2c/mpdir/mplib.h | 4 | ||||
-rw-r--r-- | Build/source/texk/web2c/mpdir/turningnumber.c | 113 | ||||
-rw-r--r-- | Build/source/texk/web2c/mpdir/writefont.c | 11 |
5 files changed, 120 insertions, 14 deletions
diff --git a/Build/source/texk/web2c/mpdir/Makefile.in b/Build/source/texk/web2c/mpdir/Makefile.in index c6abb102f2d..5b1cbc6893c 100644 --- a/Build/source/texk/web2c/mpdir/Makefile.in +++ b/Build/source/texk/web2c/mpdir/Makefile.in @@ -14,7 +14,7 @@ CXX = @CXX@ XCPPFLAGS=-I.. -I$(srcdir)/.. -I../.. -I$(srcdir)/../.. -OBJS = mapfile.o avl.o avlstuff.o utils.o writeenc.o writet1.o writefont.o +OBJS = mapfile.o avl.o avlstuff.o utils.o writeenc.o writet1.o writefont.o turningnumber.o all: libmpost.a makecpool @@ -34,7 +34,7 @@ clean:: depend: rm -f $(OBJS) XXCFLAGS=-MM XCFLAGS=-MM $(MAKE) -k $(OBJS) | \ - grep -v "^$(CC)\|$(CXX)\|$(AR)\|make\|klibtool" | \ + grep -v "^$(CC)\|$(CXX)\|$(AR)\|make" | \ sed 's: [^ ]*/\.\./libs/[^ ]*::g' > $(srcdir)/depend.mk kpse_include mpdir/depend.mk diff --git a/Build/source/texk/web2c/mpdir/mp.defines b/Build/source/texk/web2c/mpdir/mp.defines index 90f196b1ff5..7af554a389a 100644 --- a/Build/source/texk/web2c/mpdir/mp.defines +++ b/Build/source/texk/web2c/mpdir/mp.defines @@ -54,4 +54,4 @@ $Id$ { function from turningnumber.c } -@define function bezierslope();
\ No newline at end of file +@define function bezierslope(); diff --git a/Build/source/texk/web2c/mpdir/mplib.h b/Build/source/texk/web2c/mpdir/mplib.h index 363836a994d..232956dbff7 100644 --- a/Build/source/texk/web2c/mpdir/mplib.h +++ b/Build/source/texk/web2c/mpdir/mplib.h @@ -297,4 +297,8 @@ extern void writezip (boolean); extern void avlputobj (integer, integer); extern integer avlfindobj (integer, integer, integer); +/* turningnumber.c */ + +extern angle bezierslope(integer,integer,integer,integer,integer,integer,integer,integer,int); + #endif /* MPOSTLIB */ diff --git a/Build/source/texk/web2c/mpdir/turningnumber.c b/Build/source/texk/web2c/mpdir/turningnumber.c new file mode 100644 index 00000000000..bfb7d9133d2 --- /dev/null +++ b/Build/source/texk/web2c/mpdir/turningnumber.c @@ -0,0 +1,113 @@ +/* $Id$ */ + +#include "mplib.h" + +#define bezier_error (720<<20)+1 + +#define sign(v) ((v)>0 ? 1 : ((v)<0 ? -1 : 0 )) + +#define print_roots(a) { if (debuglevel>(65536*2)) \ + fprintf(stdout,"bezierslope(): %s, i=%f, o=%f, angle=%f\n", \ + (a),in,out,res); } + +#define out ((double)(xo>>20)) +#define mid ((double)(xm>>20)) +#define in ((double)(xi>>20)) + +#define divisor (256*256) + +#define double2angle(a) (int)floor(a*256.0*256.0*16.0) + +angle +bezierslope(integer AX,integer AY,integer BX,integer BY, + integer CX,integer CY,integer DX,integer DY, int debuglevel) { + double a, b, c; + integer deltax,deltay; + double ax,ay,bx,by,cx,cy,dx,dy; + + angle xi = 0, xo = 0, xm = 0; + double res = 0; + + ax=AX/divisor; ay=AY/divisor; + bx=BX/divisor; by=BY/divisor; + cx=CX/divisor; cy=CY/divisor; + dx=DX/divisor; dy=DY/divisor; + + deltax = (BX-AX); deltay = (BY-AY); + if (deltax==0 && deltay == 0) { deltax=(CX-AX); deltay=(CY-AY); } + if (deltax==0 && deltay == 0) { deltax=(DX-AX); deltay=(DY-AY); } + xi = anangle(deltax,deltay); + + deltax = (CX-BX); deltay = (CY-BY); + xm = anangle(deltax,deltay); + + deltax = (DX-CX); deltay = (DY-CY); + if (deltax==0 && deltay == 0) { deltax=(DX-BX); deltay=(DY-BY); } + if (deltax==0 && deltay == 0) { deltax=(DX-AX); deltay=(DY-AY); } + xo = anangle(deltax,deltay); + + a = (bx-ax)*(cy-by) - (cx-bx)*(by-ay); /* a = (bp-ap)x(cp-bp); */ + b = (bx-ax)*(dy-cy) - (by-ay)*(dx-cx);; /* b = (bp-ap)x(dp-cp);*/ + c = (cx-bx)*(dy-cy) - (dx-cx)*(cy-by); /* c = (cp-bp)x(dp-cp);*/ + + if (debuglevel>(65536*2)) { + fprintf(stdout, + "bezierslope(): (%.2f,%.2f),(%.2f,%.2f),(%.2f,%.2f),(%.2f,%.2f)\n", + ax,ay,bx,by,cx,cy,dx,dy); + fprintf(stdout,"bezierslope(): a,b,c,b^2,4ac: (%.2f,%.2f,%.2f,%.2f,%.2f)\n",a,b,c,b*b,4*a*c); + } + + if ((a==0)&&(c==0)) { + res = (b==0 ? 0 : (out-in)); + print_roots("no roots (a)"); + } else if ((a==0)||(c==0)) { + if ((sign(b) == sign(a)) || (sign(b) == sign(c))) { + res = out-in; /* ? */ + if (res<-180.0) + res += 360.0; + else if (res>180.0) + res -= 360.0; + print_roots("no roots (b)"); + } else { + res = out-in; /* ? */ + print_roots("one root (a)"); + } + } else if ((sign(a)*sign(c))<0) { + res = out-in; /* ? */ + if (res<-180.0) + res += 360.0; + else if (res>180.0) + res -= 360.0; + print_roots("one root (b)"); + } else { + if (sign(a) == sign(b)) { + res = out-in; /* ? */ + if (res<-180.0) + res += 360.0; + else if (res>180.0) + res -= 360.0; + print_roots("no roots (d)"); + } else { + if ((b*b) == (4*a*c)) { + res = bezier_error; + /* print_roots("double root"); *//* cusp */ + } else if ((b*b) < (4*a*c)) { + res = out-in; /* ? */ + if (res<=0.0 &&res>-180.0) + res += 360.0; + else if (res>=0.0 && res<180.0) + res -= 360.0; + print_roots("no roots (e)"); + } else { + res = out-in; + if (res<-180.0) + res += 360.0; + else if (res>180.0) + res -= 360.0; + print_roots("two roots"); /* two inflections */ + } + } + } + return double2angle(res); +} + diff --git a/Build/source/texk/web2c/mpdir/writefont.c b/Build/source/texk/web2c/mpdir/writefont.c index e88b4dbab7d..899b42b54a2 100644 --- a/Build/source/texk/web2c/mpdir/writefont.c +++ b/Build/source/texk/web2c/mpdir/writefont.c @@ -184,17 +184,6 @@ void mpfontencodings (int lastfnum, int encodings_only) { if (encodings_only || (!is_subsetted (fm))) { e = fm->encoding; write_enc (NULL, e, 0); - } - } - } - } - } - for (f=nullfont+1;f<=lastfnum;f++) { - if (fontsizes[f]!=0 && hasfmentry (f)) { - fm = (fm_entry *) mpfontmap[f]; - if (fm != NULL && (fm->ps_name != NULL)) { - if (is_reencoded (fm)) { - if (encodings_only || (!is_subsetted (fm))) { /* clear for next run */ e->objnum = 0; } |