FontDescriptor   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 21
c 1
b 0
f 0
dl 0
loc 42
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setFont() 0 4 1
A render() 0 19 1
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * FontDescriptor class.
6
 *
7
 * @package   YetiForcePDF\Objects
8
 *
9
 * @copyright YetiForce Sp. z o.o
10
 * @license   MIT
11
 * @author    Rafal Pospiech <[email protected]>
12
 */
13
14
namespace YetiForcePDF\Objects;
15
16
/**
17
 * Class FontDescriptor.
18
 */
19
class FontDescriptor extends \YetiForcePDF\Objects\Resource
20
{
21
	/**
22
	 * @var \YetiForcePDF\Objects\Font
23
	 */
24
	protected $font;
25
26
	/**
27
	 * Set font instance.
28
	 *
29
	 * @param \YetiForcePDF\Objects\Font $font
30
	 *
31
	 * @return $this
32
	 */
33
	public function setFont(Font $font)
34
	{
35
		$this->font = $font;
36
		return $this;
37
	}
38
39
	/**
40
	 * {@inheritdoc}
41
	 */
42
	public function render(): string
43
	{
44
		$descriptor = $this->font->getOutputInfo()['descriptor'];
45
		return implode("\n", [
46
			$this->getRawId() . ' obj',
47
			'<<',
48
			'  /Type /FontDescriptor',
49
			'  /FontName /' . $this->font->getFullName(),
50
			'  /FontBBox ' . $descriptor['FontBBox'],
51
			'  /Flags ' . $descriptor['Flags'],
52
			'  /Ascent ' . $descriptor['Ascent'],
53
			'  /Descent ' . $descriptor['Descent'],
54
			'  /CapHeight ' . $descriptor['Ascent'],
55
			'  /ItalicAngle ' . $descriptor['ItalicAngle'],
56
			'  /StemV ' . $descriptor['StemV'],
57
			'  /MissingWidth ' . $descriptor['MissingWidth'],
58
			'  /FontFile2 ' . $this->font->getDataStream()->getReference(),
59
			'>>',
60
			'endobj',
61
		]);
62
	}
63
}
64