Skip to content

Commit 643a2cd

Browse files
author
konstantin
committed
text positioning code was changed a little bit
1 parent 3053817 commit 643a2cd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Creator.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,23 @@ public function addSolid($x, $y, $z=0.0, $w=0.0, $h=0.0)
353353
*/
354354
public function addText($x, $y, $z, $text, $textHeight, $position = 7, $angle = 0.0, $thickness = 0)
355355
{
356+
$positions = [
357+
1 => [3, 0], // top-left
358+
2 => [3, 1], // top-center
359+
3 => [3, 2], // top-right
360+
4 => [2, 0], // center-left
361+
5 => [2, 1], // center
362+
6 => [2, 2], // center-right
363+
7 => [1, 0], // bottom-left
364+
8 => [1, 1], // bottom-center
365+
9 => [1, 2] // bottom-right
366+
];
356367
$x += $this->offset[0];
357368
$y += $this->offset[1];
358369
$z += $this->offset[2];
359370
$angle = deg2rad($angle);
360-
$horizontalJustification = ($position - 1) % 3;
361-
$verticalJustification = 3 - intval(($position -1) / 3);
371+
$verticalJustification = $positions[$position][0];
372+
$horizontalJustification = $positions[$position][1];
362373
$this->shapes[] = "TEXT\n" .
363374
"5\n" . // Entity Handle
364375
"{number}\n" .

0 commit comments

Comments
 (0)