implemented text attributes "hcenter=true" (center text in reading direction) and "vcenter=true" (center text in direction perpendicular to reading direction). these can both be set for full centered text block.
This commit is contained in:
parent
bd982c00ce
commit
d076952bff
|
|
@ -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));
|
||||
|
|
|
|||
21
src/draw.c
21
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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue