From 6457cd3f6e21e23e21db6dafff021d17f5457567 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 2 Jan 2021 16:31:31 +0000 Subject: asy 2.68 sources git-svn-id: svn://tug.org/texlive/trunk@57291 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/utils/asymptote/drawlabel.cc | 54 +++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'Build/source/utils/asymptote/drawlabel.cc') diff --git a/Build/source/utils/asymptote/drawlabel.cc b/Build/source/utils/asymptote/drawlabel.cc index 7f749989c48..afeeeb56737 100644 --- a/Build/source/utils/asymptote/drawlabel.cc +++ b/Build/source/utils/asymptote/drawlabel.cc @@ -15,15 +15,15 @@ using namespace settings; namespace camp { - + string texready=string("(Please type a command or say `\\end')\n*"); -void drawLabel::labelwarning(const char *action) +void drawLabel::labelwarning(const char *action) { - cerr << "warning: label \"" << label + cerr << "warning: label \"" << label << "\" " << action << " to avoid overwriting" << endl; } - + // Reads one of the dimensions from the pipe. void texdim(iopipestream& tex, double& dest, const string command, const string name) @@ -62,18 +62,18 @@ void texbounds(double& width, double& height, double& depth, texdim(tex,width,"wd","width"); texdim(tex,height,"ht","height"); texdim(tex,depth,"dp","depth"); -} +} inline double urand() -{ +{ static const double factor=2.0/RANDOM_MAX; return random()*factor-1.0; } -void setpen(iopipestream& tex, const string& texengine, const pen& pentype) +void setpen(iopipestream& tex, const string& texengine, const pen& pentype) { bool Latex=latex(texengine); - + if(Latex && setlatexfont(tex,pentype,drawElement::lastpen)) { tex << "\n"; tex.wait(texready.c_str()); @@ -82,7 +82,7 @@ void setpen(iopipestream& tex, const string& texengine, const pen& pentype) tex << "\n"; tex.wait(texready.c_str()); } - + drawElement::lastpen=pentype; } @@ -90,20 +90,20 @@ void drawLabel::getbounds(iopipestream& tex, const string& texengine) { if(havebounds) return; havebounds=true; - + setpen(tex,texengine,pentype); texbounds(width,height,depth,tex,label); - + if(width == 0.0 && height == 0.0 && depth == 0.0 && !size.empty()) texbounds(width,height,depth,tex,size); enabled=true; - + Align=inverse(T)*align; double scale0=max(fabs(Align.getx()),fabs(Align.gety())); if(scale0) Align *= 0.5/scale0; Align -= pair(0.5,0.5); - double Depth=(pentype.Baseline() == NOBASEALIGN) ? depth : + double Depth=(pentype.Baseline() == NOBASEALIGN) ? depth : -depth*Align.gety(); texAlign=Align; const double vertical=height+depth; @@ -118,9 +118,9 @@ void drawLabel::bounds(bbox& b, iopipestream& tex, boxvector& labelbounds, { string texengine=getSetting("tex"); if(texengine == "none") {b += position; return;} - + getbounds(tex,texengine); - + // alignment point pair p=position+Align; const double vertical=height+depth; @@ -129,7 +129,7 @@ void drawLabel::bounds(bbox& b, iopipestream& tex, boxvector& labelbounds, pair B=p+T*pair(-fuzz,vertical+fuzz); pair C=p+T*pair(width+fuzz,vertical+fuzz); pair D=p+T*pair(width+fuzz,-fuzz); - + if(pentype.Overwrite() != ALLOW && label != "") { size_t n=labelbounds.size(); box Box=box(A,B,C,D); @@ -139,7 +139,7 @@ void drawLabel::bounds(bbox& b, iopipestream& tex, boxvector& labelbounds, case SUPPRESS: labelwarning("suppressed"); case SUPPRESSQUIET: - suppress=true; + suppress=true; return; case MOVE: labelwarning("moved"); @@ -168,13 +168,13 @@ void drawLabel::bounds(bbox& b, iopipestream& tex, boxvector& labelbounds, labelbounds.resize(n+1); labelbounds[n]=Box; } - + Box=bbox(); Box += A; Box += B; Box += C; Box += D; - + b += Box; } @@ -203,10 +203,10 @@ void drawLabelPath::bounds(bbox& b, iopipestream& tex, boxvector&, bboxlist&) { string texengine=getSetting("tex"); if(texengine == "none") {b += position; return;} - + getbounds(tex,texengine); double L=p.arclength(); - + double s1,s2; if(justify == "l") { s1=0.0; @@ -220,30 +220,30 @@ void drawLabelPath::bounds(bbox& b, iopipestream& tex, boxvector&, bboxlist&) s1=s-h; s2=s+h; } - + double Sx=shift.getx(); double Sy=shift.gety(); s1 += Sx; s2 += Sx; - + if(width > L || (!p.cyclic() && (s1 < 0 || s2 > L))) { ostringstream buf; buf << "Cannot fit label \"" << label << "\" to path"; reportError(buf); } - + path q=p.subpath(p.arctime(s1),p.arctime(s2)); - + b += q.bounds(Sy,Sy+height); Box=b; } - + bool drawLabelPath::write(texfile *out, const bbox&) { bbox b=Box; double Hoffset=getSetting("inlinetex") ? b.right : b.left; b.shift(pair(-Hoffset,-b.bottom)); - + checkbounds(); if(drawLabel::pentype.invisible()) return true; out->setpen(drawLabel::pentype); -- cgit v1.2.3