Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace OpenSpout\Writer\ODS\Manager\Style;
6
 
7
use OpenSpout\Common\Entity\Style\Style;
8
use OpenSpout\Writer\Common\Manager\Style\AbstractStyleRegistry as CommonStyleRegistry;
9
 
10
/**
11
 * @internal
12
 */
13
final class StyleRegistry extends CommonStyleRegistry
14
{
15
    /** @var array<string, bool> [FONT_NAME] => [] Map whose keys contain all the fonts used */
16
    private array $usedFontsSet = [];
17
 
18
    /**
19
     * Registers the given style as a used style.
20
     * Duplicate styles won't be registered more than once.
21
     *
22
     * @param Style $style The style to be registered
23
     *
24
     * @return Style the registered style, updated with an internal ID
25
     */
26
    public function registerStyle(Style $style): Style
27
    {
28
        if ($style->isRegistered()) {
29
            return $style;
30
        }
31
 
32
        $registeredStyle = parent::registerStyle($style);
33
        $this->usedFontsSet[$style->getFontName()] = true;
34
 
35
        return $registeredStyle;
36
    }
37
 
38
    /**
39
     * @return string[] List of used fonts name
40
     */
41
    public function getUsedFonts(): array
42
    {
43
        return array_keys($this->usedFontsSet);
44
    }
45
}