Merge pull request #173 from bear454/per-legend-fonts

Font can be explicitly set on a legend
This commit is contained in:
Bob 2022-10-14 23:52:27 -04:00 committed by GitHub
commit 7a5d2f00ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 11 deletions

View File

@ -1,9 +1,9 @@
module keytext(text, position, font_size, depth) { module keytext(text, position, font_size, font_face, depth) {
woffset = (top_total_key_width()/3.5) * position[0]; woffset = (top_total_key_width()/3.5) * position[0];
hoffset = (top_total_key_height()/3.5) * -position[1]; hoffset = (top_total_key_height()/3.5) * -position[1];
translate([woffset, hoffset, -depth]){ translate([woffset, hoffset, -depth]){
color($tertiary_color) linear_extrude(height=$dish_depth + depth){ color($tertiary_color) linear_extrude(height=$dish_depth + depth){
text(text=text, font=$font, size=font_size, halign="center", valign="center"); text(text=text, font=font_face, size=font_size, halign="center", valign="center");
} }
} }
} }
@ -12,14 +12,14 @@ module legends(depth=0) {
if (len($front_legends) > 0) { if (len($front_legends) > 0) {
front_of_key() { front_of_key() {
for (i=[0:len($front_legends)-1]) { for (i=[0:len($front_legends)-1]) {
rotate([90,0,0]) keytext($front_legends[i][0], $front_legends[i][1], $front_legends[i][2], depth); rotate([90,0,0]) keytext($front_legends[i][0], $front_legends[i][1], $front_legends[i][2], $front_legends[i][3], depth);
} }
} }
} }
if (len($legends) > 0) { if (len($legends) > 0) {
top_of_key() { top_of_key() {
for (i=[0:len($legends)-1]) { for (i=[0:len($legends)-1]) {
keytext($legends[i][0], $legends[i][1], $legends[i][2], depth); keytext($legends[i][0], $legends[i][1], $legends[i][2], $legends[i][3], depth);
} }
} }
} }

View File

@ -158,15 +158,17 @@ module flat_support() {
children(); children();
} }
module legend(text, position=[0,0], size=undef) { module legend(text, position=[0,0], size=undef, font=undef) {
font_size = size == undef ? $font_size : size; font_size = size == undef ? $font_size : size;
$legends = [for(L=[$legends, [[text, position, font_size]]], a=L) a]; font_face = font == undef ? $font : font;
$legends = [for(L=[$legends, [[text, position, font_size, font_face]]], a=L) a];
children(); children();
} }
module front_legend(text, position=[0,0], size=undef) { module front_legend(text, position=[0,0], size=undef, font=undef) {
font_size = size == undef ? $font_size : size; font_size = size == undef ? $font_size : size;
$front_legends = [for(L=[$front_legends, [[text, position, font_size]]], a=L) a]; font_face = font == undef ? $font : font;
$front_legends = [for(L=[$front_legends, [[text, position, font_size, font_face]]], a=L) a];
children(); children();
} }