1<?php
2
3namespace Mpdf\Config;
4
5class FontVariables
6{
7
8	private $defaults;
9
10	public function __construct()
11	{
12		$this->defaults = [
13
14			// Specify which font metrics to use:
15			// - 'winTypo uses sTypoAscender etc from the OS/2 table and is the one usually recommended - BUT
16			// - 'win' use WinAscent etc from OS/2 and inpractice seems to be used more commonly in Windows environment
17			// - 'mac' uses Ascender etc from hhea table, and is used on Mac/OSX environment
18			'fontDescriptor' => 'win',
19
20			// For custom fonts data folder set config key 'fontDir'. It can also be an array of directories,
21			// first found file will then be returned
22
23			// Optionally set font(s) (names as defined below in 'fontdata') to use for missing characters
24			// when using useSubstitutions. Use a font with wide coverage - dejavusanscondensed is a good start
25			// only works using subsets (otherwise would add very large file)
26			// More than 1 font can be specified but each will add to the processing time of the script
27
28			'backupSubsFont' => ['dejavusanscondensed', 'freesans', 'sun-exta'],
29
30			// Optionally set a font (name as defined below in 'fontdata') to use for CJK characters
31			// in Plane 2 Unicode (> U+20000) when using useSubstitutions.
32			// Use a font like hannomb or sun-extb if available
33			// only works using subsets (otherwise would add very large file)
34
35			'backupSIPFont' => 'sun-extb',
36
37			/*
38			  This array defines translations from font-family in CSS or HTML
39			  to the internal font-family name used in mPDF.
40			  Can include as many as want, regardless of which fonts are installed.
41			  By default mPDF will take a CSS/HTML font-family and remove spaces
42			  and change to lowercase e.g. "Times New Roman" will be recognised as
43			  "timesnewroman"
44			  You only need to define additional translations.
45			  You can also use it to define specific substitutions e.g.
46			  'helvetica' => 'arial'
47			  Generic substitutions (i.e. to a sans-serif or serif font) are set
48			  by including the font-family in e.g. 'sans_fonts' below
49			 */
50			'fonttrans' => [
51				'times' => 'timesnewroman',
52				'courier' => 'couriernew',
53				'trebuchet' => 'trebuchetms',
54				'comic' => 'comicsansms',
55				'franklin' => 'franklingothicbook',
56				'ocr-b' => 'ocrb',
57				'ocr-b10bt' => 'ocrb',
58				'damase' => 'mph2bdamase',
59			],
60
61			/*
62			  This array lists the file names of the TrueType .ttf or .otf font files
63			  for each variant of the (internal mPDF) font-family name.
64			  ['R'] = Regular (Normal), others are Bold, Italic, and Bold-Italic
65			  Each entry must contain an ['R'] entry, but others are optional.
66			  Only the font (files) entered here will be available to use in mPDF.
67			  Put preferred default first in order
68			  This will be used if a named font cannot be found in any of
69			  'sans_fonts', 'serif_fonts' or 'mono_fonts'
70
71			  ['sip-ext'] = 'sun-extb', name a related font file containing SIP characters
72			  ['useOTL'] => 0xFF,	Enable use of OTL features.
73			  ['useKashida'] => 75,	Enable use of kashida for text justification in Arabic text
74
75			  If a .ttc TrueType collection file is referenced, the number of the font
76			  within the collection is required. Fonts in the collection are numbered
77			  starting at 1, as they appear in the .ttc file e.g.
78			  "cambria" => array(
79					'R' => "cambria.ttc",
80					'B' => "cambriab.ttf",
81					'I' => "cambriai.ttf",
82					'BI' => "cambriaz.ttf",
83					'TTCfontID' => array(
84						'R' => 1,
85					),
86				),
87				"cambriamath" => array(
88					'R' => "cambria.ttc",
89					'TTCfontID' => array(
90						'R' => 2,
91					),
92				),
93			 */
94
95			'fontdata' => [
96				"dejavusanscondensed" => [
97					'R' => "DejaVuSansCondensed.ttf",
98					'B' => "DejaVuSansCondensed-Bold.ttf",
99					'I' => "DejaVuSansCondensed-Oblique.ttf",
100					'BI' => "DejaVuSansCondensed-BoldOblique.ttf",
101					'useOTL' => 0xFF,
102					'useKashida' => 75,
103				],
104				"dejavusans" => [
105					'R' => "DejaVuSans.ttf",
106					'B' => "DejaVuSans-Bold.ttf",
107					'I' => "DejaVuSans-Oblique.ttf",
108					'BI' => "DejaVuSans-BoldOblique.ttf",
109					'useOTL' => 0xFF,
110					'useKashida' => 75,
111				],
112				"dejavuserif" => [
113					'R' => "DejaVuSerif.ttf",
114					'B' => "DejaVuSerif-Bold.ttf",
115					'I' => "DejaVuSerif-Italic.ttf",
116					'BI' => "DejaVuSerif-BoldItalic.ttf",
117				],
118				"dejavuserifcondensed" => [
119					'R' => "DejaVuSerifCondensed.ttf",
120					'B' => "DejaVuSerifCondensed-Bold.ttf",
121					'I' => "DejaVuSerifCondensed-Italic.ttf",
122					'BI' => "DejaVuSerifCondensed-BoldItalic.ttf",
123				],
124				"dejavusansmono" => [
125					'R' => "DejaVuSansMono.ttf",
126					'B' => "DejaVuSansMono-Bold.ttf",
127					'I' => "DejaVuSansMono-Oblique.ttf",
128					'BI' => "DejaVuSansMono-BoldOblique.ttf",
129					'useOTL' => 0xFF,
130					'useKashida' => 75,
131				],
132				"freesans" => [
133					'R' => "FreeSans.ttf",
134					'B' => "FreeSansBold.ttf",
135					'I' => "FreeSansOblique.ttf",
136					'BI' => "FreeSansBoldOblique.ttf",
137					'useOTL' => 0xFF,
138				],
139				"freeserif" => [
140					'R' => "FreeSerif.ttf",
141					'B' => "FreeSerifBold.ttf",
142					'I' => "FreeSerifItalic.ttf",
143					'BI' => "FreeSerifBoldItalic.ttf",
144					'useOTL' => 0xFF,
145					'useKashida' => 75,
146				],
147				"freemono" => [
148					'R' => "FreeMono.ttf",
149					'B' => "FreeMonoBold.ttf",
150					'I' => "FreeMonoOblique.ttf",
151					'BI' => "FreeMonoBoldOblique.ttf",
152				],
153				/* OCR-B font for Barcodes */
154				"ocrb" => [
155					'R' => "ocrb10.ttf",
156				],
157				/* Miscellaneous language font(s) */
158				"estrangeloedessa" => [/* Syriac */
159					'R' => "SyrCOMEdessa.otf",
160					'useOTL' => 0xFF,
161				],
162				"kaputaunicode" => [/* Sinhala  */
163					'R' => "kaputaunicode.ttf",
164					'useOTL' => 0xFF,
165				],
166				"abyssinicasil" => [/* Ethiopic */
167					'R' => "Abyssinica_SIL.ttf",
168					'useOTL' => 0xFF,
169				],
170				"aboriginalsans" => [/* Cherokee and Canadian */
171					'R' => "AboriginalSansREGULAR.ttf",
172				],
173				"jomolhari" => [/* Tibetan */
174					'R' => "Jomolhari.ttf",
175					'useOTL' => 0xFF,
176				],
177				"sundaneseunicode" => [/* Sundanese */
178					'R' => "SundaneseUnicode-1.0.5.ttf",
179					'useOTL' => 0xFF,
180				],
181				"taiheritagepro" => [/* Tai Viet */
182					'R' => "TaiHeritagePro.ttf",
183				],
184				"aegean" => [
185					'R' => "Aegean.otf",
186					'useOTL' => 0xFF,
187				],
188				"aegyptus" => [
189					'R' => "Aegyptus.otf",
190					'useOTL' => 0xFF,
191				],
192				"akkadian" => [/* Cuneiform */
193					'R' => "Akkadian.otf",
194					'useOTL' => 0xFF,
195				],
196				"quivira" => [
197					'R' => "Quivira.otf",
198					'useOTL' => 0xFF,
199				],
200				"eeyekunicode" => [/* Meetei Mayek */
201					'R' => "Eeyek.ttf",
202				],
203				"lannaalif" => [/* Tai Tham */
204					'R' => "lannaalif-v1-03.ttf",
205					'useOTL' => 0xFF,
206				],
207				"daibannasilbook" => [/* New Tai Lue */
208					'R' => "DBSILBR.ttf",
209				],
210				"garuda" => [/* Thai */
211					'R' => "Garuda.ttf",
212					'B' => "Garuda-Bold.ttf",
213					'I' => "Garuda-Oblique.ttf",
214					'BI' => "Garuda-BoldOblique.ttf",
215					'useOTL' => 0xFF,
216				],
217				"khmeros" => [/* Khmer */
218					'R' => "KhmerOS.ttf",
219					'useOTL' => 0xFF,
220				],
221				"dhyana" => [/* Lao fonts */
222					'R' => "Dhyana-Regular.ttf",
223					'B' => "Dhyana-Bold.ttf",
224					'useOTL' => 0xFF,
225				],
226				"tharlon" => [/* Myanmar / Burmese */
227					'R' => "Tharlon-Regular.ttf",
228					'useOTL' => 0xFF,
229				],
230				"padaukbook" => [/* Myanmar / Burmese */
231					'R' => "Padauk-book.ttf",
232					'useOTL' => 0xFF,
233				],
234				"zawgyi-one" => [/* Myanmar / Burmese */
235					'R' => "ZawgyiOne.ttf",
236					'useOTL' => 0xFF,
237				],
238				"ayar" => [/* Myanmar / Burmese */
239					'R' => "ayar.ttf",
240					'useOTL' => 0xFF,
241				],
242				"taameydavidclm" => [/* Hebrew with full Niqud and Cantillation */
243					'R' => "TaameyDavidCLM-Medium.ttf",
244					'useOTL' => 0xFF,
245				],
246				/* SMP */
247				"mph2bdamase" => [
248					'R' => "damase_v.2.ttf",
249				],
250				/* Indic */
251				"lohitkannada" => [
252					'R' => "Lohit-Kannada.ttf",
253					'useOTL' => 0xFF,
254				],
255				"pothana2000" => [
256					'R' => "Pothana2000.ttf",
257					'useOTL' => 0xFF,
258				],
259				/* Arabic fonts */
260				"xbriyaz" => [
261					'R' => "XB Riyaz.ttf",
262					'B' => "XB RiyazBd.ttf",
263					'I' => "XB RiyazIt.ttf",
264					'BI' => "XB RiyazBdIt.ttf",
265					'useOTL' => 0xFF,
266					'useKashida' => 75,
267				],
268				"lateef" => [/* Sindhi, Pashto and Urdu */
269					'R' => "LateefRegOT.ttf",
270					'useOTL' => 0xFF,
271					'useKashida' => 75,
272				],
273				"kfgqpcuthmantahanaskh" => [/* KFGQPC Uthman Taha Naskh - Koranic */
274					'R' => "Uthman.otf",
275					'useOTL' => 0xFF,
276					'useKashida' => 75,
277				],
278				/* CJK fonts */
279				"sun-exta" => [
280					'R' => "Sun-ExtA.ttf",
281					'sip-ext' => 'sun-extb', /* SIP=Plane2 Unicode (extension B) */
282				],
283				"sun-extb" => [
284					'R' => "Sun-ExtB.ttf",
285				],
286				"unbatang" => [/* Korean */
287					'R' => "UnBatang_0613.ttf",
288				],
289			],
290
291			// Add fonts to this array if they contain characters in the SIP or SMP Unicode planes
292			// but you do not require them. This allows a more efficient form of subsetting to be used.
293			'BMPonly' => [
294				"dejavusanscondensed",
295				"dejavusans",
296				"dejavuserifcondensed",
297				"dejavuserif",
298				"dejavusansmono",
299			],
300
301			// These next 3 arrays do two things:
302			// 1. If a font referred to in HTML/CSS is not available to mPDF, these arrays will determine whether
303			//    a serif/sans-serif or monospace font is substituted
304			// 2. The first font in each array will be the font which is substituted in circumstances as above
305			//     (Otherwise the order is irrelevant)
306			// Use the mPDF font-family names i.e. lowercase and no spaces (after any translations in $fonttrans)
307			// Always include "sans-serif", "serif" and "monospace" etc.
308			'sans_fonts' => ['dejavusanscondensed', 'sans', 'sans-serif', 'cursive', 'fantasy', 'dejavusans', 'freesans', 'liberationsans',
309				'arial', 'helvetica', 'verdana', 'geneva', 'lucida', 'arialnarrow', 'arialblack',
310				'franklin', 'franklingothicbook', 'tahoma', 'garuda', 'calibri', 'trebuchet', 'lucidagrande', 'microsoftsansserif',
311				'trebuchetms', 'lucidasansunicode', 'franklingothicmedium', 'albertusmedium', 'xbriyaz', 'albasuper', 'quillscript',
312				'humanist777', 'humanist777black', 'humanist777light', 'futura', 'hobo', 'segoeprint'
313			],
314
315			'serif_fonts' => ['dejavuserifcondensed', 'serif', 'dejavuserif', 'freeserif', 'liberationserif',
316				'timesnewroman', 'times', 'centuryschoolbookl', 'palatinolinotype', 'centurygothic',
317				'bookmanoldstyle', 'bookantiqua', 'cyberbit', 'cambria',
318				'norasi', 'charis', 'palatino', 'constantia', 'georgia', 'albertus', 'xbzar', 'algerian', 'garamond',
319			],
320
321			'mono_fonts' => ['dejavusansmono', 'mono', 'monospace', 'freemono', 'liberationmono', 'courier', 'ocrb', 'ocr-b', 'lucidaconsole',
322				'couriernew', 'monotypecorsiva'
323			],
324		];
325	}
326
327	public function getDefaults()
328	{
329		return $this->defaults;
330	}
331
332}
333