chengkun
2025-09-09 774d962b76d63366ed26c395e0a33cdbec309242
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?php
 
namespace PhpOffice\PhpSpreadsheet;
 
class Theme
{
    private string $themeColorName = 'Office';
 
    private string $themeFontName = 'Office';
 
    public const COLOR_SCHEME_2013_PLUS_NAME = 'Office 2013+';
    public const COLOR_SCHEME_2013_PLUS = [
        'dk1' => '000000',
        'lt1' => 'FFFFFF',
        'dk2' => '44546A',
        'lt2' => 'E7E6E6',
        'accent1' => '4472C4',
        'accent2' => 'ED7D31',
        'accent3' => 'A5A5A5',
        'accent4' => 'FFC000',
        'accent5' => '5B9BD5',
        'accent6' => '70AD47',
        'hlink' => '0563C1',
        'folHlink' => '954F72',
    ];
 
    public const COLOR_SCHEME_2007_2010_NAME = 'Office 2007-2010';
    public const COLOR_SCHEME_2007_2010 = [
        'dk1' => '000000',
        'lt1' => 'FFFFFF',
        'dk2' => '1F497D',
        'lt2' => 'EEECE1',
        'accent1' => '4F81BD',
        'accent2' => 'C0504D',
        'accent3' => '9BBB59',
        'accent4' => '8064A2',
        'accent5' => '4BACC6',
        'accent6' => 'F79646',
        'hlink' => '0000FF',
        'folHlink' => '800080',
    ];
 
    /** @var string[] */
    private array $themeColors = self::COLOR_SCHEME_2007_2010;
 
    private string $majorFontLatin = 'Cambria';
 
    private string $majorFontEastAsian = '';
 
    private string $majorFontComplexScript = '';
 
    private string $minorFontLatin = 'Calibri';
 
    private string $minorFontEastAsian = '';
 
    private string $minorFontComplexScript = '';
 
    /**
     * Map of Major (header) fonts to write.
     *
     * @var string[]
     */
    private array $majorFontSubstitutions = self::FONTS_TIMES_SUBSTITUTIONS;
 
    /**
     * Map of Minor (body) fonts to write.
     *
     * @var string[]
     */
    private array $minorFontSubstitutions = self::FONTS_ARIAL_SUBSTITUTIONS;
 
    public const FONTS_TIMES_SUBSTITUTIONS = [
        'Jpan' => 'MS Pゴシック',
        'Hang' => '맑은 고딕',
        'Hans' => '宋体',
        'Hant' => '新細明體',
        'Arab' => 'Times New Roman',
        'Hebr' => 'Times New Roman',
        'Thai' => 'Tahoma',
        'Ethi' => 'Nyala',
        'Beng' => 'Vrinda',
        'Gujr' => 'Shruti',
        'Khmr' => 'MoolBoran',
        'Knda' => 'Tunga',
        'Guru' => 'Raavi',
        'Cans' => 'Euphemia',
        'Cher' => 'Plantagenet Cherokee',
        'Yiii' => 'Microsoft Yi Baiti',
        'Tibt' => 'Microsoft Himalaya',
        'Thaa' => 'MV Boli',
        'Deva' => 'Mangal',
        'Telu' => 'Gautami',
        'Taml' => 'Latha',
        'Syrc' => 'Estrangelo Edessa',
        'Orya' => 'Kalinga',
        'Mlym' => 'Kartika',
        'Laoo' => 'DokChampa',
        'Sinh' => 'Iskoola Pota',
        'Mong' => 'Mongolian Baiti',
        'Viet' => 'Times New Roman',
        'Uigh' => 'Microsoft Uighur',
        'Geor' => 'Sylfaen',
    ];
 
    public const FONTS_ARIAL_SUBSTITUTIONS = [
        'Jpan' => 'MS Pゴシック',
        'Hang' => '맑은 고딕',
        'Hans' => '宋体',
        'Hant' => '新細明體',
        'Arab' => 'Arial',
        'Hebr' => 'Arial',
        'Thai' => 'Tahoma',
        'Ethi' => 'Nyala',
        'Beng' => 'Vrinda',
        'Gujr' => 'Shruti',
        'Khmr' => 'DaunPenh',
        'Knda' => 'Tunga',
        'Guru' => 'Raavi',
        'Cans' => 'Euphemia',
        'Cher' => 'Plantagenet Cherokee',
        'Yiii' => 'Microsoft Yi Baiti',
        'Tibt' => 'Microsoft Himalaya',
        'Thaa' => 'MV Boli',
        'Deva' => 'Mangal',
        'Telu' => 'Gautami',
        'Taml' => 'Latha',
        'Syrc' => 'Estrangelo Edessa',
        'Orya' => 'Kalinga',
        'Mlym' => 'Kartika',
        'Laoo' => 'DokChampa',
        'Sinh' => 'Iskoola Pota',
        'Mong' => 'Mongolian Baiti',
        'Viet' => 'Arial',
        'Uigh' => 'Microsoft Uighur',
        'Geor' => 'Sylfaen',
    ];
 
    public function getThemeColors(): array
    {
        return $this->themeColors;
    }
 
    public function setThemeColor(string $key, string $value): self
    {
        $this->themeColors[$key] = $value;
 
        return $this;
    }
 
    public function getThemeColorName(): string
    {
        return $this->themeColorName;
    }
 
    public function setThemeColorName(string $name, ?array $themeColors = null): self
    {
        $this->themeColorName = $name;
        if ($name === self::COLOR_SCHEME_2007_2010_NAME) {
            $themeColors = $themeColors ?? self::COLOR_SCHEME_2007_2010;
        } elseif ($name === self::COLOR_SCHEME_2013_PLUS_NAME) {
            $themeColors = $themeColors ?? self::COLOR_SCHEME_2013_PLUS;
        }
        if ($themeColors !== null) {
            $this->themeColors = $themeColors;
        }
 
        return $this;
    }
 
    public function getMajorFontLatin(): string
    {
        return $this->majorFontLatin;
    }
 
    public function getMajorFontEastAsian(): string
    {
        return $this->majorFontEastAsian;
    }
 
    public function getMajorFontComplexScript(): string
    {
        return $this->majorFontComplexScript;
    }
 
    public function getMajorFontSubstitutions(): array
    {
        return $this->majorFontSubstitutions;
    }
 
    public function setMajorFontValues(?string $latin, ?string $eastAsian, ?string $complexScript, ?array $substitutions): self
    {
        if (!empty($latin)) {
            $this->majorFontLatin = $latin;
        }
        if ($eastAsian !== null) {
            $this->majorFontEastAsian = $eastAsian;
        }
        if ($complexScript !== null) {
            $this->majorFontComplexScript = $complexScript;
        }
        if ($substitutions !== null) {
            $this->majorFontSubstitutions = $substitutions;
        }
 
        return $this;
    }
 
    public function getMinorFontLatin(): string
    {
        return $this->minorFontLatin;
    }
 
    public function getMinorFontEastAsian(): string
    {
        return $this->minorFontEastAsian;
    }
 
    public function getMinorFontComplexScript(): string
    {
        return $this->minorFontComplexScript;
    }
 
    public function getMinorFontSubstitutions(): array
    {
        return $this->minorFontSubstitutions;
    }
 
    public function setMinorFontValues(?string $latin, ?string $eastAsian, ?string $complexScript, ?array $substitutions): self
    {
        if (!empty($latin)) {
            $this->minorFontLatin = $latin;
        }
        if ($eastAsian !== null) {
            $this->minorFontEastAsian = $eastAsian;
        }
        if ($complexScript !== null) {
            $this->minorFontComplexScript = $complexScript;
        }
        if ($substitutions !== null) {
            $this->minorFontSubstitutions = $substitutions;
        }
 
        return $this;
    }
 
    public function getThemeFontName(): string
    {
        return $this->themeFontName;
    }
 
    public function setThemeFontName(?string $name): self
    {
        if (!empty($name)) {
            $this->themeFontName = $name;
        }
 
        return $this;
    }
}