Mercurial > hg-website
annotate static/javascript/typeface.js @ 295:bbe97888b5a3
Update substate
author | David Soria Parra <dsp@php.net> |
---|---|
date | Tue, 01 Dec 2009 23:35:20 +0100 |
parents | b9105ed958a4 |
children |
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 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
3 typeface.js, version 0.13 | typefacejs.neocracy.org |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
4 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
5 Copyright (c) 2008 - 2009, David Chester davidchester@gmx.net |
248
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 *****************************************************************/ |
279
b9105ed958a4
typeface: temporarly fix rendering on IE8 64bit
David Soria Parra <dsp@php.net>
parents:
277
diff
changeset
|
29 if (/MSIE/i.test(navigator.userAgent) && /x64/i.test(navigator.userAgent)) { |
b9105ed958a4
typeface: temporarly fix rendering on IE8 64bit
David Soria Parra <dsp@php.net>
parents:
277
diff
changeset
|
30 var _typeface_js = {}; |
b9105ed958a4
typeface: temporarly fix rendering on IE8 64bit
David Soria Parra <dsp@php.net>
parents:
277
diff
changeset
|
31 window._typeface_js = _typeface_js; |
b9105ed958a4
typeface: temporarly fix rendering on IE8 64bit
David Soria Parra <dsp@php.net>
parents:
277
diff
changeset
|
32 } else { |
248
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 (function() { |
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 var _typeface_js = { |
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 faces: {}, |
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 loadFace: function(typefaceData) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
41 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
42 var familyName = typefaceData.familyName.toLowerCase(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
43 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
44 if (!this.faces[familyName]) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
45 this.faces[familyName] = {}; |
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 if (!this.faces[familyName][typefaceData.cssFontWeight]) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
48 this.faces[familyName][typefaceData.cssFontWeight] = {}; |
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 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
|
52 face.loaded = true; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
53 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
54 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
55 log: function(message) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
56 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
57 if (this.quiet) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
58 return; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
59 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
60 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
61 message = "typeface.js: " + message; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
62 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
63 if (this.customLogFn) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
64 this.customLogFn(message); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
65 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
66 } else if (window.console && window.console.log) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
67 window.console.log(message); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
68 } |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
69 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
70 }, |
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 pixelsFromPoints: function(face, style, points, dimension) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
73 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
|
74 if (dimension == 'horizontal' && style.fontStretchPercent) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
75 pixels *= style.fontStretchPercent; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
76 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
77 return pixels; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
78 }, |
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 pointsFromPixels: function(face, style, pixels, dimension) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
81 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
|
82 if (dimension == 'horizontal' && style.fontStretchPrecent) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
83 points *= style.fontStretchPercent; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
84 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
85 return points; |
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 cssFontWeightMap: { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
89 normal: 'normal', |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
90 bold: 'bold', |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
91 400: 'normal', |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
92 700: 'bold' |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
93 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
94 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
95 cssFontStretchMap: { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
96 'ultra-condensed': 0.55, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
97 'extra-condensed': 0.77, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
98 'condensed': 0.85, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
99 'semi-condensed': 0.93, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
100 'normal': 1, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
101 'semi-expanded': 1.07, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
102 'expanded': 1.15, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
103 'extra-expanded': 1.23, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
104 'ultra-expanded': 1.45, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
105 'default': 1 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
106 }, |
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 fallbackCharacter: '.', |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
109 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
110 configure: function(args) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
111 var configurableOptionNames = [ 'customLogFn', 'customClassNameRegex', 'customTypefaceElementsList', 'quiet', 'verbose', 'disableSelection' ]; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
112 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
113 for (var i = 0; i < configurableOptionNames.length; i++) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
114 var optionName = configurableOptionNames[i]; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
115 if (args[optionName]) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
116 if (optionName == 'customLogFn') { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
117 if (typeof args[optionName] != 'function') { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
118 throw "customLogFn is not a function"; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
119 } else { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
120 this.customLogFn = args.customLogFn; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
121 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
122 } else { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
123 this[optionName] = args[optionName]; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
124 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
125 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
126 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
127 }, |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
128 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
129 getTextExtents: function(face, style, text) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
130 var extentX = 0; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
131 var extentY = 0; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
132 var horizontalAdvance; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
133 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
134 var textLength = text.length; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
135 for (var i = 0; i < textLength; i++) { |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
136 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
|
137 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
|
138 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
|
139 horizontalAdvance += glyph.ha + letterSpacingAdjustment; |
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 return { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
142 x: extentX, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
143 y: extentY, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
144 ha: horizontalAdvance |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
145 |
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 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
148 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
149 pixelsFromCssAmount: function(cssAmount, defaultValue, element) { |
248
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 var matches = undefined; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
152 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
153 if (cssAmount == 'normal') { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
154 return defaultValue; |
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 } else if (matches = cssAmount.match(/([\-\d+\.]+)px/)) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
157 return matches[1]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
158 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
159 } else { |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
160 // thanks to Dean Edwards for this very sneaky way to get IE to convert |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
161 // relative values to pixel values |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
162 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
163 var pixelAmount; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
164 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
165 var leftInlineStyle = element.style.left; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
166 var leftRuntimeStyle = element.runtimeStyle.left; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
167 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
168 element.runtimeStyle.left = element.currentStyle.left; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
169 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
170 if (!cssAmount.match(/\d(px|pt)$/)) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
171 element.style.left = '1em'; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
172 } else { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
173 element.style.left = cssAmount || 0; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
174 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
175 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
176 pixelAmount = element.style.pixelLeft; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
177 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
178 element.style.left = leftInlineStyle; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
179 element.runtimeStyle.left = leftRuntimeStyle; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
180 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
181 return pixelAmount || defaultValue; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
182 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
183 }, |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
184 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
185 capitalizeText: function(text) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
186 return text.replace(/(^|\s)[a-z]/g, function(match) { return match.toUpperCase() } ); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
187 }, |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
188 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
189 getElementStyle: function(e) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
190 if (window.getComputedStyle) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
191 return window.getComputedStyle(e, ''); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
192 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
193 } else if (e.currentStyle) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
194 return e.currentStyle; |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
195 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
196 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
197 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
198 getRenderedText: function(e) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
199 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
200 var browserStyle = this.getElementStyle(e.parentNode); |
248
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 var inlineStyleAttribute = e.parentNode.getAttribute('style'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
203 if (inlineStyleAttribute && typeof(inlineStyleAttribute) == 'object') { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
204 inlineStyleAttribute = inlineStyleAttribute.cssText; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
205 } |
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 (inlineStyleAttribute) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
208 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
209 var inlineStyleDeclarations = inlineStyleAttribute.split(/\s*\;\s*/); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
210 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
211 var inlineStyle = {}; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
212 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
|
213 var declaration = inlineStyleDeclarations[i]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
214 var declarationOperands = declaration.split(/\s*\:\s*/); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
215 inlineStyle[declarationOperands[0]] = declarationOperands[1]; |
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 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
218 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
219 var style = { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
220 color: browserStyle.color, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
221 fontFamily: browserStyle.fontFamily.split(/\s*,\s*/)[0].replace(/(^"|^'|'$|"$)/g, '').toLowerCase(), |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
222 fontSize: this.pixelsFromCssAmount(browserStyle.fontSize, 12, e.parentNode), |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
223 fontWeight: this.cssFontWeightMap[browserStyle.fontWeight], |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
224 fontStyle: browserStyle.fontStyle ? browserStyle.fontStyle : 'normal', |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
225 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
|
226 textDecoration: browserStyle.textDecoration, |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
227 lineHeight: this.pixelsFromCssAmount(browserStyle.lineHeight, 'normal', e.parentNode), |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
228 letterSpacing: this.pixelsFromCssAmount(browserStyle.letterSpacing, 0, e.parentNode), |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
229 textTransform: browserStyle.textTransform |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
230 }; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
231 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
232 var face; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
233 if ( |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
234 this.faces[style.fontFamily] |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
235 && this.faces[style.fontFamily][style.fontWeight] |
248
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 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
|
238 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
239 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
240 var text = e.nodeValue; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
241 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
242 if ( |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
243 e.previousSibling |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
244 && e.previousSibling.nodeType == 1 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
245 && e.previousSibling.tagName != 'BR' |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
246 && this.getElementStyle(e.previousSibling).display.match(/inline/) |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
247 ) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
248 text = text.replace(/^\s+/, ' '); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
249 } else { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
250 text = text.replace(/^\s+/, ''); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
251 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
252 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
253 if ( |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
254 e.nextSibling |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
255 && e.nextSibling.nodeType == 1 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
256 && e.nextSibling.tagName != 'BR' |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
257 && this.getElementStyle(e.nextSibling).display.match(/inline/) |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
258 ) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
259 text = text.replace(/\s+$/, ' '); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
260 } else { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
261 text = text.replace(/\s+$/, ''); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
262 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
263 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
264 text = text.replace(/\s+/g, ' '); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
265 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
266 if (style.textTransform && style.textTransform != 'none') { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
267 switch (style.textTransform) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
268 case 'capitalize': |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
269 text = this.capitalizeText(text); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
270 break; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
271 case 'uppercase': |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
272 text = text.toUpperCase(); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
273 break; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
274 case 'lowercase': |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
275 text = text.toLowerCase(); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
276 break; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
277 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
278 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
279 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
280 if (!face) { |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
281 var excerptLength = 12; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
282 var textExcerpt = text.substring(0, excerptLength); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
283 if (text.length > excerptLength) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
284 textExcerpt += '...'; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
285 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
286 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
287 var fontDescription = style.fontFamily; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
288 if (style.fontWeight != 'normal') fontDescription += ' ' + style.fontWeight; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
289 if (style.fontStyle != 'normal') fontDescription += ' ' + style.fontStyle; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
290 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
291 this.log("couldn't find typeface font: " + fontDescription + ' for text "' + textExcerpt + '"'); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
292 return; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
293 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
294 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
295 var words = text.split(/\b(?=\w)/); |
248
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 var containerSpan = document.createElement('span'); |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
298 containerSpan.className = 'typeface-js-vector-container'; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
299 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
300 var wordsLength = words.length |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
301 for (var i = 0; i < wordsLength; i++) { |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
302 var word = words[i]; |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
303 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
304 var vector = this.renderWord(face, style, word); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
305 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
306 if (vector) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
307 containerSpan.appendChild(vector.element); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
308 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
309 if (!this.disableSelection) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
310 var selectableSpan = document.createElement('span'); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
311 selectableSpan.className = 'typeface-js-selected-text'; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
312 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
313 var wordNode = document.createTextNode(word); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
314 selectableSpan.appendChild(wordNode); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
315 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
316 if (this.vectorBackend != 'vml') { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
317 selectableSpan.style.marginLeft = -1 * (vector.width + 1) + 'px'; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
318 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
319 selectableSpan.targetWidth = vector.width; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
320 //selectableSpan.style.lineHeight = 1 + 'px'; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
321 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
322 if (this.vectorBackend == 'vml') { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
323 vector.element.appendChild(selectableSpan); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
324 } else { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
325 containerSpan.appendChild(selectableSpan); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
326 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
327 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
328 } |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
329 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
330 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
331 return containerSpan; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
332 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
333 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
334 renderDocument: function(callback) { |
248
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 if (!callback) |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
337 callback = function(e) { e.style.visibility = 'visible' }; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
338 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
339 var elements = document.getElementsByTagName('*'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
340 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
341 var elementsLength = elements.length; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
342 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
|
343 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
|
344 this.replaceText(elements[i]); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
345 if (typeof callback == 'function') { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
346 callback(elements[i]); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
347 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
348 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
349 } |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
350 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
351 if (this.vectorBackend == 'vml') { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
352 // lamely work around IE's quirky leaving off final dynamic shapes |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
353 var dummyShape = document.createElement('v:shape'); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
354 dummyShape.style.display = 'none'; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
355 document.body.appendChild(dummyShape); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
356 } |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
357 }, |
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 replaceText: function(e) { |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
360 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
361 var childNodes = []; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
362 var childNodesLength = e.childNodes.length; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
363 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
364 for (var i = 0; i < childNodesLength; i++) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
365 this.replaceText(e.childNodes[i]); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
366 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
367 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
368 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
|
369 var parentNode = e.parentNode; |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
370 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
371 if (parentNode.className == 'typeface-js-selected-text') { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
372 return; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
373 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
374 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
375 var renderedText = this.getRenderedText(e); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
376 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
377 if ( |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
378 parentNode.tagName == 'A' |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
379 && this.vectorBackend == 'vml' |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
380 && this.getElementStyle(parentNode).display == 'inline' |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
381 ) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
382 // something of a hack, use inline-block to get IE to accept clicks in whitespace regions |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
383 parentNode.style.display = 'inline-block'; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
384 parentNode.style.cursor = 'pointer'; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
385 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
386 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
387 if (this.getElementStyle(parentNode).display == 'inline') { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
388 parentNode.style.display = 'inline-block'; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
389 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
390 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
391 if (renderedText) { |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
392 if (parentNode.replaceChild) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
393 parentNode.replaceChild(renderedText, e); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
394 } else { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
395 parentNode.insertBefore(renderedText, e); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
396 parentNode.removeChild(e); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
397 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
398 if (this.vectorBackend == 'vml') { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
399 renderedText.innerHTML = renderedText.innerHTML; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
400 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
401 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
402 var childNodesLength = renderedText.childNodes.length |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
403 for (var i; i < childNodesLength; i++) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
404 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
405 // do our best to line up selectable text with rendered text |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
406 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
407 var e = renderedText.childNodes[i]; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
408 if (e.hasChildNodes() && !e.targetWidth) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
409 e = e.childNodes[0]; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
410 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
411 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
412 if (e && e.targetWidth) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
413 var letterSpacingCount = e.innerHTML.length; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
414 var wordSpaceDelta = e.targetWidth - e.offsetWidth; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
415 var letterSpacing = wordSpaceDelta / (letterSpacingCount || 1); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
416 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
417 if (this.vectorBackend == 'vml') { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
418 letterSpacing = Math.ceil(letterSpacing); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
419 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
420 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
421 e.style.letterSpacing = letterSpacing + 'px'; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
422 e.style.width = e.targetWidth + 'px'; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
423 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
424 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
425 } |
248
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 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
429 applyElementVerticalMetrics: function(face, style, e) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
430 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
431 if (style.lineHeight == 'normal') { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
432 style.lineHeight = this.pixelsFromPoints(face, style, face.lineHeight); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
433 } |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
434 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
435 var cssLineHeightAdjustment = style.lineHeight - this.pixelsFromPoints(face, style, face.lineHeight); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
436 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
437 e.style.marginTop = Math.round( cssLineHeightAdjustment / 2 ) + 'px'; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
438 e.style.marginBottom = Math.round( cssLineHeightAdjustment / 2) + 'px'; |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
439 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
440 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
441 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
442 vectorBackends: { |
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 canvas: { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
445 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
446 _initializeSurface: function(face, style, text) { |
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 var extents = this.getTextExtents(face, style, text); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
449 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
450 var canvas = document.createElement('canvas'); |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
451 if (this.disableSelection) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
452 canvas.innerHTML = text; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
453 } |
248
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 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
|
456 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
|
457 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
458 this.applyElementVerticalMetrics(face, style, canvas); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
459 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
460 if (extents.x > extents.ha) |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
461 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
|
462 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
463 var ctx = canvas.getContext('2d'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
464 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
465 var pointScale = this.pixelsFromPoints(face, style, 1); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
466 ctx.scale(pointScale * style.fontStretchPercent, -1 * pointScale); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
467 ctx.translate(0, -1 * face.ascender); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
468 ctx.fillStyle = style.color; |
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 return { context: ctx, canvas: canvas }; |
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 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
473 _renderGlyph: function(ctx, face, char, style) { |
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 var glyph = face.glyphs[char]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
476 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
477 if (!glyph) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
478 //this.log.error("glyph not defined: " + char); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
479 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
|
480 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
481 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
482 if (glyph.o) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
483 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
484 var outline; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
485 if (glyph.cached_outline) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
486 outline = glyph.cached_outline; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
487 } else { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
488 outline = glyph.o.split(' '); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
489 glyph.cached_outline = outline; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
490 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
491 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
492 var outlineLength = outline.length; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
493 for (var i = 0; i < outlineLength; ) { |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
494 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
495 var action = outline[i++]; |
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 switch(action) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
498 case 'm': |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
499 ctx.moveTo(outline[i++], outline[i++]); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
500 break; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
501 case 'l': |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
502 ctx.lineTo(outline[i++], outline[i++]); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
503 break; |
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 case 'q': |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
506 var cpx = outline[i++]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
507 var cpy = outline[i++]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
508 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
|
509 break; |
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 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
513 if (glyph.ha) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
514 var letterSpacingPoints = |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
515 style.letterSpacing && style.letterSpacing != 'normal' ? |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
516 this.pointsFromPixels(face, style, style.letterSpacing) : |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
517 0; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
518 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
519 ctx.translate(glyph.ha + letterSpacingPoints, 0); |
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 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
523 _renderWord: function(face, style, text) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
524 var surface = this.initializeSurface(face, style, text); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
525 var ctx = surface.context; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
526 var canvas = surface.canvas; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
527 ctx.beginPath(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
528 ctx.save(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
529 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
530 var chars = text.split(''); |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
531 var charsLength = chars.length; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
532 for (var i = 0; i < charsLength; i++) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
533 this.renderGlyph(ctx, face, chars[i], style); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
534 } |
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 ctx.fill(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
537 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
538 if (style.textDecoration == 'underline') { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
539 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
540 ctx.beginPath(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
541 ctx.moveTo(0, face.underlinePosition); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
542 ctx.restore(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
543 ctx.lineTo(0, face.underlinePosition); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
544 ctx.strokeStyle = style.color; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
545 ctx.lineWidth = face.underlineThickness; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
546 ctx.stroke(); |
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 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
549 return { element: ctx.canvas, width: Math.floor(canvas.width) }; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
550 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
551 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
552 }, |
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 vml: { |
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 _initializeSurface: function(face, style, text) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
557 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
558 var shape = document.createElement('v:shape'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
559 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
560 var extents = this.getTextExtents(face, style, text); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
561 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
562 shape.style.width = shape.style.height = style.fontSize + 'px'; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
563 shape.style.marginLeft = '-1px'; // this seems suspect... |
248
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 if (extents.x > extents.ha) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
566 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
|
567 } |
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 this.applyElementVerticalMetrics(face, style, shape); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
570 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
571 var resolutionScale = face.resolution * 100 / 72; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
572 shape.coordsize = (resolutionScale / style.fontStretchPercent) + "," + resolutionScale; |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
573 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
574 shape.coordorigin = '0,' + face.ascender; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
575 shape.style.flip = 'y'; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
576 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
577 shape.fillColor = style.color; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
578 shape.stroked = false; |
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 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
|
581 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
582 return shape; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
583 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
584 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
585 _renderGlyph: function(shape, face, char, offsetX, style, vmlSegments) { |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
586 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
587 var glyph = face.glyphs[char]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
588 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
589 if (!glyph) { |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
590 this.log("glyph not defined: " + char); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
591 this.renderGlyph(shape, face, this.fallbackCharacter, offsetX, style); |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
592 return; |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
593 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
594 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
595 vmlSegments.push('m'); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
596 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
597 if (glyph.o) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
598 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
599 var outline, outlineLength; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
600 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
601 if (glyph.cached_outline) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
602 outline = glyph.cached_outline; |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
603 outlineLength = outline.length; |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
604 } else { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
605 outline = glyph.o.split(' '); |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
606 outlineLength = outline.length; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
607 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
608 for (var i = 0; i < outlineLength;) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
609 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
610 switch(outline[i++]) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
611 case 'q': |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
612 outline[i] = Math.round(outline[i++]); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
613 outline[i] = Math.round(outline[i++]); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
614 case 'm': |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
615 case 'l': |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
616 outline[i] = Math.round(outline[i++]); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
617 outline[i] = Math.round(outline[i++]); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
618 break; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
619 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
620 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
621 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
622 glyph.cached_outline = outline; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
623 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
624 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
625 var prevX, prevY; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
626 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
627 for (var i = 0; i < outlineLength;) { |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
628 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
629 var action = outline[i++]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
630 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
631 var x = outline[i++] + offsetX; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
632 var y = outline[i++]; |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
633 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
634 switch(action) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
635 case 'm': |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
636 vmlSegments.push('xm ', x, ',', y); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
637 break; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
638 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
639 case 'l': |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
640 vmlSegments.push('l ', x, ',', y); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
641 break; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
642 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
643 case 'q': |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
644 var cpx = outline[i++] + offsetX; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
645 var cpy = outline[i++]; |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
646 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
647 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
|
648 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
|
649 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
650 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
|
651 var cp2y = Math.round(cp1y + (y - prevY) / 3.0); |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
652 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
653 vmlSegments.push('c ', cp1x, ',', cp1y, ',', cp2x, ',', cp2y, ',', x, ',', y); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
654 break; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
655 } |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
656 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
657 prevX = x; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
658 prevY = y; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
659 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
660 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
661 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
662 vmlSegments.push('x e'); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
663 return vmlSegments; |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
664 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
665 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
666 _renderWord: function(face, style, text) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
667 var offsetX = 0; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
668 var shape = this.initializeSurface(face, style, text); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
669 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
670 var letterSpacingPoints = |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
671 style.letterSpacing && style.letterSpacing != 'normal' ? |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
672 this.pointsFromPixels(face, style, style.letterSpacing) : |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
673 0; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
674 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
675 letterSpacingPoints = Math.round(letterSpacingPoints); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
676 var chars = text.split(''); |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
677 var vmlSegments = []; |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
678 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
|
679 var char = chars[i]; |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
680 vmlSegments = this.renderGlyph(shape, face, char, offsetX, style, vmlSegments); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
681 offsetX += face.glyphs[char].ha + letterSpacingPoints ; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
682 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
683 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
684 // make sure to preserve trailing whitespace |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
685 shape.path += vmlSegments.join('') + 'm ' + offsetX + ' 0 l ' + offsetX + ' ' + face.ascender; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
686 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
687 return { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
688 element: shape, |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
689 width: Math.floor(this.pixelsFromPoints(face, style, offsetX, 'horizontal')) |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
690 }; |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
691 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
692 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
693 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
694 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
695 }, |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
696 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
697 setVectorBackend: function(backend) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
698 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
699 this.vectorBackend = backend; |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
700 var backendFunctions = ['renderWord', 'initializeSurface', 'renderGlyph']; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
701 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
702 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
|
703 var backendFunction = backendFunctions[i]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
704 this[backendFunction] = this.vectorBackends[backend]['_' + backendFunction]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
705 } |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
706 }, |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
707 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
708 initialize: function() { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
709 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
710 // quit if this function has already been called |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
711 if (arguments.callee.done) return; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
712 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
713 // flag this function so we don't do the same thing twice |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
714 arguments.callee.done = true; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
715 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
716 // kill the timer |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
717 if (window._typefaceTimer) clearInterval(_typefaceTimer); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
718 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
719 this.renderDocument( function(e) { e.style.visibility = 'visible' } ); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
720 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
721 } |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
722 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
723 }; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
724 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
725 // IE won't accept real selectors... |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
726 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
|
727 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
728 if (document.createStyleSheet) { |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
729 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
730 var styleSheet = document.createStyleSheet(); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
731 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
|
732 var selector = typefaceSelectors[i]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
733 styleSheet.addRule(selector, 'visibility: hidden'); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
734 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
735 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
736 styleSheet.addRule( |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
737 '.typeface-js-selected-text', |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
738 '-ms-filter: \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
739 "Chroma(color=black) \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
740 progid:DXImageTransform.Microsoft.MaskFilter(Color=white) \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
741 progid:DXImageTransform.Microsoft.MaskFilter(Color=blue) \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
742 alpha(opacity=30)" !important; \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
743 color: black; \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
744 font-family: Modern; \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
745 position: absolute; \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
746 white-space: pre; \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
747 filter: alpha(opacity=0);' |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
748 ); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
749 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
750 styleSheet.addRule( |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
751 '.typeface-js-vector-container', |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
752 'position: relative' |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
753 ); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
754 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
755 } else if (document.styleSheets && document.styleSheets.length) { |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
756 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
757 var styleSheet = document.styleSheets[0]; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
758 document.styleSheets[0].insertRule(typefaceSelectors.join(',') + ' { visibility: hidden; }', styleSheet.cssRules.length); |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
759 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
760 document.styleSheets[0].insertRule( |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
761 '.typeface-js-selected-text { \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
762 color: rgba(128, 128, 128, 0); \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
763 opacity: 0.30; \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
764 position: absolute; \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
765 font-family: Arial, sans-serif; \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
766 white-space: pre \ |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
767 }', |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
768 styleSheet.cssRules.length |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
769 ); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
770 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
771 try { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
772 // set selection style for Mozilla / Firefox |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
773 document.styleSheets[0].insertRule( |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
774 '.typeface-js-selected-text::-moz-selection { background: blue; }', |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
775 styleSheet.cssRules.length |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
776 ); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
777 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
778 } catch(e) {}; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
779 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
780 try { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
781 // set styles for browsers with CSS3 selectors (Safari, Chrome) |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
782 document.styleSheets[0].insertRule( |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
783 '.typeface-js-selected-text::selection { background: blue; }', |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
784 styleSheet.cssRules.length |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
785 ); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
786 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
787 } catch(e) {}; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
788 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
789 // most unfortunately, sniff for WebKit's quirky selection behavior |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
790 if (/WebKit/i.test(navigator.userAgent)) { |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
791 document.styleSheets[0].insertRule( |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
792 '.typeface-js-vector-container { position: relative }', |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
793 styleSheet.cssRules.length |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
794 ); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
795 } |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
796 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
797 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
798 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
799 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
|
800 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
801 if (backend == 'vml') { |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
802 |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
803 document.namespaces.add("v","urn:schemas-microsoft-com:vml","#default#VML"); |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
804 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
805 var styleSheet = document.createStyleSheet(); |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
806 styleSheet.addRule('v\\:shape', "display: inline-block;"); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
807 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
808 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
809 _typeface_js.setVectorBackend(backend); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
810 window._typeface_js = _typeface_js; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
811 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
812 if (/WebKit/i.test(navigator.userAgent)) { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
813 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
814 var _typefaceTimer = setInterval(function() { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
815 if (/loaded|complete/.test(document.readyState)) { |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
816 _typeface_js.initialize(); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
817 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
818 }, 10); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
819 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
820 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
821 if (document.addEventListener) { |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
822 window.addEventListener('DOMContentLoaded', function() { _typeface_js.initialize() }, false); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
823 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
824 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
825 /*@cc_on @*/ |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
826 /*@if (@_win32) |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
827 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
828 document.write("<script id=__ie_onload_typeface defer src=//:><\/script>"); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
829 var script = document.getElementById("__ie_onload_typeface"); |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
830 script.onreadystatechange = function() { |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
831 if (this.readyState == "complete") { |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
832 _typeface_js.initialize(); |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
833 } |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
834 }; |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
835 |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
836 /*@end @*/ |
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
837 |
277
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
838 try { console.log('initializing typeface.js') } catch(e) {}; |
84f2a6a16bd2
Update typeface.js from version 0.11 to 0.13
David Soria Parra <dsp@php.net>
parents:
248
diff
changeset
|
839 |
248
53a5e100b497
Convert the frontpage, except for the download button.
Steve Losh <steve@stevelosh.com>
parents:
diff
changeset
|
840 })(); |
279
b9105ed958a4
typeface: temporarly fix rendering on IE8 64bit
David Soria Parra <dsp@php.net>
parents:
277
diff
changeset
|
841 } |