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
|
'use strict';
// The OpenType spec mentions that the follow tables are required for a font to
// function correctly. We'll have all the tables listed except for OS/2, which
// is not present in all fonts on Mac OS.
// https://docs.microsoft.com/en-us/typography/opentype/spec/otff#font-tables
const BASE_TABLES = [
'cmap',
'head',
'hhea',
'hmtx',
'maxp',
'name',
'post',
];
const MAC_FONTS = new Map([
['Monaco', {
postscriptName: 'Monaco',
fullName: 'Monaco',
family: 'Monaco',
style: 'Regular',
}],
['Menlo-Regular', {
postscriptName: 'Menlo-Regular',
fullName: 'Menlo Regular',
family: 'Menlo',
style: 'Regular',
}],
]);
const WIN_FONTS = new Map([
['Verdana', {
postscriptName: 'Verdana',
fullName: 'Verdana',
family: 'Verdana',
style: 'Regular',
}],
]);
const LINUX_FONTS = new Map([
['Ahem', {
postscriptName: 'Ahem',
fullName: 'Ahem',
family: 'Ahem',
style: 'Regular',
}],
]);
// Returns a map of known system fonts, mapping a font's postscript name to
// FontData.
function getTestData() {
let output = undefined;
if (navigator.platform.indexOf("Win") !== -1) {
output = WIN_FONTS;
} else if (navigator.platform.indexOf("Mac") !== -1) {
output = MAC_FONTS;
} else if (navigator.platform.indexOf("Linux") !== -1) {
output = LINUX_FONTS;
}
assert_not_equals(
output, undefined, 'Cannot get test set due to unsupported platform.');
return output;
}
|