eliminated some global vars

This commit is contained in:
Stefan Frederik 2020-12-23 05:07:39 +01:00
parent 11a054946b
commit d0fb5f94e0
11 changed files with 116 additions and 94 deletions

View File

@ -1283,7 +1283,8 @@ void calc_drawing_bbox(xRect *boundbox, int selected)
updatebbox(count,boundbox,&tmp);
}
if(has_x) for(i=0;i<xctx->texts;i++)
{
{
int no_of_lines, longest_line;
if(selected == 1 && !xctx->text[i].sel) continue;
if(selected == 2) continue;
#if HAS_CAIRO==1
@ -1293,7 +1294,7 @@ void calc_drawing_bbox(xRect *boundbox, int selected)
xctx->text[i].yscale,xctx->text[i].rot, xctx->text[i].flip,
xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0, xctx->text[i].y0,
&tmp.x1,&tmp.y1, &tmp.x2,&tmp.y2) ) {
&tmp.x1,&tmp.y1, &tmp.x2,&tmp.y2, &no_of_lines, &longest_line) ) {
count++;
updatebbox(count,boundbox,&tmp);
}
@ -2101,7 +2102,7 @@ void new_polygon(int what)
#if HAS_CAIRO==1
int text_bbox(const char *str, double xscale, double yscale,
short rot, short flip, int hcenter, int vcenter, double x1,double y1, double *rx1, double *ry1,
double *rx2, double *ry2)
double *rx2, double *ry2, int *cairo_lines, int *cairo_longest_line)
{
int c=0;
char *str_ptr, *s = NULL;
@ -2112,7 +2113,7 @@ int text_bbox(const char *str, double xscale, double yscale,
/* will not match exactly font metrics when doing ps/svg output , but better than nothing */
if(!has_x) return text_bbox_nocairo(str, xscale, yscale, rot, flip, hcenter, vcenter, x1, y1,
rx1, ry1, rx2, ry2);
rx1, ry1, rx2, ry2, cairo_lines, cairo_longest_line);
size = xscale*52.*cairo_font_scale;
/* if(size*xctx->mooz>800.) { */
@ -2123,14 +2124,14 @@ int text_bbox(const char *str, double xscale, double yscale,
ww=0.; hh=1.;
c=0;
cairo_lines=1;
*cairo_lines=1;
my_strdup2(1158, &s, str);
str_ptr = s;
while( s && s[c] ) {
if(s[c] == '\n') {
s[c]='\0';
hh++;
cairo_lines++;
(*cairo_lines)++;
if(str_ptr[0]!='\0') {
cairo_text_extents(xctx->cairo_ctx, str_ptr, &ext);
maxw = ext.x_advance > ext.width ? ext.x_advance : ext.width;
@ -2149,7 +2150,7 @@ int text_bbox(const char *str, double xscale, double yscale,
}
my_free(1159, &s);
hh = hh*fext.height*cairo_font_line_spacing;
cairo_longest_line = ww;
*cairo_longest_line = ww;
*rx1=x1;*ry1=y1;
if(hcenter) {
@ -2186,26 +2187,27 @@ int text_bbox(const char *str, double xscale, double yscale,
}
int text_bbox_nocairo(const char * str,double xscale, double yscale,
short rot, short flip, int hcenter, int vcenter, double x1,double y1, double *rx1, double *ry1,
double *rx2, double *ry2)
double *rx2, double *ry2, int *cairo_lines, int *cairo_longest_line)
#else
int text_bbox(const char * str,double xscale, double yscale,
short rot, short flip, int hcenter, int vcenter, double x1,double y1, double *rx1, double *ry1,
double *rx2, double *ry2)
double *rx2, double *ry2, int *cairo_lines, int *cairo_longest_line)
#endif
{
register int c=0, length =0;
double w, h;
w=0;h=1;
cairo_lines = 1;
*cairo_lines = 1;
if(str!=NULL) while( str[c] )
{
if((str)[c++]=='\n') {cairo_lines++; h++; length=0;}
if((str)[c++]=='\n') {(*cairo_lines)++; h++; length=0;}
else length++;
if(length > w)
w = length;
}
w *= (FONTWIDTH+FONTWHITESPACE)*xscale*nocairo_font_xscale;
*cairo_longest_line = w;
h *= (FONTHEIGHT+FONTDESCENT+FONTWHITESPACE)*yscale*nocairo_font_yscale;
*rx1=x1;*ry1=y1;
if( rot==0) *ry1-=nocairo_vert_correct;

View File

@ -136,20 +136,19 @@ int set_text_custom_font(xText *txt)
#if HAS_CAIRO==1
static void cairo_draw_string_line(cairo_t *c_ctx, char *s,
double x, double y, short rot, short flip,
int lineno, double fontheight, double fontascent, double fontdescent, int llength)
int lineno, double fontheight, double fontascent, double fontdescent,
int llength, int no_of_lines, int longest_line)
{
double ix, iy;
short rot1;
int line_delta;
int line_offset;
double lines;
double vc; /* 20171121 vert correct */
if(s==NULL) return;
if(llength==0) return;
line_delta = lineno*fontheight*cairo_font_line_spacing;
lines = (cairo_lines-1)*fontheight*cairo_font_line_spacing;
line_offset=cairo_longest_line;
lines = (no_of_lines-1)*fontheight*cairo_font_line_spacing;
ix=X_TO_SCREEN(x);
iy=Y_TO_SCREEN(y);
@ -160,13 +159,13 @@ static void cairo_draw_string_line(cairo_t *c_ctx, char *s,
vc = cairo_vert_correct*xctx->mooz; /* converted to device (pixel) space */
if( rot==0 && flip==0) {iy+=line_delta+fontascent-vc;}
else if(rot==1 && flip==0) {iy+=line_offset;ix=ix-fontheight+fontascent+vc-lines+line_delta;}
else if(rot==2 && flip==0) {iy=iy-fontheight-lines+line_delta+fontascent+vc; ix=ix-line_offset;}
else if(rot==1 && flip==0) {iy+=longest_line;ix=ix-fontheight+fontascent+vc-lines+line_delta;}
else if(rot==2 && flip==0) {iy=iy-fontheight-lines+line_delta+fontascent+vc; ix=ix-longest_line;}
else if(rot==3 && flip==0) {ix+=line_delta+fontascent-vc;}
else if(rot==0 && flip==1) {ix=ix-line_offset;iy+=line_delta+fontascent-vc;}
else if(rot==0 && flip==1) {ix=ix-longest_line;iy+=line_delta+fontascent-vc;}
else if(rot==1 && flip==1) {ix=ix-fontheight+line_delta-lines+fontascent+vc;}
else if(rot==2 && flip==1) {iy=iy-fontheight-lines+line_delta+fontascent+vc;}
else if(rot==3 && flip==1) {iy=iy+line_offset;ix+=line_delta+fontascent-vc;}
else if(rot==3 && flip==1) {iy=iy+longest_line;ix+=line_delta+fontascent-vc;}
cairo_save(c_ctx);
cairo_translate(c_ctx, ix, iy);
@ -186,7 +185,7 @@ void draw_string(int layer, int what, const char *str, short rot, short flip, in
int lineno=0;
double size;
cairo_font_extents_t fext;
int llength=0;
int llength=0, no_of_lines, longest_line;
(void)what; /* UNUSED in cairo version, avoid compiler warning */
if(str==NULL || !has_x ) return;
@ -195,8 +194,10 @@ void draw_string(int layer, int what, const char *str, short rot, short flip, in
if(size*xctx->mooz<3.0) return; /* too small */
if(size*xctx->mooz>1600) return; /* too big */
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter, x,y, &textx1,&texty1,&textx2,&texty2);
if(!textclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,textx1,texty1,textx2,texty2)) {
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter, x,y,
&textx1,&texty1,&textx2,&texty2, &no_of_lines, &longest_line);
if(!textclip(xctx->areax1,xctx->areay1,xctx->areax2,
xctx->areay2,textx1,texty1,textx2,texty2)) {
return;
}
@ -234,11 +235,11 @@ void draw_string(int layer, int what, const char *str, short rot, short flip, in
c=*ss;
if(c=='\n' || c==0) {
*ss='\0';
/*fprintf(errfp, "cairo_draw_string(): tt=%s, longest line: %d\n", tt, cairo_longest_line); */
/*fprintf(errfp, "cairo_draw_string(): tt=%s, longest line: %d\n", tt, longest_line); */
if(draw_window) cairo_draw_string_line(xctx->cairo_ctx, tt, x, y, rot, flip,
lineno, fext.height, fext.ascent, fext.descent, llength);
lineno, fext.height, fext.ascent, fext.descent, llength, no_of_lines, longest_line);
if(draw_pixmap) cairo_draw_string_line(xctx->cairo_save_ctx, tt, x, y, rot, flip,
lineno, fext.height, fext.ascent, fext.descent, llength);
lineno, fext.height, fext.ascent, fext.descent, llength, no_of_lines, longest_line);
lineno++;
if(c==0) break;
*ss='\n';
@ -265,7 +266,7 @@ void draw_string(int layer, int what, const char *str, short rot, short flip, in
register int pos=0,pos2=0;
register unsigned int cc;
register double *char_ptr_x1,*char_ptr_y1,*char_ptr_x2,*char_ptr_y2;
register int i,lines;
register int i,lines, no_of_lines, longest_line;
if(str==NULL || !has_x ) return;
dbg(2, "draw_string(): string=%s\n",str);
@ -274,10 +275,12 @@ void draw_string(int layer, int what, const char *str, short rot, short flip, in
return;
}
else {
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter, x1,y1, &textx1,&texty1,&textx2,&texty2);
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter, x1,y1,
&textx1,&texty1,&textx2,&texty2, &no_of_lines, &longest_line);
xscale*=nocairo_font_xscale;
yscale*=nocairo_font_yscale;
if(!textclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,textx1,texty1,textx2,texty2)) return;
if(!textclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,
textx1,texty1,textx2,texty2)) return;
x1=textx1;y1=texty1;
if(rot&1) {y1=texty2;rot=3;}
else rot=0;
@ -319,9 +322,11 @@ void draw_string(int layer, int what, const char *str, short rot, short flip, in
void draw_temp_string(GC gctext, int what, const char *str, short rot, short flip, int hcenter, int vcenter,
double x1,double y1, double xscale, double yscale)
{
int tmp;
if(!has_x) return;
dbg(2, "draw_string(): string=%s\n",str);
if(!text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter, x1,y1, &textx1,&texty1,&textx2,&texty2)) return;
if(!text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter, x1,y1,
&textx1,&texty1,&textx2,&texty2, &tmp, &tmp)) return;
drawtemprect(gctext,what, textx1,texty1,textx2,texty2);
}

View File

@ -704,7 +704,7 @@ void edit_text_property(int x)
#if HAS_CAIRO==1
int customfont;
#endif
int sel, k, text_changed;
int sel, k, text_changed, tmp;
int c,l, preserve;
double xx1,yy1,xx2,yy2;
double pcx,pcy; /* pin center 20070317 */
@ -759,9 +759,9 @@ void edit_text_property(int x)
customfont = set_text_custom_font(&xctx->text[sel]);
#endif
text_bbox(xctx->text[sel].txt_ptr, xctx->text[sel].xscale,
xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter, xctx->text[sel].vcenter,
xctx->text[sel].x0, xctx->text[sel].y0,
&xx1,&yy1,&xx2,&yy2);
xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter,
xctx->text[sel].vcenter, xctx->text[sel].x0, xctx->text[sel].y0,
&xx1,&yy1,&xx2,&yy2, &tmp, &tmp);
#if HAS_CAIRO==1
if(customfont) cairo_restore(xctx->cairo_ctx);
#endif
@ -780,9 +780,9 @@ void edit_text_property(int x)
customfont = set_text_custom_font(&xctx->text[sel]);
#endif
text_bbox(xctx->text[sel].txt_ptr, xctx->text[sel].xscale,
xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter, xctx->text[sel].vcenter,
xctx->text[sel].x0, xctx->text[sel].y0,
&xx1,&yy1,&xx2,&yy2);
xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter,
xctx->text[sel].vcenter, xctx->text[sel].x0, xctx->text[sel].y0,
&xx1,&yy1,&xx2,&yy2, &tmp, &tmp);
#if HAS_CAIRO==1
if(customfont) cairo_restore(xctx->cairo_ctx);
#endif
@ -844,9 +844,9 @@ void edit_text_property(int x)
customfont = set_text_custom_font(&xctx->text[sel]);
#endif
text_bbox(xctx->text[sel].txt_ptr, xctx->text[sel].xscale,
xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter, xctx->text[sel].vcenter,
xctx->text[sel].x0, xctx->text[sel].y0,
&xx1,&yy1,&xx2,&yy2);
xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter,
xctx->text[sel].vcenter, xctx->text[sel].x0, xctx->text[sel].y0,
&xx1,&yy1,&xx2,&yy2, &tmp, &tmp);
#if HAS_CAIRO==1
if(customfont) cairo_restore(xctx->cairo_ctx);
#endif

View File

@ -273,7 +273,7 @@ void find_closest_text(double mx,double my)
{
short rot,flip;
double xx1,xx2,yy1,yy2;
int i,r=-1;
int i,r=-1, tmp;
double threshold = CADWIREMINDIST * CADWIREMINDIST * cadgrid * cadgrid / 400;
#if HAS_CAIRO==1
int customfont;
@ -286,9 +286,10 @@ void find_closest_text(double mx,double my)
customfont = set_text_custom_font(&xctx->text[i]);
#endif
text_bbox(xctx->text[i].txt_ptr,
xctx->text[i].xscale, xctx->text[i].yscale, rot, flip, xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].xscale, xctx->text[i].yscale, rot, flip,
xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0, xctx->text[i].y0,
&xx1,&yy1, &xx2,&yy2);
&xx1,&yy1, &xx2,&yy2, &tmp, &tmp);
#if HAS_CAIRO==1
if(customfont) cairo_restore(xctx->cairo_ctx);
#endif

View File

@ -217,8 +217,6 @@ int enable_drill=0; /* 20171211 pass net hilights through components with 'propa
size_t get_tok_value_size;
size_t get_tok_size;
int batch_mode = 0; /* no tcl console if set; batch mode */
int cairo_longest_line;
int cairo_lines;
int show_erc=1;
/* following data is relative to the current schematic */

View File

@ -493,7 +493,7 @@ void find_inst_to_be_redrawn(const char *node)
void copy_objects(int what)
{
int c, i, n, k;
int c, i, n, k /*, tmp */ ;
/* xRect tmp; */
double angle;
int newpropcnt;
@ -785,9 +785,10 @@ void copy_objects(int what)
customfont = set_text_custom_font(&xctx->text[n]);
#endif
text_bbox(xctx->text[n].txt_ptr, xctx->text[n].xscale,
xctx->text[n].yscale, xctx->text[n].rot,xctx->text[n].flip, xctx->text[n].hcenter, xctx->text[n].vcenter,
xctx->text[n].yscale, xctx->text[n].rot,xctx->text[n].flip,
xctx->text[n].hcenter, xctx->text[n].vcenter,
xctx->text[n].x0, xctx->text[n].y0,
&xctx->rx1,&xctx->ry1, &xctx->rx2,&xctx->ry2);
&xctx->rx1,&xctx->ry1, &xctx->rx2,&xctx->ry2, &tmp, &tmp);
#if HAS_CAIRO==1
if(customfont) cairo_restore(xctx->cairo_ctx);
#endif
@ -980,7 +981,7 @@ void copy_objects(int what)
/* merge param unused, RFU */
void move_objects(int what, int merge, double dx, double dy)
{
int c, i, n, k;
int c, i, n, k, tmpint;
xRect tmp;
double angle;
double tx1,ty1; /* temporaries for swapping coordinates 20070302 */
@ -1208,9 +1209,11 @@ void move_objects(int what, int merge, double dx, double dy)
if( p->sel==SELECTED || p->selected_point[j]) {
if(xctx->rotatelocal) {
ROTATION(xctx->move_rot, xctx->move_flip, savex0, savey0, p->x[j], p->y[j], xctx->rx1,xctx->ry1);
ROTATION(xctx->move_rot, xctx->move_flip, savex0, savey0, p->x[j], p->y[j],
xctx->rx1,xctx->ry1);
} else {
ROTATION(xctx->move_rot, xctx->move_flip, xctx->x1, xctx->y_1, p->x[j], p->y[j], xctx->rx1,xctx->ry1);
ROTATION(xctx->move_rot, xctx->move_flip, xctx->x1, xctx->y_1, p->x[j], p->y[j],
xctx->rx1,xctx->ry1);
}
p->x[j] = xctx->rx1+xctx->deltax;
@ -1229,7 +1232,8 @@ void move_objects(int what, int merge, double dx, double dy)
arc_bbox(xctx->arc[c][n].x, xctx->arc[c][n].y, xctx->arc[c][n].r, 0, 360,
&tmp.x1, &tmp.y1, &tmp.x2, &tmp.y2);
else
arc_bbox(xctx->arc[c][n].x, xctx->arc[c][n].y, xctx->arc[c][n].r, xctx->arc[c][n].a, xctx->arc[c][n].b,
arc_bbox(xctx->arc[c][n].x, xctx->arc[c][n].y, xctx->arc[c][n].r,
xctx->arc[c][n].a, xctx->arc[c][n].b,
&tmp.x1, &tmp.y1, &tmp.x2, &tmp.y2);
dbg(1, "move_objects(): arc_bbox: %g %g %g %g\n", tmp.x1, tmp.y1, tmp.x2, tmp.y2);
bbox(ADD, tmp.x1, tmp.y1, tmp.x2, tmp.y2);
@ -1367,7 +1371,8 @@ void move_objects(int what, int merge, double dx, double dy)
#endif
text_bbox(xctx->text[n].txt_ptr, xctx->text[n].xscale,
xctx->text[n].yscale, xctx->text[n].rot,xctx->text[n].flip, xctx->text[n].hcenter,
xctx->text[n].vcenter, xctx->text[n].x0, xctx->text[n].y0, &xctx->rx1,&xctx->ry1, &xctx->rx2,&xctx->ry2);
xctx->text[n].vcenter, xctx->text[n].x0, xctx->text[n].y0,
&xctx->rx1,&xctx->ry1, &xctx->rx2,&xctx->ry2, &tmpint, &tmpint);
#if HAS_CAIRO==1
if(customfont) cairo_restore(xctx->cairo_ctx);
#endif

View File

@ -200,8 +200,9 @@ static void ps_drawline(int gc, double linex1,double liney1,double linex2,double
static void ps_draw_string_line(int layer, char *s, double x, double y, double size, short rot, short flip,
int lineno, double fontheight, double fontascent, double fontdescent, int llength)
static void ps_draw_string_line(int layer, char *s, double x, double y, double size,
short rot, short flip, int lineno, double fontheight, double fontascent,
double fontdescent, int llength, int no_of_lines, int longest_line)
{
double ix, iy;
short rot1;
@ -212,7 +213,7 @@ static void ps_draw_string_line(int layer, char *s, double x, double y, double s
if(llength==0) return;
line_delta = lineno*fontheight;
lines = (cairo_lines-1)*fontheight;
lines = (no_of_lines-1)*fontheight;
ix=X_TO_PS(x);
iy=Y_TO_PS(y);
@ -271,16 +272,18 @@ static void ps_draw_string(int layer, const char *str, short rot, short flip, in
char c;
int lineno=0;
double size, height, ascent, descent;
int llength=0;
int llength=0, no_of_lines, longest_line;
if(str==NULL || !has_x ) return;
size = xscale*53.;
height = size*xctx->mooz * 1.147; /* was 1.147 */
ascent = size*xctx->mooz * 0.808; /* was 0.908 */
descent = size*xctx->mooz * 0.219; /* was 0.219 */
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter, x,y, &textx1,&texty1,&textx2,&texty2);
/* fprintf(fd, "%% text bbox: %g %g\n", xctx->mooz * (textx2 - textx1), xctx->mooz * (texty2 - texty1)); */
if(!textclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,textx1,texty1,textx2,texty2)) {
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter,
x,y, &textx1,&texty1,&textx2,&texty2, &no_of_lines, &longest_line);
if(!textclip(xctx->areax1,xctx->areay1,xctx->areax2,
xctx->areay2,textx1,texty1,textx2,texty2)) {
return;
}
if(hcenter) {
@ -310,7 +313,8 @@ static void ps_draw_string(int layer, const char *str, short rot, short flip, in
c=*ss;
if(c=='\n' || c==0) {
*ss='\0';
ps_draw_string_line(layer, tt, x, y, size, rot, flip, lineno, height, ascent, descent, llength);
ps_draw_string_line(layer, tt, x, y, size, rot, flip, lineno,
height, ascent, descent, llength, no_of_lines, longest_line);
lineno++;
if(c==0) break;
*ss='\n';
@ -332,13 +336,15 @@ static void old_ps_draw_string(int gctext, const char *str,
{
double a,yy,curr_x1,curr_y1,curr_x2,curr_y2,rx1,rx2,ry1,ry2;
int pos=0,cc,pos2=0;
int i;
int i, no_of_lines, longest_line;
if(str==NULL) return;
#if HAS_CAIRO==1
text_bbox_nocairo(str, xscale, yscale, rot, flip, hcenter, vcenter, x1,y1, &rx1,&ry1,&rx2,&ry2);
text_bbox_nocairo(str, xscale, yscale, rot, flip, hcenter, vcenter,
x1,y1, &rx1,&ry1,&rx2,&ry2, &no_of_lines, &longest_line);
#else
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter, x1,y1, &rx1,&ry1,&rx2,&ry2);
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter,
x1,y1, &rx1,&ry1,&rx2,&ry2, &no_of_lines);
#endif
xscale*=nocairo_font_xscale;
yscale*=nocairo_font_yscale;

View File

@ -1497,10 +1497,11 @@ void calc_symbol_bbox(int pos)
*
* for(i=0;i<lastt;i++)
* {
int tmp;
* count++;
* rot=tt[i].rot;flip=tt[i].flip;
* text_bbox(tt[i].txt_ptr, tt[i].xscale, tt[i].yscale, rot, flip,
* tt[i].x0, tt[i].y0, &rx1,&ry1,&rx2,&ry2);
* tt[i].x0, tt[i].y0, &rx1,&ry1,&rx2,&ry2, &tmp);
* tmp.x1=rx1;tmp.y1=ry1;tmp.x2=rx2;tmp.y2=ry2;
* updatebbox(count,&boundbox,&tmp);
* }

View File

@ -30,7 +30,7 @@ static double xx1,yy1,xx2,yy2;
void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2)
{
int j;
int j, no_of_lines, tmp;
xText text;
const char *tmp_txt;
short rot,flip;
@ -74,7 +74,7 @@ void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2)
text_bbox(tmp_txt, text.xscale, text.yscale,
(text.rot + ( (sym_flip && (text.rot & 1) ) ? sym_rot+2 : sym_rot)) &0x3,
sym_flip ^ text.flip, text.hcenter, text.vcenter,
x0+text_x0,y0+text_y0, &xx1,&yy1,&xx2,&yy2);
x0+text_x0,y0+text_y0, &xx1,&yy1,&xx2,&yy2, &tmp, &tmp);
#if HAS_CAIRO==1
if(customfont) cairo_restore(xctx->cairo_ctx);
#endif
@ -199,7 +199,7 @@ static void del_rect_line_arc_poly(void)
void delete(void)
{
int i, j, n;
int i, j, n, tmp;
#if HAS_CAIRO==1
int customfont;
#endif
@ -268,9 +268,9 @@ void delete(void)
customfont = set_text_custom_font(&xctx->text[i]);
#endif
text_bbox(xctx->text[i].txt_ptr, xctx->text[i].xscale,
xctx->text[i].yscale, select_rot, select_flip, xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0, xctx->text[i].y0,
&xx1,&yy1, &xx2,&yy2);
xctx->text[i].yscale, select_rot, select_flip, xctx->text[i].hcenter,
xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0,
&xx1,&yy1, &xx2,&yy2, &tmp, &tmp);
#if HAS_CAIRO==1
if(customfont) cairo_restore(xctx->cairo_ctx);
#endif
@ -886,9 +886,9 @@ unsigned short select_object(double mx,double my, unsigned short select_mode, in
return sel.type;
}
void select_inside(double x1,double y1, double x2, double y2, int sel) /* 20150927 added unselect (sel param) */
void select_inside(double x1,double y1, double x2, double y2, int sel) /*added unselect (sel param) */
{
int c,i;
int c,i, tmpint;
double x, y, r, a, b, xa, ya, xb, yb; /* arc */
xRect tmp;
#if HAS_CAIRO==1
@ -924,7 +924,7 @@ void select_inside(double x1,double y1, double x2, double y2, int sel) /* 201509
xctx->text[i].xscale, xctx->text[i].yscale, select_rot, select_flip,
xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0, xctx->text[i].y0,
&xx1,&yy1, &xx2,&yy2);
&xx1,&yy1, &xx2,&yy2, &tmpint, &tmpint);
#if HAS_CAIRO==1
if(customfont) cairo_restore(xctx->cairo_ctx);
#endif

View File

@ -185,13 +185,13 @@ static void svg_drawline(int gc, int bus, double linex1,double liney1,double lin
}
}
static void svg_draw_string_line(int layer, char *s, double x, double y, double size, short rot, short flip,
int lineno, double fontheight, double fontascent, double fontdescent, int llength)
static void svg_draw_string_line(int layer, char *s, double x, double y, double size,
short rot, short flip, int lineno, double fontheight, double fontascent,
double fontdescent, int llength, int no_of_lines, int longest_line)
{
double ix, iy;
short rot1;
int line_delta;
int line_offset;
double lines;
char col[20];
if(color_ps)
@ -205,8 +205,7 @@ static void svg_draw_string_line(int layer, char *s, double x, double y, double
if(llength==0) return;
line_delta = lineno*fontheight;
lines = (cairo_lines-1)*fontheight;
line_offset=cairo_longest_line;
lines = (no_of_lines-1)*fontheight;
ix=X_TO_SVG(x);
iy=Y_TO_SVG(y);
@ -215,13 +214,13 @@ static void svg_draw_string_line(int layer, char *s, double x, double y, double
} else rot1=0;
if( rot==0 && flip==0) {iy+=line_delta+fontascent;}
else if(rot==1 && flip==0) {iy+=line_offset;ix=ix-fontheight+fontascent-lines+line_delta;}
else if(rot==2 && flip==0) {iy=iy-fontheight-lines+line_delta+fontascent; ix=ix-line_offset;}
else if(rot==1 && flip==0) {iy+=longest_line;ix=ix-fontheight+fontascent-lines+line_delta;}
else if(rot==2 && flip==0) {iy=iy-fontheight-lines+line_delta+fontascent; ix=ix-longest_line;}
else if(rot==3 && flip==0) {ix+=line_delta+fontascent;}
else if(rot==0 && flip==1) {ix=ix-line_offset;iy+=line_delta+fontascent;}
else if(rot==0 && flip==1) {ix=ix-longest_line;iy+=line_delta+fontascent;}
else if(rot==1 && flip==1) {ix=ix-fontheight+line_delta-lines+fontascent;}
else if(rot==2 && flip==1) {iy=iy-fontheight-lines+line_delta+fontascent;}
else if(rot==3 && flip==1) {iy=iy+line_offset;ix+=line_delta+fontascent;}
else if(rot==3 && flip==1) {iy=iy+longest_line;ix+=line_delta+fontascent;}
fprintf(fd,"<text fill=\"%s\" xml:space=\"preserve\" font-size=\"%g\" ", col, size*xctx->mooz);
if(strcmp(svg_font_weight, "normal")) fprintf(fd, "font-weight=\"%s\" ", svg_font_weight);
@ -257,13 +256,15 @@ static void svg_draw_string(int layer, const char *str, short rot, short flip, i
char c;
int lineno=0;
double size, height, ascent, descent;
int llength=0;
int llength=0, no_of_lines, longest_line;
if(str==NULL) return;
size = xscale*52.;
height = size*xctx->mooz * 1.147;
ascent = size*xctx->mooz * 0.908;
descent = size*xctx->mooz * 0.219;
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter, x,y, &textx1,&texty1,&textx2,&texty2);
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter, x,y,
&textx1,&texty1,&textx2,&texty2, &no_of_lines, &longest_line);
if(!textclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,textx1,texty1,textx2,texty2)) {
return;
}
@ -294,7 +295,8 @@ static void svg_draw_string(int layer, const char *str, short rot, short flip, i
c=*ss;
if(c=='\n' || c==0) {
*ss='\0';
svg_draw_string_line(layer, tt, x, y, size, rot, flip, lineno, height, ascent, descent, llength);
svg_draw_string_line(layer, tt, x, y, size, rot, flip, lineno, height,
ascent, descent, llength, no_of_lines, longest_line);
lineno++;
if(c==0) break;
*ss='\n';
@ -317,13 +319,15 @@ static void old_svg_draw_string(int layer, const char *str,
{
double a,yy,curr_x1,curr_y1,curr_x2,curr_y2,rx1,rx2,ry1,ry2;
int pos=0,cc,pos2=0;
int i;
int i, no_of_lines, longest_line;
if(str==NULL) return;
#if HAS_CAIRO==1
text_bbox_nocairo(str, xscale, yscale, rot, flip, hcenter, vcenter, x,y, &rx1,&ry1,&rx2,&ry2);
text_bbox_nocairo(str, xscale, yscale, rot, flip, hcenter, vcenter,
x,y, &rx1,&ry1,&rx2,&ry2, &no_of_lines, &longest_line);
#else
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter, x,y, &rx1,&ry1,&rx2,&ry2);
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter, x,y,
&rx1,&ry1,&rx2,&ry2, &no_of_lines, &longest_line);
#endif
xscale*=nocairo_font_xscale;
yscale*=nocairo_font_yscale;

View File

@ -758,8 +758,6 @@ extern int show_pin_net_names;
extern char svg_font_name[80];
/* CAIRO specific global variables */
extern char cairo_font_name[80];
extern int cairo_longest_line;
extern int cairo_lines;
extern double cairo_font_scale; /* default: 1.0, allows to adjust font size */
extern double nocairo_font_xscale;
extern double nocairo_font_yscale;
@ -845,8 +843,9 @@ extern void arc_bbox(double x, double y, double r, double a, double b,
extern void bbox(int what,double x1,double y1, double x2, double y2);
extern int set_text_custom_font(xText *txt);
extern int text_bbox(const char * str,double xscale, double yscale,
short rot, short flip, int hcenter, int vcenter, double x1,double y1, double *rx1, double *ry1,
double *rx2, double *ry2);
short rot, short flip, int hcenter, int vcenter,
double x1,double y1, double *rx1, double *ry1,
double *rx2, double *ry2, int *cairo_lines, int *longest_line);
extern int get_color(int value);
@ -860,8 +859,9 @@ extern void hash_instances(void); /* 20171203 insert instance bbox in spatial h
#if HAS_CAIRO==1
extern int text_bbox_nocairo(const char * str,double xscale, double yscale,
short rot, short flip, int hcenter, int vcenter, double x1,double y1, double *rx1, double *ry1,
double *rx2, double *ry2);
short rot, short flip, int hcenter, int vcenter,
double x1,double y1, double *rx1, double *ry1,
double *rx2, double *ry2, int *cairo_lines, int *longest_line);
#endif
extern unsigned short select_object(double mx,double my, unsigned short sel_mode,