public function __construct($id, $init, &$compiler)
{
- if ($init['to'] === 'text' || $init['to'] === 'onlytext') {
+ if ($init['to'] === 'text' || $init['to'] === 'onlytext' || $init['to'] === 'textmask') {
$this->defaultZIndex++;
}
- if ($init['to'] === 'text' && $compiler->config->transparentPage) {
+ if ($init['to'] === 'textmask') {
$compiler->addMask('texts', $init['page'], ['x' => $init['left'], 'y' => $init['top'], 'width' => $init['width'], 'height' => $init['height']]);
}
parent::__construct($id, $init, $compiler);
protected function _getExtension()
{
- if ($this->_getLayer() === 'text' || $this->_getLayer() === 'onlytext' || $this->_getLayer() === 'bothsvg') {
- return 'svg';
- } else {
- return 'jpg';
- }
+ return match ($this->_getLayer()) {
+ 'text', 'onlytext', 'bothsvg', 'textmask' => 'svg',
+ default => 'jpg',
+ };
}
protected function _getLayer()
$extractOptions['quality'] = $attributes['quality'];
}
- if (isset($attributes['layer']) && !in_array($attributes['layer'], ['image', 'text', 'onlytext', 'bothsvg'])) {
+ if (isset($attributes['layer']) && !in_array($attributes['layer'], ['image', 'text', 'onlytext', 'bothsvg', 'textmask'])) {
unset($attributes['layer']);
}
if ($attributes['layer'] === 'image') {
$extractOptions['texts'] = false;
$extractOptions['background'] = true;
- } else if ($attributes['layer'] === 'text' || $attributes['layer'] === 'onlytext') {
+ } else if ($attributes['layer'] === 'text' || $attributes['layer'] === 'onlytext' || $attributes['layer'] === 'textmask') {
$extractOptions['texts'] = true;
$extractOptions['background'] = false;
$ext = $extractOptions['format'] = 'svg';