Mercurial > hg-website
annotate static/javascript/typeface.js @ 248:53a5e100b497
Convert the frontpage, except for the download button.
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Wed, 23 Sep 2009 20:34:42 -0400 |
parents | |
children | 84f2a6a16bd2 |
rev | line source |
---|---|
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
1 /***************************************************************** |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
2 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
3 typeface.js, version 0.11 | typefacejs.neocracy.org |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
4 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
5 Copyright (c) 2008, David Chester davidchester@gmx.net |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
6 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
7 Permission is hereby granted, free of charge, to any person |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
8 obtaining a copy of this software and associated documentation |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
9 files (the "Software"), to deal in the Software without |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
10 restriction, including without limitation the rights to use, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
11 copy, modify, merge, publish, distribute, sublicense, and/or sell |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
12 copies of the Software, and to permit persons to whom the |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
13 Software is furnished to do so, subject to the following |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
14 conditions: |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
15 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
16 The above copyright notice and this permission notice shall be |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
17 included in all copies or substantial portions of the Software. |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
18 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
21 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
23 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
24 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
25 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
26 OTHER DEALINGS IN THE SOFTWARE. |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
27 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
28 *****************************************************************/ |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
29 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
30 (function() { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
31 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
32 var _typeface_js = { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
33 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
34 faces: {}, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
35 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
36 loadFace: function(typefaceData) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
37 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
38 var familyName = typefaceData.familyName.toLowerCase(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
39 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
40 if (!this.faces[familyName]) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
41 this.faces[familyName] = {}; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
42 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
43 if (!this.faces[familyName][typefaceData.cssFontWeight]) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
44 this.faces[familyName][typefaceData.cssFontWeight] = {}; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
45 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
46 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
47 var face = this.faces[familyName][typefaceData.cssFontWeight][typefaceData.cssFontStyle] = typefaceData; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
48 face.loaded = true; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
49 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
50 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
51 log: { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
52 debug: function(message) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
53 var typefaceConsole = document.getElementById('typeface-console'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
54 if (typefaceConsole) |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
55 typefaceConsole.innerHTML += 'DEBUG: ' + message + "<br>"; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
56 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
57 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
58 error: function(message) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
59 var typefaceConsole = document.getElementById('typeface-console'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
60 if (typefaceConsole) |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
61 typefaceConsole.innerHTML += 'ERROR: ' + message + "<br>"; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
62 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
63 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
64 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
65 pixelsFromPoints: function(face, style, points, dimension) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
66 var pixels = points * parseInt(style.fontSize) * 72 / (face.resolution * 100); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
67 if (dimension == 'horizontal' && style.fontStretchPercent) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
68 pixels *= style.fontStretchPercent; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
69 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
70 return pixels; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
71 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
72 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
73 pointsFromPixels: function(face, style, pixels, dimension) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
74 var points = pixels * face.resolution / (parseInt(style.fontSize) * 72 / 100); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
75 if (dimension == 'horizontal' && style.fontStretchPrecent) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
76 points *= style.fontStretchPercent; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
77 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
78 return points; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
79 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
80 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
81 cssFontWeightMap: { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
82 normal: 'normal', |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
83 bold: 'bold', |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
84 400: 'normal', |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
85 700: 'bold' |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
86 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
87 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
88 cssFontStretchMap: { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
89 'ultra-condensed': 0.55, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
90 'extra-condensed': 0.77, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
91 'condensed': 0.85, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
92 'semi-condensed': 0.93, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
93 'normal': 1, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
94 'semi-expanded': 1.07, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
95 'expanded': 1.15, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
96 'extra-expanded': 1.23, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
97 'ultra-expanded': 1.45, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
98 'default': 1 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
99 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
100 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
101 fallbackCharacter: '.', |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
102 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
103 getTextExtents: function(face, style, text) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
104 var extentX = 0; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
105 var extentY = 0; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
106 var horizontalAdvance; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
107 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
108 for (var i = 0; i < text.length; i++) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
109 var glyph = face.glyphs[text.charAt(i)] ? face.glyphs[text.charAt(i)] : face.glyphs[this.fallbackCharacter]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
110 var letterSpacingAdjustment = this.pointsFromPixels(face, style, style.letterSpacing); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
111 extentX += Math.max(glyph.ha, glyph.x_max) + letterSpacingAdjustment; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
112 horizontalAdvance += glyph.ha + letterSpacingAdjustment; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
113 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
114 return { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
115 x: extentX, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
116 y: extentY, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
117 ha: horizontalAdvance |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
118 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
119 }; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
120 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
121 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
122 pixelsFromCssAmount: function(cssAmount, defaultValue) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
123 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
124 var matches = undefined; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
125 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
126 if (cssAmount == 'normal') { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
127 return defaultValue; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
128 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
129 } else if (matches = cssAmount.match(/([\-\d+\.]+)px/)) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
130 return matches[1]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
131 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
132 } else if (matches = cssAmount.match(/([\-\d\.]+)pt/)) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
133 return matches[1] * 100 / 75; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
134 } else { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
135 return defaultValue; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
136 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
137 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
138 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
139 getRenderedText: function(e) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
140 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
141 var browserStyle = window.getComputedStyle ? |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
142 document.defaultView.getComputedStyle(e.parentNode, '') : |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
143 e.parentNode.currentStyle ? |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
144 e.parentNode.currentStyle : |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
145 { color: '#ff0000', fontSize: 12, fontFamily: 'arial' }; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
146 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
147 var inlineStyleAttribute = e.parentNode.getAttribute('style'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
148 if (inlineStyleAttribute && typeof(inlineStyleAttribute) == 'object') { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
149 inlineStyleAttribute = inlineStyleAttribute.cssText; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
150 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
151 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
152 if (inlineStyleAttribute) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
153 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
154 var inlineStyleDeclarations = inlineStyleAttribute.split(/\s*\;\s*/); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
155 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
156 var inlineStyle = {}; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
157 for (var i = 0; i < inlineStyleDeclarations.length; i++) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
158 var declaration = inlineStyleDeclarations[i]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
159 var declarationOperands = declaration.split(/\s*\:\s*/); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
160 inlineStyle[declarationOperands[0]] = declarationOperands[1]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
161 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
162 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
163 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
164 var style = { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
165 color: browserStyle.color, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
166 fontFamily: browserStyle.fontFamily.split(/\s*,\s*/)[0].replace(/(^"|^'|'$|"$)/g, '').toLowerCase(), |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
167 fontSize: this.pixelsFromCssAmount(browserStyle.fontSize, 12), |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
168 fontWeight: this.cssFontWeightMap[browserStyle.fontWeight], |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
169 fontStyle: browserStyle.fontStyle ? browserStyle.fontStyle : 'normal', |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
170 fontStretchPercent: this.cssFontStretchMap[inlineStyle && inlineStyle['font-stretch'] ? inlineStyle['font-stretch'] : 'default'], |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
171 textDecoration: browserStyle.textDecoration, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
172 lineHeight: this.pixelsFromCssAmount(browserStyle.lineHeight, 'normal'), |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
173 letterSpacing: this.pixelsFromCssAmount(browserStyle.letterSpacing, 0) |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
174 }; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
175 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
176 var face; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
177 if ( |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
178 this.faces[style.fontFamily] && |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
179 this.faces[style.fontFamily][style.fontWeight] |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
180 ) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
181 face = this.faces[style.fontFamily][style.fontWeight][style.fontStyle]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
182 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
183 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
184 if (!face) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
185 return; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
186 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
187 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
188 var text = e.nodeValue.replace(/(?:^\s+|\s+$)/g, ''); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
189 text = text.replace(/\s+/g, ' '); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
190 var words = text.split(/\s/); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
191 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
192 var containerSpan = document.createElement('span'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
193 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
194 for (var i = 0; i < words.length; i++) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
195 var word = words[i]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
196 var delimiter = i == words.length - 1 ? '' : ' '; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
197 var vectorElement = this.renderWord(face, style, word + delimiter); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
198 if (vectorElement) |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
199 containerSpan.appendChild(vectorElement); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
200 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
201 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
202 return containerSpan; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
203 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
204 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
205 renderDocument: function(callback) { // args: onComplete |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
206 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
207 if (this.renderDocumentLock) |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
208 return; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
209 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
210 this.renderDocumentLock = true; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
211 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
212 if (!callback) |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
213 callback = function(e) { e.style.visibility = 'visible' }; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
214 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
215 var elements = document.getElementsByTagName('*'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
216 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
217 var elementsLength = elements.length; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
218 for (var i = 0; i < elements.length; i++) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
219 if (elements[i].className.match(/(^|\s)typeface-js(\s|$)/) || elements[i].tagName.match(/^(H1|H2|H3|H4|H5|H6)$/)) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
220 this.replaceText(elements[i]); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
221 if (typeof callback == 'function') { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
222 callback(elements[i]); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
223 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
224 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
225 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
226 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
227 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
228 replaceText: function(e) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
229 if (e.hasChildNodes()) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
230 var childNodes = []; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
231 for (var i = 0; i < e.childNodes.length; i++) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
232 childNodes[i] = e.childNodes[i]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
233 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
234 for (var i = 0; i < childNodes.length; i++) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
235 this.replaceText(childNodes[i]); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
236 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
237 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
238 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
239 if (e.nodeType == 3 && e.nodeValue.match(/\S/)) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
240 var parentNode = e.parentNode; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
241 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
242 var renderedText = this.getRenderedText(e); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
243 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
244 if (renderedText) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
245 parentNode.insertBefore(renderedText, e); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
246 parentNode.removeChild(e); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
247 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
248 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
249 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
250 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
251 applyElementVerticalMetrics: function(face, style, e) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
252 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
253 var boundingBoxAdjustmentTop = this.pixelsFromPoints(face, style, face.ascender - Math.max(face.boundingBox.yMax, face.ascender)); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
254 var boundingBoxAdjustmentBottom = this.pixelsFromPoints(face, style, Math.min(face.boundingBox.yMin, face.descender) - face.descender); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
255 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
256 var cssLineHeightAdjustment = 0; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
257 if (style.lineHeight != 'normal') { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
258 cssLineHeightAdjustment = style.lineHeight - this.pixelsFromPoints(face, style, face.lineHeight); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
259 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
260 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
261 var marginTop = Math.round(boundingBoxAdjustmentTop + cssLineHeightAdjustment / 2); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
262 var marginBottom = Math.round(boundingBoxAdjustmentBottom + cssLineHeightAdjustment / 2); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
263 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
264 e.style.marginTop = marginTop + 'px'; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
265 e.style.marginBottom = marginBottom + 'px'; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
266 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
267 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
268 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
269 vectorBackends: { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
270 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
271 canvas: { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
272 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
273 _initializeSurface: function(face, style, text) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
274 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
275 var extents = this.getTextExtents(face, style, text); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
276 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
277 var canvas = document.createElement('canvas'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
278 canvas.innerHTML = text; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
279 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
280 this.applyElementVerticalMetrics(face, style, canvas); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
281 canvas.height = Math.round(this.pixelsFromPoints(face, style, face.lineHeight)); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
282 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
283 canvas.width = Math.round(this.pixelsFromPoints(face, style, extents.x, 'horizontal')); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
284 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
285 if (extents.x > extents.ha) |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
286 canvas.style.marginRight = Math.round(this.pixelsFromPoints(face, style, extents.x - extents.ha, 'horizontal')) + 'px'; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
287 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
288 var ctx = canvas.getContext('2d'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
289 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
290 var pointScale = this.pixelsFromPoints(face, style, 1); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
291 ctx.scale(pointScale * style.fontStretchPercent, -1 * pointScale); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
292 ctx.translate(0, -1 * face.ascender); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
293 ctx.fillStyle = style.color; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
294 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
295 return { context: ctx, canvas: canvas }; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
296 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
297 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
298 _renderGlyph: function(ctx, face, char, style) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
299 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
300 var glyph = face.glyphs[char]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
301 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
302 if (!glyph) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
303 //this.log.error("glyph not defined: " + char); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
304 return this.renderGlyph(ctx, face, this.fallbackCharacter, style); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
305 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
306 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
307 if (glyph.o) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
308 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
309 var outline; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
310 if (glyph.cached_outline) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
311 outline = glyph.cached_outline; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
312 } else { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
313 outline = glyph.o.split(' '); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
314 glyph.cached_outline = outline; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
315 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
316 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
317 for (var i = 0; i < outline.length; ) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
318 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
319 var action = outline[i++]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
320 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
321 switch(action) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
322 case 'm': |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
323 ctx.moveTo(outline[i++], outline[i++]); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
324 break; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
325 case 'l': |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
326 ctx.lineTo(outline[i++], outline[i++]); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
327 break; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
328 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
329 case 'q': |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
330 var cpx = outline[i++]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
331 var cpy = outline[i++]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
332 ctx.quadraticCurveTo(outline[i++], outline[i++], cpx, cpy); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
333 break; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
334 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
335 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
336 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
337 if (glyph.ha) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
338 var letterSpacingPoints = |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
339 style.letterSpacing && style.letterSpacing != 'normal' ? |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
340 this.pointsFromPixels(face, style, style.letterSpacing) : |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
341 0; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
342 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
343 ctx.translate(glyph.ha + letterSpacingPoints, 0); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
344 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
345 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
346 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
347 _renderWord: function(face, style, text) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
348 var surface = this.initializeSurface(face, style, text); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
349 var ctx = surface.context; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
350 var canvas = surface.canvas; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
351 ctx.beginPath(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
352 ctx.save(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
353 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
354 var chars = text.split(''); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
355 for (var i = 0; i < chars.length; i++) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
356 var char = chars[i]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
357 this.renderGlyph(ctx, face, char, style); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
358 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
359 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
360 ctx.fill(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
361 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
362 if (style.textDecoration == 'underline') { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
363 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
364 ctx.beginPath(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
365 ctx.moveTo(0, face.underlinePosition); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
366 ctx.restore(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
367 ctx.lineTo(0, face.underlinePosition); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
368 ctx.strokeStyle = style.color; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
369 ctx.lineWidth = face.underlineThickness; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
370 ctx.stroke(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
371 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
372 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
373 return ctx.canvas; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
374 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
375 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
376 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
377 vml: { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
378 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
379 _initializeSurface: function(face, style, text) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
380 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
381 var shape = document.createElement('v:shape'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
382 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
383 var extents = this.getTextExtents(face, style, text); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
384 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
385 shape.style.width = style.fontSize + 'px'; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
386 shape.style.height = style.fontSize + 'px'; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
387 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
388 if (extents.x > extents.ha) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
389 shape.style.marginRight = this.pixelsFromPoints(face, style, extents.x - extents.ha, 'horizontal') + 'px'; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
390 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
391 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
392 this.applyElementVerticalMetrics(face, style, shape); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
393 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
394 shape.coordsize = (face.resolution * 100 / style.fontStretchPercent / 72 ) + "," + (face.resolution * 100 / 72); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
395 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
396 shape.coordorigin = '0,' + face.ascender; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
397 shape.style.flip = 'y'; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
398 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
399 shape.fillColor = style.color; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
400 shape.stroked = false; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
401 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
402 shape.path = 'hh m 0,' + face.ascender + ' l 0,' + face.descender + ' '; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
403 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
404 return shape; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
405 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
406 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
407 _renderGlyph: function(shape, face, char, offsetX, style) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
408 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
409 var glyph = face.glyphs[char]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
410 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
411 if (!glyph) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
412 //this.log.error("glyph not defined: " + char); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
413 this.renderGlyph(shape, face, this.fallbackCharacter, offsetX, style); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
414 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
415 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
416 var vmlSegments = []; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
417 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
418 if (glyph.o) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
419 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
420 var outline; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
421 if (glyph.cached_outline) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
422 outline = glyph.cached_outline; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
423 } else { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
424 outline = glyph.o.split(' '); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
425 glyph.cached_outline = outline; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
426 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
427 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
428 var prevAction, prevX, prevY; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
429 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
430 var i; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
431 for (i = 0; i < outline.length;) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
432 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
433 var action = outline[i++]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
434 var vmlSegment = ''; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
435 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
436 var x = Math.round(outline[i++]) + offsetX; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
437 var y = Math.round(outline[i++]); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
438 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
439 switch(action) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
440 case 'm': |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
441 vmlSegment = (vmlSegments.length ? 'x ' : '') + 'm ' + x + ',' + y; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
442 break; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
443 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
444 case 'l': |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
445 vmlSegment = 'l ' + x + ',' + y; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
446 break; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
447 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
448 case 'q': |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
449 var cpx = Math.round(outline[i++]) + offsetX; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
450 var cpy = Math.round(outline[i++]); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
451 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
452 var cp1x = Math.round(prevX + 2.0 / 3.0 * (cpx - prevX)); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
453 var cp1y = Math.round(prevY + 2.0 / 3.0 * (cpy - prevY)); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
454 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
455 var cp2x = Math.round(cp1x + (x - prevX) / 3.0); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
456 var cp2y = Math.round(cp1y + (y - prevY) / 3.0); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
457 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
458 vmlSegment = 'c ' + cp1x + ',' + cp1y + ',' + cp2x + ',' + cp2y + ',' + x + ',' + y; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
459 break; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
460 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
461 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
462 prevAction = action; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
463 prevX = x; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
464 prevY = y; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
465 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
466 if (vmlSegment.length) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
467 vmlSegments.push(vmlSegment); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
468 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
469 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
470 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
471 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
472 vmlSegments.push('x', 'e'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
473 return vmlSegments.join(' '); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
474 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
475 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
476 _renderWord: function(face, style, text) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
477 var offsetX = 0; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
478 var shape = this.initializeSurface(face, style, text); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
479 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
480 var letterSpacingPoints = |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
481 style.letterSpacing && style.letterSpacing != 'normal' ? |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
482 this.pointsFromPixels(face, style, style.letterSpacing) : |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
483 0; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
484 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
485 letterSpacingPoints = Math.round(letterSpacingPoints); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
486 var chars = text.split(''); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
487 for (var i = 0; i < chars.length; i++) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
488 var char = chars[i]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
489 shape.path += this.renderGlyph(shape, face, char, offsetX, style) + ' '; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
490 offsetX += face.glyphs[char].ha + letterSpacingPoints ; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
491 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
492 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
493 shape.style.marginRight = this.pixelsFromPoints(face, style, face.glyphs[' '].ha) + 'px'; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
494 return shape; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
495 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
496 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
497 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
498 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
499 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
500 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
501 setVectorBackend: function(backend) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
502 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
503 var backendFunctions = ['renderWord', 'initializeSurface', 'renderGlyph']; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
504 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
505 for (var i = 0; i < backendFunctions.length; i++) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
506 var backendFunction = backendFunctions[i]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
507 this[backendFunction] = this.vectorBackends[backend]['_' + backendFunction]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
508 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
509 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
510 }; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
511 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
512 // IE won't accept real selectors... |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
513 var typefaceSelectors = ['.typeface-js', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
514 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
515 if (document.createStyleSheet) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
516 var styleSheet = document.createStyleSheet(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
517 for (var i = 0; i < typefaceSelectors.length; i++) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
518 var selector = typefaceSelectors[i]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
519 styleSheet.addRule(selector, 'visibility: hidden'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
520 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
521 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
522 } else if (document.styleSheets && document.styleSheets.length) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
523 var styleSheet = document.styleSheets[0]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
524 document.styleSheets[0].insertRule(typefaceSelectors.join(',') + ' { visibility: hidden; }', styleSheet.cssRules.length); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
525 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
526 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
527 var backend = !!(window.attachEvent && !window.opera) ? 'vml' : window.CanvasRenderingContext2D || document.createElement('canvas').getContext ? 'canvas' : null; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
528 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
529 if (backend == 'vml') { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
530 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
531 document.namespaces.add("v"); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
532 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
533 var styleSheet = document.createStyleSheet(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
534 styleSheet.addRule('v\\:*', "behavior: url(#default#VML); display: inline-block;"); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
535 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
536 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
537 _typeface_js.setVectorBackend(backend); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
538 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
539 window._typeface_js = _typeface_js; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
540 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
541 // based on code by Dean Edwards / Matthias Miller / John Resig |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
542 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
543 function typefaceInit() { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
544 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
545 // quit if this function has already been called |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
546 if (arguments.callee.done) return; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
547 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
548 // flag this function so we don't do the same thing twice |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
549 arguments.callee.done = true; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
550 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
551 // kill the timer |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
552 if (window._typefaceTimer) clearInterval(_typefaceTimer); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
553 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
554 _typeface_js.renderDocument( function(e) { e.style.visibility = 'visible' } ); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
555 }; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
556 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
557 if (/WebKit/i.test(navigator.userAgent)) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
558 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
559 var _typefaceTimer = setInterval(function() { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
560 if (/loaded|complete/.test(document.readyState)) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
561 typefaceInit(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
562 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
563 }, 10); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
564 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
565 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
566 if (document.addEventListener) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
567 window.addEventListener('DOMContentLoaded', function() { typefaceInit() }, false); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
568 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
569 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
570 /*@cc_on @*/ |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
571 /*@if (@_win32) |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
572 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
573 document.write("<script id=__ie_onload_typeface defer src=javascript:void(0)><\/script>"); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
574 var script = document.getElementById("__ie_onload_typeface"); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
575 script.onreadystatechange = function() { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
576 if (this.readyState == "complete") { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
577 typefaceInit(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
578 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
579 }; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
580 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
581 /*@end @*/ |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
582 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
583 })(); |