forked from foliojs/fontkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.js
More file actions
29 lines (23 loc) · 643 Bytes
/
Copy pathbase.js
File metadata and controls
29 lines (23 loc) · 643 Bytes
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
import {DecodeStream} from 'restructure';
export let logErrors = false;
let formats = [];
export function registerFormat(format) {
formats.push(format);
};
export function create(buffer, postscriptName) {
for (let i = 0; i < formats.length; i++) {
let format = formats[i];
if (format.probe(buffer)) {
let font = new format(new DecodeStream(buffer));
if (postscriptName) {
return font.getFont(postscriptName);
}
return font;
}
}
throw new Error('Unknown font format');
};
export let defaultLanguage = 'en';
export function setDefaultLanguage(lang = 'en') {
defaultLanguage = lang;
};