Added align parameter
This commit is contained in:
parent
26f50f8409
commit
55aecfb419
11
fonts.scad
11
fonts.scad
|
@ -32,23 +32,24 @@ module bold_2d(bold,width=0.2,resolution=8) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module polytext(charstring,size,font,line=0,justify=1
|
module polytext(charstring,size,font,line=0,justify=1,align=-1
|
||||||
,bold=false,bold_width=0.2,bold_resolution=8
|
,bold=false,bold_width=0.2,bold_resolution=8
|
||||||
,underline=false,underline_start=[0,0],underline_width=1.0
|
,underline=false,underline_start=[0,0],underline_width=1.0
|
||||||
,outline=false,outline_width=0.2,outline_resolution=8
|
,outline=false,outline_width=0.2,outline_resolution=8
|
||||||
,strike=false,strike_start=[-0.5,0],strike_width=1.0
|
,strike=false,strike_start=[-0.5,0],strike_width=1.0
|
||||||
) {
|
) {
|
||||||
line_length=len(charstring)*font[0][0];
|
line_length=len(charstring)*font[0][0];
|
||||||
line_shift=-line_length/2+justify*line_length/2;
|
line_shift_x=-line_length/2+justify*line_length/2;
|
||||||
char_width=font[0][0];
|
char_width=font[0][0];
|
||||||
char_height=font[0][1];
|
char_height=font[0][1];
|
||||||
|
char_shift_height=-char_height/2-align*char_height/2;
|
||||||
char_thickness=font[0][2];
|
char_thickness=font[0][2];
|
||||||
char_index_map=search(charstring,font[2],1,1);
|
char_index_map=search(charstring,font[2],1,1);
|
||||||
for(i=[0:len(char_index_map)-1]) assign( thisCharIndex=char_index_map[i], x_pos= i*char_width*size/char_width+line_shift) {
|
for(i=[0:len(char_index_map)-1]) assign( thisCharIndex=char_index_map[i], x_pos=i*size+line_shift_x*size/char_width) {
|
||||||
translate([x_pos,line*char_height*size/char_height]) {
|
translate([x_pos,line*size+char_shift_height*size/char_height]) scale([size/char_width,size/char_height]) {
|
||||||
if(char_thickness==0)
|
if(char_thickness==0)
|
||||||
bold_2d(bold,width=bold_width,resolution=bold_resolution)
|
bold_2d(bold,width=bold_width,resolution=bold_resolution)
|
||||||
render() outline_2d(outline,points=font[2][thisCharIndex][6][0],paths=font[2][thisCharIndex][6][1]
|
outline_2d(outline,points=font[2][thisCharIndex][6][0],paths=font[2][thisCharIndex][6][1]
|
||||||
,width=outline_width,resolution=outline_resolution);
|
,width=outline_width,resolution=outline_resolution);
|
||||||
if( charstring[i] != " " ) {
|
if( charstring[i] != " " ) {
|
||||||
if(underline) translate(underline_start)
|
if(underline) translate(underline_start)
|
||||||
|
|
Loading…
Reference in a new issue