diff options
Diffstat (limited to 'Build/source/utils/asymptote/drawlabel.cc')
-rw-r--r-- | Build/source/utils/asymptote/drawlabel.cc | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/Build/source/utils/asymptote/drawlabel.cc b/Build/source/utils/asymptote/drawlabel.cc index b6f0590ae1c..484ecf3cb89 100644 --- a/Build/source/utils/asymptote/drawlabel.cc +++ b/Build/source/utils/asymptote/drawlabel.cc @@ -25,8 +25,8 @@ void drawLabel::labelwarning(const char *action) << "\" " << action << " to avoid overwriting" << endl; } -int drawLabel::wait(iopipestream &tex, const char *s, const char **abort, - bool ignore) +int wait(iopipestream &tex, const char *s, const char **abort, + bool ignore=false) { int rc=tex.wait(s,abort); if(rc > 0) { @@ -49,12 +49,13 @@ int drawLabel::wait(iopipestream &tex, const char *s, const char **abort, return rc; } -bool drawLabel::texbounds(iopipestream& tex, string& s, const char **abort, - bool warn) +bool texbounds(double& width, double& height, double& depth, + iopipestream& tex, string& s, const char **abort, bool warn, + bool Inline) { string texbuf; tex << "\\setbox\\ASYbox=\\hbox{" << stripblanklines(s) << "}\n\n"; - int rc=wait(tex,texready.c_str(),abort,getSetting<bool>("inlinetex")); + int rc=wait(tex,texready.c_str(),abort,Inline); if(rc) { tex << "\\show 0\n"; tex.wait("\n*"); @@ -116,26 +117,33 @@ inline double urand() return rand()*factor-1.0; } -void drawLabel::getbounds(iopipestream& tex, const string& texengine) +void setpen(iopipestream& tex, const string& texengine, const pen& pentype) { - if(havebounds) return; - havebounds=true; - const char **abort=texabort(texengine); bool Latex=latex(texengine); if(Latex) { - if(setlatexfont(tex,pentype,lastpen)) + if(setlatexfont(tex,pentype,drawElement::lastpen)) wait(tex,"\n*",abort); } - if(settexfont(tex,pentype,lastpen,Latex)) + if(settexfont(tex,pentype,drawElement::lastpen,Latex)) wait(tex,"\n*",abort); - lastpen=pentype; - + drawElement::lastpen=pentype; +} + +void drawLabel::getbounds(iopipestream& tex, const string& texengine) +{ + if(havebounds) return; + havebounds=true; + + const char **abort=texabort(texengine); + setpen(tex,texengine,pentype); + bool nullsize=size.empty(); - if(!texbounds(tex,label,abort,nullsize) && !nullsize) - texbounds(tex,size,abort,false); + if(!texbounds(width,height,depth,tex,label,abort,nullsize, + getSetting<bool>("inlinetex")) && !nullsize) + texbounds(width,height,depth,tex,size,abort,false); enabled=true; Align=inverse(T)*align; |