make svg/ps font naming consistent between tcl/c. Filter out some code if X not available (command mode)
This commit is contained in:
parent
779c789100
commit
ae11f27db0
|
|
@ -2106,7 +2106,9 @@ int text_bbox(const char *str, double xscale, double yscale,
|
|||
cairo_font_extents_t fext;
|
||||
double ww, hh, maxw;
|
||||
|
||||
if(!has_x) return 0;
|
||||
/* 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);
|
||||
size = xscale*52.*cairo_font_scale;
|
||||
|
||||
/* if(size*xctx->mooz>800.) { */
|
||||
|
|
|
|||
|
|
@ -139,8 +139,8 @@ int flat_netlist=0;
|
|||
int cadlayers=0;
|
||||
int hide_symbols = 0; /* draw only a bounding box for component instances and @symname, @name texts */
|
||||
int dark_colorscheme=1;
|
||||
char cairo_font_name[1024]="Sans Serif";
|
||||
char svg_font_name[1024]="Sans Serif";
|
||||
char cairo_font_name[1024]="SansSerif";
|
||||
char svg_font_name[1024]="SansSerif";
|
||||
double cairo_font_scale=1.0; /* default: 1.0, allows to adjust font size */
|
||||
double nocairo_font_xscale=0.85; /* match with cairo sizing */
|
||||
double nocairo_font_yscale=0.88; /* match with cairo sizing */
|
||||
|
|
|
|||
|
|
@ -1661,14 +1661,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
* xschem print pdf file.pdf
|
||||
*/
|
||||
else if(!strcmp(argv[1],"print") ) {
|
||||
int save_nodraw, save_draw_window, save_draw_pixmap;
|
||||
cmd_found = 1;
|
||||
save_nodraw = no_draw;
|
||||
save_draw_window = draw_window;
|
||||
save_draw_pixmap = draw_pixmap;
|
||||
no_draw = 1;
|
||||
draw_window = 0;
|
||||
draw_pixmap = 0;
|
||||
if(argc < 3) {
|
||||
Tcl_SetResult(interp, "xschem print needs at least 1 more arguments: plot_type", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
|
|
@ -1688,11 +1681,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
set_viewport_size(w, h, 0.8);
|
||||
zoom_full(0, 0, 2, 0.97);
|
||||
resetwin(1, 1, 1, w, h);
|
||||
no_draw = 0;
|
||||
draw_pixmap = 1;
|
||||
print_image();
|
||||
draw_pixmap = 0;
|
||||
no_draw = 1;
|
||||
save_restore_zoom(0);
|
||||
resetwin(1, 1, 1, 0, 0);
|
||||
change_linewidth(-1.);
|
||||
|
|
@ -1708,21 +1697,13 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
set_viewport_size(w, h, 0.8);
|
||||
zoom_box(x1, y1, x2, y2, 1.0);
|
||||
resetwin(1, 1, 1, w, h);
|
||||
no_draw = 0;
|
||||
draw_pixmap = 1;
|
||||
print_image();
|
||||
draw_pixmap = 0;
|
||||
no_draw = 1;
|
||||
save_restore_zoom(0);
|
||||
resetwin(1, 1, 1, 0, 0);
|
||||
change_linewidth(-1.);
|
||||
draw();
|
||||
} else {
|
||||
no_draw = 0;
|
||||
draw_pixmap = 1;
|
||||
print_image();
|
||||
draw_pixmap = 0;
|
||||
no_draw = 1;
|
||||
}
|
||||
}
|
||||
else if(!strcmp(argv[2],"svg")) {
|
||||
|
|
@ -1752,9 +1733,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
svg_draw();
|
||||
}
|
||||
}
|
||||
no_draw = save_nodraw;
|
||||
draw_window = save_draw_window;
|
||||
draw_pixmap = save_draw_pixmap;
|
||||
draw();
|
||||
Tcl_ResetResult(interp);
|
||||
}
|
||||
|
|
|
|||
50
src/select.c
50
src/select.c
|
|
@ -444,18 +444,18 @@ void bbox(int what,double x1,double y1, double x2, double y2)
|
|||
xctx->xrect[0].width = xctx->areaw-4*INT_WIDTH(xctx->lw);
|
||||
xctx->xrect[0].height = xctx->areah-4*INT_WIDTH(xctx->lw);
|
||||
|
||||
XSetClipMask(display, xctx->gctiled, None); /* 20171110 optimization, clipping already done in software */
|
||||
|
||||
for(i=0;i<cadlayers;i++)
|
||||
{
|
||||
XSetClipMask(display, gc[i], None); /* 20171110 optimization, clipping already done in software */
|
||||
XSetClipMask(display, gcstipple[i], None); /* 20171110 optimization, clipping already done in software */
|
||||
if(has_x) {
|
||||
XSetClipMask(display, xctx->gctiled, None); /* clipping already done in software */
|
||||
for(i=0;i<cadlayers;i++)
|
||||
{
|
||||
XSetClipMask(display, gc[i], None); /* clipping already done in software */
|
||||
XSetClipMask(display, gcstipple[i], None); /* optimization, clipping already done in software */
|
||||
}
|
||||
#if HAS_CAIRO==1
|
||||
cairo_reset_clip(xctx->cairo_ctx);
|
||||
cairo_reset_clip(xctx->cairo_save_ctx);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if HAS_CAIRO==1
|
||||
cairo_reset_clip(xctx->cairo_ctx);
|
||||
cairo_reset_clip(xctx->cairo_save_ctx);
|
||||
#endif
|
||||
sem=0;
|
||||
break;
|
||||
case SET:
|
||||
|
|
@ -474,19 +474,23 @@ void bbox(int what,double x1,double y1, double x2, double y2)
|
|||
xctx->xrect[0].y = bby1-INT_WIDTH(xctx->lw);
|
||||
xctx->xrect[0].width = bbx2-bbx1+2*INT_WIDTH(xctx->lw);
|
||||
xctx->xrect[0].height = bby2-bby1+2*INT_WIDTH(xctx->lw);
|
||||
for(i=0;i<cadlayers;i++)
|
||||
{
|
||||
XSetClipRectangles(display, gc[i], 0,0, xctx->xrect, 1, Unsorted);
|
||||
XSetClipRectangles(display, gcstipple[i], 0,0, xctx->xrect, 1, Unsorted);
|
||||
if(has_x) {
|
||||
for(i=0;i<cadlayers;i++)
|
||||
{
|
||||
XSetClipRectangles(display, gc[i], 0,0, xctx->xrect, 1, Unsorted);
|
||||
XSetClipRectangles(display, gcstipple[i], 0,0, xctx->xrect, 1, Unsorted);
|
||||
}
|
||||
XSetClipRectangles(display, xctx->gctiled, 0,0, xctx->xrect, 1, Unsorted);
|
||||
dbg(1, "bbox(): bbox= %d %d %d %d\n",xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2);
|
||||
#if HAS_CAIRO==1
|
||||
cairo_rectangle(xctx->cairo_ctx, xctx->xrect[0].x, xctx->xrect[0].y,
|
||||
xctx->xrect[0].width, xctx->xrect[0].height);
|
||||
cairo_clip(xctx->cairo_ctx);
|
||||
cairo_rectangle(xctx->cairo_save_ctx, xctx->xrect[0].x, xctx->xrect[0].y,
|
||||
xctx->xrect[0].width, xctx->xrect[0].height);
|
||||
cairo_clip(xctx->cairo_save_ctx);
|
||||
#endif
|
||||
}
|
||||
XSetClipRectangles(display, xctx->gctiled, 0,0, xctx->xrect, 1, Unsorted);
|
||||
dbg(1, "bbox(): bbox= %d %d %d %d\n",xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2);
|
||||
#if HAS_CAIRO==1
|
||||
cairo_rectangle(xctx->cairo_ctx, xctx->xrect[0].x, xctx->xrect[0].y, xctx->xrect[0].width, xctx->xrect[0].height);
|
||||
cairo_clip(xctx->cairo_ctx);
|
||||
cairo_rectangle(xctx->cairo_save_ctx, xctx->xrect[0].x, xctx->xrect[0].y, xctx->xrect[0].width, xctx->xrect[0].height);
|
||||
cairo_clip(xctx->cairo_save_ctx);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ typedef struct {
|
|||
|
||||
static Svg_color *svg_colors;
|
||||
static char svg_font_weight[80] = "normal"; /* normal, bold, bolder, lighter */
|
||||
static char svg_font_family[80] = "Sans Serif"; /* serif, monospace, Helvetica, Arial */
|
||||
static char svg_font_family[80] = "SansSerif"; /* serif, monospace, Helvetica, Arial */
|
||||
static char svg_font_style[80] = "normal"; /* normal, italic, oblique */
|
||||
static double svg_linew; /* current width of lines / rectangles */
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ static void svg_draw_string_line(int layer, char *s, double x, double y, double
|
|||
char col[20];
|
||||
if(color_ps)
|
||||
my_snprintf(col, S(col), "#%02x%02x%02x",
|
||||
xcolor_array[layer].red >> 8, xcolor_array[layer].green >> 8, xcolor_array[layer].blue >> 8);
|
||||
svg_colors[layer].red, svg_colors[layer].green, svg_colors[layer].blue);
|
||||
else if(dark_colorscheme)
|
||||
my_snprintf(col, S(col), "#%02x%02x%02x", 255, 255, 255);
|
||||
else
|
||||
|
|
@ -226,7 +226,7 @@ static void svg_draw_string_line(int layer, char *s, double x, double y, double
|
|||
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);
|
||||
if(strcmp(svg_font_style, "normal")) fprintf(fd, "font-style=\"%s\" ", svg_font_style);
|
||||
if(strcmp(svg_font_family, "Sans Serif")) fprintf(fd, "style=\"font-family:%s;\" ", svg_font_family);
|
||||
if(strcmp(svg_font_family, "SansSerif")) fprintf(fd, "style=\"font-family:%s;\" ", svg_font_family);
|
||||
if(rot1) fprintf(fd, "transform=\"translate(%g, %g) rotate(%d)\" ", ix, iy, rot1*90);
|
||||
else fprintf(fd, "transform=\"translate(%g, %g)\" ", ix, iy);
|
||||
fprintf(fd, ">");
|
||||
|
|
@ -258,12 +258,11 @@ static void svg_draw_string(int layer, const char *str, short rot, short flip, i
|
|||
int lineno=0;
|
||||
double size, height, ascent, descent;
|
||||
int llength=0;
|
||||
if(str==NULL || !has_x ) return;
|
||||
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);
|
||||
if(!textclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,textx1,texty1,textx2,texty2)) {
|
||||
return;
|
||||
|
|
@ -623,7 +622,7 @@ void svg_draw(void)
|
|||
fprintf(fd, "}\n");
|
||||
}
|
||||
|
||||
fprintf(fd, "text {font-family: Sans Serif;}\n");
|
||||
fprintf(fd, "text {font-family: SansSerif;}\n");
|
||||
fprintf(fd, "</style>\n");
|
||||
|
||||
/* background */
|
||||
|
|
|
|||
Loading…
Reference in New Issue