-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.js
70 lines (62 loc) · 2.21 KB
/
main.js
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
define([
'specimenTools/loadFonts'
, 'specimenTools/initDocumentWidgets'
, 'specimenTools/services/PubSub'
, 'specimenTools/services/FontsData'
, 'specimenTools/services/WebfontProvider'
, 'specimenTools/widgets/GlyphTables'
, 'specimenTools/widgets/FamilyChooser'
, 'specimenTools/widgets/GenericFontData'
, 'specimenTools/widgets/CurrentWebFont'
, 'specimenTools/widgets/TypeTester'
], function(
loadFonts
, initDocumentWidgets
, PubSub
, FontsData
, WebFontProvider
, GlyphTables
, FamilyChooser
, GenericFontData
, CurrentWebFont
, TypeTester
) {
"use strict";
/**
* A very basic initialization function without passing configuration
* with the factories array
*/
function main(window, fontFiles) {
// This PubSub instance is the centrally connecting element between
// all modules. The order in which modules subscribe to PubSub
// channels is relevant in some cases. I.e. when a subscriber is
// dependant on the state of another module.
var pubsub = new PubSub()
, factories
, fontsData = new FontsData(pubsub, {
useLaxDetection: true,
// passing in this object with a font's postscript name
// allows this name to be overwritten
overwrites: {
'JosefinSans': 'Testname: Josefin Sans'
}
})
, webFontProvider = new WebFontProvider(window, pubsub, fontsData)
;
factories = [
// [css-class of host element, Constructor(, further Constructor arguments, ...)]
// All Constructors are given [dom-container, pubsub] as the first two arguments.
['family-chooser', FamilyChooser, fontsData]
, ['glyph-table', GlyphTables]
, ['font-data', GenericFontData, fontsData]
, ['current-font', CurrentWebFont, webFontProvider]
, ['type-tester', TypeTester, fontsData]
];
initDocumentWidgets(window.document, factories, pubsub);
pubsub.subscribe('allFontsLoaded', function() {
pubsub.publish('activateFont', 0);
});
loadFonts.fromUrl(pubsub, fontFiles);
}
return main;
});