From f26a0c737e64bca4595be590e61d012da4c5f493 Mon Sep 17 00:00:00 2001 From: Stefan Schippers Date: Sat, 29 Aug 2020 11:58:50 +0200 Subject: [PATCH] Use text layer (color) attribute for text objects also in no-CAIRO builds --- src/actions.c | 3 +-- src/draw.c | 28 +++++++++++++++------------- src/move.c | 16 +++++++++++----- src/psprint.c | 17 ++++++++++++----- src/svgdraw.c | 15 ++++++++++++--- 5 files changed, 51 insertions(+), 28 deletions(-) diff --git a/src/actions.c b/src/actions.c index 10631b1b..e16d8a36 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2239,10 +2239,9 @@ void place_text(int draw_text, double mx, double my) if(strlayer[0]) textelement[lasttext].layer = atoi(strlayer); else textelement[lasttext].layer = -1; my_strdup(21, &textelement[lasttext].font, get_tok_value(textelement[lasttext].prop_ptr, "font", 0));/* 20171206 */ - textlayer = TEXTLAYER; - #ifdef HAS_CAIRO textlayer = textelement[lasttext].layer; if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; + #ifdef HAS_CAIRO textfont = textelement[lasttext].font; if(textfont && textfont[0]) { cairo_save(ctx); diff --git a/src/draw.c b/src/draw.c index da97f9fd..2b5a20b7 100644 --- a/src/draw.c +++ b/src/draw.c @@ -543,12 +543,10 @@ void draw_symbol(int what,int c, int n,int layer,int tmp_flip, int rot, ROTATION(0.0,0.0,text.x0,text.y0,x1,y1); textlayer = c; - #ifdef HAS_CAIRO if( !(c == PINLAYER && (inst_ptr[n].flags & 4))) { textlayer = symptr->txtptr[j].layer; if(textlayer < 0 || textlayer >= cadlayers) textlayer = c; } - #endif if((c == PINLAYER && inst_ptr[n].flags & 4) || enable_layer[textlayer]) { #ifdef HAS_CAIRO textfont = symptr->txtptr[j].font; @@ -563,6 +561,10 @@ void draw_symbol(int what,int c, int n,int layer,int tmp_flip, int rot, (text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3, flip^text.flip, text.hcenter, text.vcenter, x0+x1, y0+y1, text.xscale, text.yscale); + #ifndef HAS_CAIRO + drawrect(textlayer, END, 0.0, 0.0, 0.0, 0.0); + drawline(textlayer, END, 0.0, 0.0, 0.0, 0.0); + #endif #ifdef HAS_CAIRO if(textfont && textfont[0]) { cairo_restore(ctx); @@ -1618,17 +1620,12 @@ void draw(void) drawline(WIRELAYER, END, 0.0, 0.0, 0.0, 0.0); } if(draw_single_layer ==-1 || draw_single_layer==TEXTLAYER) { /* 20151117 */ - #ifndef HAS_CAIRO - drawline(TEXTLAYER,BEGIN, 0.0, 0.0, 0.0, 0.0); - drawrect(TEXTLAYER,BEGIN, 0.0, 0.0, 0.0, 0.0); - #endif for(i=0;i= cadlayers) textlayer = TEXTLAYER; + dbg(1, "draw(): drawing string %d = %s\n",i, textelement[i].txt_ptr); + #ifdef HAS_CAIRO textfont = textelement[i].font; /* 20171206 */ if(textfont && textfont[0]) { cairo_save(ctx); @@ -1637,6 +1634,11 @@ void draw(void) cairo_select_font_face (save_ctx, textfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); } #endif + + #ifndef HAS_CAIRO + drawline(textlayer,BEGIN, 0.0, 0.0, 0.0, 0.0); + drawrect(textlayer,BEGIN, 0.0, 0.0, 0.0, 0.0); + #endif draw_string(textlayer, ADD, textelement[i].txt_ptr, textelement[i].rot, textelement[i].flip, textelement[i].hcenter, textelement[i].vcenter, textelement[i].x0,textelement[i].y0, @@ -1647,11 +1649,11 @@ void draw(void) cairo_restore(save_ctx); } #endif + #ifndef HAS_CAIRO + drawrect(textlayer, END, 0.0, 0.0, 0.0, 0.0); + drawline(textlayer, END, 0.0, 0.0, 0.0, 0.0); + #endif } - #ifndef HAS_CAIRO - drawrect(TEXTLAYER, END, 0.0, 0.0, 0.0, 0.0); - drawline(TEXTLAYER, END, 0.0, 0.0, 0.0, 0.0); - #endif } } /* !only_probes, 20110112 */ draw_hilight_net(draw_window); diff --git a/src/move.c b/src/move.c index 425f6007..5d26b954 100644 --- a/src/move.c +++ b/src/move.c @@ -743,10 +743,10 @@ void copy_objects(int what) textelement[lasttext].xscale=textelement[n].xscale; textelement[lasttext].yscale=textelement[n].yscale; - textlayer = TEXTLAYER; - #ifdef HAS_CAIRO textlayer = textelement[lasttext].layer; /* 20171206 */ if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; + + #ifdef HAS_CAIRO textfont = textelement[lasttext].font; /* 20171206 */ if(textfont && textfont[0]) { cairo_save(ctx); @@ -759,6 +759,10 @@ void copy_objects(int what) textelement[lasttext].rot, textelement[lasttext].flip, textelement[lasttext].hcenter, textelement[lasttext].vcenter, rx1+deltax,ry1+deltay, textelement[lasttext].xscale, textelement[lasttext].yscale); + #ifndef HAS_CAIRO + drawrect(textlayer, END, 0.0, 0.0, 0.0, 0.0); + drawline(textlayer, END, 0.0, 0.0, 0.0, 0.0); + #endif #ifdef HAS_CAIRO if(textfont && textfont[0]) { /* cairo_select_font_face (ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); */ @@ -1208,11 +1212,9 @@ void move_objects(int what, int merge, double dx, double dy) ( (flip && (textelement[n].rot & 1) ) ? rot+2 : rot) ) & 0x3; textelement[n].flip=flip^textelement[n].flip; - /* 20171112 */ - textlayer = TEXTLAYER; - #ifdef HAS_CAIRO textlayer = textelement[n].layer; /* 20171206 */ if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; + #ifdef HAS_CAIRO textfont = textelement[n].font; /* 20171206 */ if(textfont && textfont[0]) { cairo_save(ctx); @@ -1225,6 +1227,10 @@ void move_objects(int what, int merge, double dx, double dy) textelement[n].rot, textelement[n].flip, textelement[n].hcenter, textelement[n].vcenter, textelement[n].x0, textelement[n].y0, textelement[n].xscale, textelement[n].yscale); + #ifndef HAS_CAIRO + drawrect(textlayer, END, 0.0, 0.0, 0.0, 0.0); + drawline(textlayer, END, 0.0, 0.0, 0.0, 0.0); + #endif #ifdef HAS_CAIRO if(textfont && textfont[0]) { /*cairo_select_font_face (ctx, cairo_font_name, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); */ diff --git a/src/psprint.c b/src/psprint.c index b6ecf9d9..f6d5c192 100644 --- a/src/psprint.c +++ b/src/psprint.c @@ -184,6 +184,7 @@ static void ps_draw_string(int gctext, char *str, yscale*=nocairo_font_yscale; if(!textclip(areax1,areay1,areax2,areay2,rx1,ry1,rx2,ry2)) return; + set_ps_colors(gctext); x1=rx1;y1=ry1; if(rot&1) {y1=ry2;rot=3;} else rot=0; @@ -251,7 +252,7 @@ static void ps_draw_symbol(int n,int layer,int tmp_flip, int rot, { /* a "for(i=0;itxtptr[j].layer; + if(textlayer < 0 || textlayer >= cadlayers) textlayer = layer; + } + ps_draw_string(textlayer, text.txt_ptr, (text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3, flip^text.flip, text.hcenter, text.vcenter, x0+x1, y0+y1, text.xscale, text.yscale); @@ -379,7 +385,7 @@ static void fill_ps_colors() void ps_draw(void) { double dx, dy, delta,scale; - int c,i; + int c,i, textlayer; char *tmp=NULL; /* 20161121 */ int old_grid; int modified_save; @@ -468,10 +474,11 @@ void ps_draw(void) restore_lw(); ps_drawgrid(); - set_ps_colors(TEXTLAYER); for(i=0;i= cadlayers) textlayer = TEXTLAYER; + ps_draw_string(textlayer, textelement[i].txt_ptr, textelement[i].rot, textelement[i].flip, textelement[i].hcenter, textelement[i].vcenter, textelement[i].x0,textelement[i].y0, textelement[i].xscale, textelement[i].yscale); diff --git a/src/svgdraw.c b/src/svgdraw.c index 2dfb3cf5..23a013ab 100644 --- a/src/svgdraw.c +++ b/src/svgdraw.c @@ -278,7 +278,7 @@ static void svg_draw_symbol(int n,int layer,int tmp_flip, int rot, { /* a "for(i=0;itxtptr[j].layer; + if(textlayer < 0 || textlayer >= cadlayers) textlayer = layer; + } + svg_draw_string(layer, text.txt_ptr, (text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3, flip^text.flip, text.hcenter, text.vcenter, @@ -408,7 +414,7 @@ static void fill_svg_colors() void svg_draw(void) { double dx, dy; - int c,i; + int c,i, textlayer; int filledrect; int old_grid; int modified_save; /* 20161121 */ @@ -488,7 +494,10 @@ void svg_draw(void) set_svg_colors(TEXTLAYER); for(i=0;i= cadlayers) textlayer = TEXTLAYER; + + svg_draw_string(textlayer, textelement[i].txt_ptr, textelement[i].rot, textelement[i].flip, textelement[i].hcenter, textelement[i].vcenter, textelement[i].x0,textelement[i].y0, textelement[i].xscale, textelement[i].yscale);