Add test cases for text alignment and text direction.

text-module
Torsten Paul 2013-11-17 20:03:43 +01:00 committed by Marius Kintel
parent a994d4b750
commit afca09729a
10 changed files with 158 additions and 0 deletions

View File

@ -0,0 +1,32 @@
use <../../ttf/paratype-serif/PTF55F.ttf>
t = "OpenSCAD";
valign = [
[10, "top"],
[40, "center"],
[70, "baseline"],
[100, "bottom"]
];
halign = [
[10, "left"],
[40, "center"],
[70, "right"]
];
for (a = valign) {
translate([10, a[0], 0]) {
color("red") square([135, 0.5]);
color("blue") square([0.5, 20]);
text(t = t, font = "PT Serif:style=Regular", size = 20, valign = a[1]);
}
}
for (a = halign) {
translate([160 + 2.23 * a[0], a[0], 0]) {
color("red") square([135, 0.5]);
color("blue") square([0.5, 20]);
text(t = t, font = "PT Serif:style=Regular", size = 20, halign = a[1]);
}
}

View File

@ -0,0 +1,17 @@
use <../../ttf/paratype-serif/PTF55F.ttf>
t = "OpenSCAD";
dir = [
[90, 10, "ltl"],
[90, 60, "rtl"],
[10, 160, "ttb"],
[60, 140, "btt"]
];
for (a = dir) {
translate([a[0], a[1], 0]) {
color("red") square([135, 0.5]);
color("blue") square([0.5, 20]);
text(t = t, font = "PT Serif:style=Regular", size = 20, direction = a[2]);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -0,0 +1,69 @@
group() {
group() {
multmatrix([[1, 0, 0, 10], [0, 1, 0, 10], [0, 0, 1, 0], [0, 0, 0, 1]]) {
color([1, 0, 0, 1]) {
square(size = [135, 0.5], center = false);
}
color([0, 0, 1, 1]) {
square(size = [0.5, 20], center = false);
}
($fn = 7, text = 'OpenSCAD', size = 20, spacing = 1, font = 'PT Serif:style=Regular', direction = 'ltr', language = 'en', script = 'latin', halign = 'left', valign = 'top');
}
multmatrix([[1, 0, 0, 10], [0, 1, 0, 40], [0, 0, 1, 0], [0, 0, 0, 1]]) {
color([1, 0, 0, 1]) {
square(size = [135, 0.5], center = false);
}
color([0, 0, 1, 1]) {
square(size = [0.5, 20], center = false);
}
($fn = 7, text = 'OpenSCAD', size = 20, spacing = 1, font = 'PT Serif:style=Regular', direction = 'ltr', language = 'en', script = 'latin', halign = 'left', valign = 'center');
}
multmatrix([[1, 0, 0, 10], [0, 1, 0, 70], [0, 0, 1, 0], [0, 0, 0, 1]]) {
color([1, 0, 0, 1]) {
square(size = [135, 0.5], center = false);
}
color([0, 0, 1, 1]) {
square(size = [0.5, 20], center = false);
}
($fn = 7, text = 'OpenSCAD', size = 20, spacing = 1, font = 'PT Serif:style=Regular', direction = 'ltr', language = 'en', script = 'latin', halign = 'left', valign = 'baseline');
}
multmatrix([[1, 0, 0, 10], [0, 1, 0, 100], [0, 0, 1, 0], [0, 0, 0, 1]]) {
color([1, 0, 0, 1]) {
square(size = [135, 0.5], center = false);
}
color([0, 0, 1, 1]) {
square(size = [0.5, 20], center = false);
}
($fn = 7, text = 'OpenSCAD', size = 20, spacing = 1, font = 'PT Serif:style=Regular', direction = 'ltr', language = 'en', script = 'latin', halign = 'left', valign = 'bottom');
}
}
group() {
multmatrix([[1, 0, 0, 182.3], [0, 1, 0, 10], [0, 0, 1, 0], [0, 0, 0, 1]]) {
color([1, 0, 0, 1]) {
square(size = [135, 0.5], center = false);
}
color([0, 0, 1, 1]) {
square(size = [0.5, 20], center = false);
}
($fn = 7, text = 'OpenSCAD', size = 20, spacing = 1, font = 'PT Serif:style=Regular', direction = 'ltr', language = 'en', script = 'latin', halign = 'left', valign = 'baseline');
}
multmatrix([[1, 0, 0, 249.2], [0, 1, 0, 40], [0, 0, 1, 0], [0, 0, 0, 1]]) {
color([1, 0, 0, 1]) {
square(size = [135, 0.5], center = false);
}
color([0, 0, 1, 1]) {
square(size = [0.5, 20], center = false);
}
($fn = 7, text = 'OpenSCAD', size = 20, spacing = 1, font = 'PT Serif:style=Regular', direction = 'ltr', language = 'en', script = 'latin', halign = 'center', valign = 'baseline');
}
multmatrix([[1, 0, 0, 316.1], [0, 1, 0, 70], [0, 0, 1, 0], [0, 0, 0, 1]]) {
color([1, 0, 0, 1]) {
square(size = [135, 0.5], center = false);
}
color([0, 0, 1, 1]) {
square(size = [0.5, 20], center = false);
}
($fn = 7, text = 'OpenSCAD', size = 20, spacing = 1, font = 'PT Serif:style=Regular', direction = 'ltr', language = 'en', script = 'latin', halign = 'right', valign = 'baseline');
}
}
}

View File

@ -0,0 +1,40 @@
group() {
group() {
multmatrix([[1, 0, 0, 90], [0, 1, 0, 10], [0, 0, 1, 0], [0, 0, 0, 1]]) {
color([1, 0, 0, 1]) {
square(size = [135, 0.5], center = false);
}
color([0, 0, 1, 1]) {
square(size = [0.5, 20], center = false);
}
($fn = 7, text = 'OpenSCAD', size = 20, spacing = 1, font = 'PT Serif:style=Regular', direction = 'ltl', language = 'en', script = 'latin', halign = 'left', valign = 'baseline');
}
multmatrix([[1, 0, 0, 90], [0, 1, 0, 60], [0, 0, 1, 0], [0, 0, 0, 1]]) {
color([1, 0, 0, 1]) {
square(size = [135, 0.5], center = false);
}
color([0, 0, 1, 1]) {
square(size = [0.5, 20], center = false);
}
($fn = 7, text = 'OpenSCAD', size = 20, spacing = 1, font = 'PT Serif:style=Regular', direction = 'rtl', language = 'en', script = 'latin', halign = 'left', valign = 'baseline');
}
multmatrix([[1, 0, 0, 10], [0, 1, 0, 160], [0, 0, 1, 0], [0, 0, 0, 1]]) {
color([1, 0, 0, 1]) {
square(size = [135, 0.5], center = false);
}
color([0, 0, 1, 1]) {
square(size = [0.5, 20], center = false);
}
($fn = 7, text = 'OpenSCAD', size = 20, spacing = 1, font = 'PT Serif:style=Regular', direction = 'ttb', language = 'en', script = 'latin', halign = 'left', valign = 'baseline');
}
multmatrix([[1, 0, 0, 60], [0, 1, 0, 140], [0, 0, 1, 0], [0, 0, 0, 1]]) {
color([1, 0, 0, 1]) {
square(size = [135, 0.5], center = false);
}
color([0, 0, 1, 1]) {
square(size = [0.5, 20], center = false);
}
($fn = 7, text = 'OpenSCAD', size = 20, spacing = 1, font = 'PT Serif:style=Regular', direction = 'btt', language = 'en', script = 'latin', halign = 'left', valign = 'baseline');
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB