Pop\Pdf\Pdf::calcTextMatrix PHP Method

calcTextMatrix() protected method

Method to calculate text matrix.
protected calcTextMatrix ( ) : string
return string
    protected function calcTextMatrix()
    {
        // Define some variables.
        $tm = '';
        $a = '';
        $b = '';
        $c = '';
        $d = '';
        $neg = null;
        // Determine is the rotate parameter is negative or not.
        $neg = $this->textParams['rot'] < 0 ? true : false;
        // Calculate the text matrix parameters.
        $rot = abs($this->textParams['rot']);
        if ($rot >= 0 && $rot <= 45) {
            $factor = round($rot / 45, 2);
            if ($neg) {
                $a = 1;
                $b = '-' . $factor;
                $c = $factor;
                $d = 1;
            } else {
                $a = 1;
                $b = $factor;
                $c = '-' . $factor;
                $d = 1;
            }
        } else {
            if ($rot > 45 && $rot <= 90) {
                $factor = round((90 - $rot) / 45, 2);
                if ($neg) {
                    $a = $factor;
                    $b = -1;
                    $c = 1;
                    $d = $factor;
                } else {
                    $a = $factor;
                    $b = 1;
                    $c = -1;
                    $d = $factor;
                }
            }
        }
        // Adjust the text matrix parameters according to the horizontal and vertical scale parameters.
        if ($this->textParams['h'] != 100) {
            $a = round($a * ($this->textParams['h'] / 100), 2);
            $b = round($b * ($this->textParams['h'] / 100), 2);
        }
        if ($this->textParams['v'] != 100) {
            $c = round($c * ($this->textParams['v'] / 100), 2);
            $d = round($d * ($this->textParams['v'] / 100), 2);
        }
        // Set the text matrix and return it.
        $tm = "{$a} {$b} {$c} {$d}";
        return $tm;
    }