diff --git a/src/actions.c b/src/actions.c index c72bad83..72374a1c 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2096,6 +2096,29 @@ int text_bbox(char *str, double xscale, double yscale, cairo_longest_line = ww; *rx1=x1;*ry1=y1; + if(hcenter) { + if(rot==0 && flip == 0) { *rx1-= ww*zoom/2;} + if(rot==1 && flip == 0) { *ry1-= ww*zoom/2;} + if(rot==2 && flip == 0) { *rx1+= ww*zoom/2;} + if(rot==3 && flip == 0) { *ry1+= ww*zoom/2;} + if(rot==0 && flip == 1) { *rx1+= ww*zoom/2;} + if(rot==1 && flip == 1) { *ry1+= ww*zoom/2;} + if(rot==2 && flip == 1) { *rx1-= ww*zoom/2;} + if(rot==3 && flip == 1) { *ry1-= ww*zoom/2;} + } + + if(vcenter) { + if(rot==0 && flip == 0) { *ry1-= hh*zoom/2;} + if(rot==1 && flip == 0) { *rx1+= hh*zoom/2;} + if(rot==2 && flip == 0) { *ry1+= hh*zoom/2;} + if(rot==3 && flip == 0) { *rx1-= hh*zoom/2;} + if(rot==0 && flip == 1) { *ry1-= hh*zoom/2;} + if(rot==1 && flip == 1) { *rx1+= hh*zoom/2;} + if(rot==2 && flip == 1) { *ry1+= hh*zoom/2;} + if(rot==3 && flip == 1) { *rx1-= hh*zoom/2;} + } + + ROTATION(0.0,0.0, ww*zoom,hh*zoom,(*rx2),(*ry2)); *rx2+=*rx1;*ry2+=*ry1; if (rot==0) {*ry1-=cairo_vert_correct; *ry2-=cairo_vert_correct;} @@ -2133,6 +2156,28 @@ int text_bbox(char * str,double xscale, double yscale, else if(rot==2) *ry1+=nocairo_vert_correct; else *rx1-=nocairo_vert_correct; + if(hcenter) { + if(rot==0 && flip == 0) { *rx1-= w/2;} + if(rot==1 && flip == 0) { *ry1-= w/2;} + if(rot==2 && flip == 0) { *rx1+= w/2;} + if(rot==3 && flip == 0) { *ry1+= w/2;} + if(rot==0 && flip == 1) { *rx1+= w/2;} + if(rot==1 && flip == 1) { *ry1+= w/2;} + if(rot==2 && flip == 1) { *rx1-= w/2;} + if(rot==3 && flip == 1) { *ry1-= w/2;} + } + + if(vcenter) { + if(rot==0 && flip == 0) { *ry1-= h/2;} + if(rot==1 && flip == 0) { *rx1+= h/2;} + if(rot==2 && flip == 0) { *ry1+= h/2;} + if(rot==3 && flip == 0) { *rx1-= h/2;} + if(rot==0 && flip == 1) { *ry1-= h/2;} + if(rot==1 && flip == 1) { *rx1+= h/2;} + if(rot==2 && flip == 1) { *ry1+= h/2;} + if(rot==3 && flip == 1) { *rx1-= h/2;} + } + ROTATION(0.0,0.0,w,h,(*rx2),(*ry2)); *rx2+=*rx1;*ry2+=*ry1; RECTORDER((*rx1),(*ry1),(*rx2),(*ry2)); diff --git a/src/draw.c b/src/draw.c index d451e8f9..da97f9fd 100644 --- a/src/draw.c +++ b/src/draw.c @@ -300,6 +300,27 @@ void draw_string(int layer, int what, char *s, int rot, int flip, int hcenter, i return; } + if(hcenter) { + if(rot == 0 && flip == 0 ) { x=textx1;} + if(rot == 1 && flip == 0 ) { y=texty1;} + if(rot == 2 && flip == 0 ) { x=textx2;} + if(rot == 3 && flip == 0 ) { y=texty2;} + if(rot == 0 && flip == 1 ) { x=textx2;} + if(rot == 1 && flip == 1 ) { y=texty2;} + if(rot == 2 && flip == 1 ) { x=textx1;} + if(rot == 3 && flip == 1 ) { y=texty1;} + } + if(vcenter) { + if(rot == 0 && flip == 0 ) { y=texty1;} + if(rot == 1 && flip == 0 ) { x=textx2;} + if(rot == 2 && flip == 0 ) { y=texty2;} + if(rot == 3 && flip == 0 ) { x=textx1;} + if(rot == 0 && flip == 1 ) { y=texty1;} + if(rot == 1 && flip == 1 ) { x=textx2;} + if(rot == 2 && flip == 1 ) { y=texty2;} + if(rot == 3 && flip == 1 ) { x=textx1;} + } + cairo_set_source_rgb(ctx, (double)xcolor_array[layer].red/65535.0, (double)xcolor_array[layer].green/65535.0,