annotate static/js/typeface-0.15.js @ 372:2c14d3e02019

Update
author David Soria Parra <dsp@php.net>
date Thu, 06 Oct 2011 21:45:47 +0200
parents bb27170e2218
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
367
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
1 /*****************************************************************
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
2
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
3 typeface.js, version 0.15 | typefacejs.neocracy.org
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
4
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
5 Copyright (c) 2008 - 2009, David Chester davidchester@gmx.net
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
6
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
7 Permission is hereby granted, free of charge, to any person
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
8 obtaining a copy of this software and associated documentation
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
9 files (the "Software"), to deal in the Software without
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
10 restriction, including without limitation the rights to use,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
11 copy, modify, merge, publish, distribute, sublicense, and/or sell
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
12 copies of the Software, and to permit persons to whom the
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
13 Software is furnished to do so, subject to the following
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
14 conditions:
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
15
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
16 The above copyright notice and this permission notice shall be
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
17 included in all copies or substantial portions of the Software.
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
18
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
21 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
23 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
24 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
25 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
26 OTHER DEALINGS IN THE SOFTWARE.
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
27
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
28 *****************************************************************/
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
29
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
30 (function() {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
31
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
32 var _typeface_js = {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
33
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
34 faces: {},
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
35
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
36 loadFace: function(typefaceData) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
37
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
38 var familyName = typefaceData.familyName.toLowerCase();
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
39
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
40 if (!this.faces[familyName]) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
41 this.faces[familyName] = {};
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
42 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
43 if (!this.faces[familyName][typefaceData.cssFontWeight]) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
44 this.faces[familyName][typefaceData.cssFontWeight] = {};
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
45 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
46
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
47 var face = this.faces[familyName][typefaceData.cssFontWeight][typefaceData.cssFontStyle] = typefaceData;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
48 face.loaded = true;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
49 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
50
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
51 log: function(message) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
52
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
53 if (this.quiet) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
54 return;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
55 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
56
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
57 message = "typeface.js: " + message;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
58
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
59 if (this.customLogFn) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
60 this.customLogFn(message);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
61
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
62 } else if (window.console && window.console.log) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
63 window.console.log(message);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
64 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
65
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
66 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
67
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
68 pixelsFromPoints: function(face, style, points, dimension) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
69 var pixels = points * parseInt(style.fontSize) * 72 / (face.resolution * 100);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
70 if (dimension == 'horizontal' && style.fontStretchPercent) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
71 pixels *= style.fontStretchPercent;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
72 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
73 return pixels;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
74 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
75
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
76 pointsFromPixels: function(face, style, pixels, dimension) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
77 var points = pixels * face.resolution / (parseInt(style.fontSize) * 72 / 100);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
78 if (dimension == 'horizontal' && style.fontStretchPrecent) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
79 points *= style.fontStretchPercent;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
80 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
81 return points;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
82 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
83
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
84 cssFontWeightMap: {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
85 normal: 'normal',
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
86 bold: 'bold',
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
87 400: 'normal',
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
88 700: 'bold'
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
89 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
90
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
91 cssFontStretchMap: {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
92 'ultra-condensed': 0.55,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
93 'extra-condensed': 0.77,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
94 'condensed': 0.85,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
95 'semi-condensed': 0.93,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
96 'normal': 1,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
97 'semi-expanded': 1.07,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
98 'expanded': 1.15,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
99 'extra-expanded': 1.23,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
100 'ultra-expanded': 1.45,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
101 'default': 1
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
102 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
103
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
104 fallbackCharacter: '.',
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
105
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
106 configure: function(args) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
107 var configurableOptionNames = [ 'customLogFn', 'customClassNameRegex', 'customTypefaceElementsList', 'quiet', 'verbose', 'disableSelection' ];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
108
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
109 for (var i = 0; i < configurableOptionNames.length; i++) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
110 var optionName = configurableOptionNames[i];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
111 if (args[optionName]) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
112 if (optionName == 'customLogFn') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
113 if (typeof args[optionName] != 'function') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
114 throw "customLogFn is not a function";
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
115 } else {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
116 this.customLogFn = args.customLogFn;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
117 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
118 } else {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
119 this[optionName] = args[optionName];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
120 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
121 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
122 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
123 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
124
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
125 getTextExtents: function(face, style, text) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
126 var extentX = 0;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
127 var extentY = 0;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
128 var horizontalAdvance;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
129
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
130 var textLength = text.length;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
131 for (var i = 0; i < textLength; i++) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
132 var glyph = face.glyphs[text.charAt(i)] ? face.glyphs[text.charAt(i)] : face.glyphs[this.fallbackCharacter];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
133 var letterSpacingAdjustment = this.pointsFromPixels(face, style, style.letterSpacing);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
134
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
135 // if we're on the last character, go with the glyph extent if that's more than the horizontal advance
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
136 extentX += i + 1 == textLength ? Math.max(glyph.x_max, glyph.ha) : glyph.ha;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
137 extentX += letterSpacingAdjustment;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
138
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
139 horizontalAdvance += glyph.ha + letterSpacingAdjustment;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
140 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
141 return {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
142 x: extentX,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
143 y: extentY,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
144 ha: horizontalAdvance
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
145
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
146 };
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
147 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
148
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
149 pixelsFromCssAmount: function(cssAmount, defaultValue, element) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
150
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
151 var matches = undefined;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
152
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
153 if (cssAmount == 'normal') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
154 return defaultValue;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
155
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
156 } else if (matches = cssAmount.match(/([\-\d+\.]+)px/)) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
157 return matches[1];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
158
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
159 } else {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
160 // thanks to Dean Edwards for this very sneaky way to get IE to convert
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
161 // relative values to pixel values
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
162
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
163 var pixelAmount;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
164
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
165 var leftInlineStyle = element.style.left;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
166 var leftRuntimeStyle = element.runtimeStyle.left;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
167
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
168 element.runtimeStyle.left = element.currentStyle.left;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
169
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
170 if (!cssAmount.match(/\d(px|pt)$/)) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
171 element.style.left = '1em';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
172 } else {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
173 element.style.left = cssAmount || 0;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
174 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
175
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
176 pixelAmount = element.style.pixelLeft;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
177
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
178 element.style.left = leftInlineStyle;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
179 element.runtimeStyle.left = leftRuntimeStyle;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
180
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
181 return pixelAmount || defaultValue;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
182 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
183 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
184
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
185 capitalizeText: function(text) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
186 return text.replace(/(^|\s)[a-z]/g, function(match) { return match.toUpperCase() } );
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
187 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
188
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
189 getElementStyle: function(e) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
190 if (window.getComputedStyle) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
191 return window.getComputedStyle(e, '');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
192
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
193 } else if (e.currentStyle) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
194 return e.currentStyle;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
195 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
196 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
197
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
198 getRenderedText: function(e) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
199
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
200 var browserStyle = this.getElementStyle(e.parentNode);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
201
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
202 var inlineStyleAttribute = e.parentNode.getAttribute('style');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
203 if (inlineStyleAttribute && typeof(inlineStyleAttribute) == 'object') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
204 inlineStyleAttribute = inlineStyleAttribute.cssText;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
205 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
206
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
207 if (inlineStyleAttribute) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
208
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
209 var inlineStyleDeclarations = inlineStyleAttribute.split(/\s*\;\s*/);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
210
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
211 var inlineStyle = {};
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
212 for (var i = 0; i < inlineStyleDeclarations.length; i++) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
213 var declaration = inlineStyleDeclarations[i];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
214 var declarationOperands = declaration.split(/\s*\:\s*/);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
215 inlineStyle[declarationOperands[0]] = declarationOperands[1];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
216 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
217 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
218
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
219 var style = {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
220 color: browserStyle.color,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
221 fontFamily: browserStyle.fontFamily.split(/\s*,\s*/)[0].replace(/(^"|^'|'$|"$)/g, '').toLowerCase(),
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
222 fontSize: this.pixelsFromCssAmount(browserStyle.fontSize, 12, e.parentNode),
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
223 fontWeight: this.cssFontWeightMap[browserStyle.fontWeight],
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
224 fontStyle: browserStyle.fontStyle ? browserStyle.fontStyle : 'normal',
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
225 fontStretchPercent: this.cssFontStretchMap[inlineStyle && inlineStyle['font-stretch'] ? inlineStyle['font-stretch'] : 'default'],
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
226 textDecoration: browserStyle.textDecoration,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
227 lineHeight: this.pixelsFromCssAmount(browserStyle.lineHeight, 'normal', e.parentNode),
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
228 letterSpacing: this.pixelsFromCssAmount(browserStyle.letterSpacing, 0, e.parentNode),
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
229 textTransform: browserStyle.textTransform
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
230 };
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
231
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
232 var face;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
233 if (
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
234 this.faces[style.fontFamily]
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
235 && this.faces[style.fontFamily][style.fontWeight]
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
236 ) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
237 face = this.faces[style.fontFamily][style.fontWeight][style.fontStyle];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
238 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
239
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
240 var text = e.nodeValue;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
241
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
242 if (
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
243 e.previousSibling
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
244 && e.previousSibling.nodeType == 1
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
245 && e.previousSibling.tagName != 'BR'
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
246 && this.getElementStyle(e.previousSibling).display.match(/inline/)
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
247 ) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
248 text = text.replace(/^\s+/, ' ');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
249 } else {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
250 text = text.replace(/^\s+/, '');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
251 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
252
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
253 if (
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
254 e.nextSibling
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
255 && e.nextSibling.nodeType == 1
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
256 && e.nextSibling.tagName != 'BR'
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
257 && this.getElementStyle(e.nextSibling).display.match(/inline/)
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
258 ) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
259 text = text.replace(/\s+$/, ' ');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
260 } else {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
261 text = text.replace(/\s+$/, '');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
262 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
263
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
264 text = text.replace(/\s+/g, ' ');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
265
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
266 if (style.textTransform && style.textTransform != 'none') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
267 switch (style.textTransform) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
268 case 'capitalize':
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
269 text = this.capitalizeText(text);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
270 break;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
271 case 'uppercase':
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
272 text = text.toUpperCase();
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
273 break;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
274 case 'lowercase':
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
275 text = text.toLowerCase();
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
276 break;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
277 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
278 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
279
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
280 if (!face) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
281 var excerptLength = 12;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
282 var textExcerpt = text.substring(0, excerptLength);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
283 if (text.length > excerptLength) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
284 textExcerpt += '...';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
285 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
286
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
287 var fontDescription = style.fontFamily;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
288 if (style.fontWeight != 'normal') fontDescription += ' ' + style.fontWeight;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
289 if (style.fontStyle != 'normal') fontDescription += ' ' + style.fontStyle;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
290
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
291 this.log("couldn't find typeface font: " + fontDescription + ' for text "' + textExcerpt + '"');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
292 return;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
293 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
294
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
295 var words = text.split(/\b(?=\w)/);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
296
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
297 var containerSpan = document.createElement('span');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
298 containerSpan.className = 'typeface-js-vector-container';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
299
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
300 var wordsLength = words.length;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
301 for (var i = 0; i < wordsLength; i++) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
302 var word = words[i];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
303
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
304 var vector = this.renderWord(face, style, word);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
305
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
306 if (vector) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
307 containerSpan.appendChild(vector.element);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
308
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
309 if (!this.disableSelection) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
310 var selectableSpan = document.createElement('span');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
311 selectableSpan.className = 'typeface-js-selected-text';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
312
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
313 var wordNode = document.createTextNode(word);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
314 selectableSpan.appendChild(wordNode);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
315
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
316 if (this.vectorBackend != 'vml') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
317 selectableSpan.style.marginLeft = -1 * (vector.width + 1) + 'px';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
318 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
319 selectableSpan.targetWidth = vector.width;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
320 //selectableSpan.style.lineHeight = 1 + 'px';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
321
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
322 if (this.vectorBackend == 'vml') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
323 vector.element.appendChild(selectableSpan);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
324 } else {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
325 containerSpan.appendChild(selectableSpan);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
326 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
327 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
328 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
329 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
330
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
331 return containerSpan;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
332 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
333
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
334 renderDocument: function(callback) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
335
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
336 if (!callback)
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
337 callback = function(e) { e.style.visibility = 'visible' };
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
338
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
339 var elements = document.getElementsByTagName('*');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
340
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
341 var elementsLength = elements.length;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
342 for (var i = 0; i < elements.length; i++) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
343 if (elements[i].className.match(/(^|\s)typeface-js(\s|$)/) || elements[i].tagName.match(/^(H1|H2|H3|H4|H5|H6)$/)) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
344 this.replaceText(elements[i]);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
345 if (typeof callback == 'function') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
346 callback(elements[i]);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
347 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
348 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
349 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
350
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
351 if (this.vectorBackend == 'vml') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
352 // lamely work around IE's quirky leaving off final dynamic shapes
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
353 var dummyShape = document.createElement('v:shape');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
354 dummyShape.style.display = 'none';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
355 document.body.appendChild(dummyShape);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
356 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
357 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
358
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
359 replaceText: function(e) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
360
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
361 var childNodes = [];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
362 var childNodesLength = e.childNodes.length;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
363
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
364 for (var i = 0; i < childNodesLength; i++) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
365 this.replaceText(e.childNodes[i]);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
366 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
367
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
368 if (e.nodeType == 3 && e.nodeValue.match(/\S/)) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
369 var parentNode = e.parentNode;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
370
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
371 if (parentNode.className == 'typeface-js-selected-text') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
372 return;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
373 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
374
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
375 var renderedText = this.getRenderedText(e);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
376
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
377 if (
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
378 parentNode.tagName == 'A'
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
379 && this.vectorBackend == 'vml'
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
380 && this.getElementStyle(parentNode).display == 'inline'
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
381 ) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
382 // something of a hack, use inline-block to get IE to accept clicks in whitespace regions
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
383 parentNode.style.display = 'inline-block';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
384 parentNode.style.cursor = 'pointer';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
385 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
386
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
387 if (this.getElementStyle(parentNode).display == 'inline') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
388 parentNode.style.display = 'inline-block';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
389 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
390
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
391 if (renderedText) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
392 if (parentNode.replaceChild) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
393 parentNode.replaceChild(renderedText, e);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
394 } else {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
395 parentNode.insertBefore(renderedText, e);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
396 parentNode.removeChild(e);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
397 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
398 if (this.vectorBackend == 'vml') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
399 renderedText.innerHTML = renderedText.innerHTML;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
400 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
401
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
402 var childNodesLength = renderedText.childNodes.length
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
403 for (var i; i < childNodesLength; i++) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
404
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
405 // do our best to line up selectable text with rendered text
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
406
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
407 var e = renderedText.childNodes[i];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
408 if (e.hasChildNodes() && !e.targetWidth) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
409 e = e.childNodes[0];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
410 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
411
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
412 if (e && e.targetWidth) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
413 var letterSpacingCount = e.innerHTML.length;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
414 var wordSpaceDelta = e.targetWidth - e.offsetWidth;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
415 var letterSpacing = wordSpaceDelta / (letterSpacingCount || 1);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
416
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
417 if (this.vectorBackend == 'vml') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
418 letterSpacing = Math.ceil(letterSpacing);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
419 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
420
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
421 e.style.letterSpacing = letterSpacing + 'px';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
422 e.style.width = e.targetWidth + 'px';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
423 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
424 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
425 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
426 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
427 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
428
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
429 applyElementVerticalMetrics: function(face, style, e) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
430
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
431 if (style.lineHeight == 'normal') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
432 style.lineHeight = this.pixelsFromPoints(face, style, face.lineHeight);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
433 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
434
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
435 var cssLineHeightAdjustment = style.lineHeight - this.pixelsFromPoints(face, style, face.lineHeight);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
436
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
437 e.style.marginTop = Math.round( cssLineHeightAdjustment / 2 ) + 'px';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
438 e.style.marginBottom = Math.round( cssLineHeightAdjustment / 2) + 'px';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
439
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
440 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
441
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
442 vectorBackends: {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
443
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
444 canvas: {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
445
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
446 _initializeSurface: function(face, style, text) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
447
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
448 var extents = this.getTextExtents(face, style, text);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
449
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
450 var canvas = document.createElement('canvas');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
451 if (this.disableSelection) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
452 canvas.innerHTML = text;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
453 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
454
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
455 canvas.height = Math.round(this.pixelsFromPoints(face, style, face.lineHeight));
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
456 canvas.width = Math.round(this.pixelsFromPoints(face, style, extents.x, 'horizontal'));
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
457
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
458 this.applyElementVerticalMetrics(face, style, canvas);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
459
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
460 if (extents.x > extents.ha)
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
461 canvas.style.marginRight = Math.round(this.pixelsFromPoints(face, style, extents.x - extents.ha, 'horizontal')) + 'px';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
462
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
463 var ctx = canvas.getContext('2d');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
464
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
465 var pointScale = this.pixelsFromPoints(face, style, 1);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
466 ctx.scale(pointScale * style.fontStretchPercent, -1 * pointScale);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
467 ctx.translate(0, -1 * face.ascender);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
468 ctx.fillStyle = style.color;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
469
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
470 return { context: ctx, canvas: canvas };
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
471 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
472
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
473 _renderGlyph: function(ctx, face, char, style) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
474
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
475 var glyph = face.glyphs[char];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
476
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
477 if (!glyph) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
478 //this.log.error("glyph not defined: " + char);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
479 return this.renderGlyph(ctx, face, this.fallbackCharacter, style);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
480 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
481
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
482 if (glyph.o) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
483
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
484 var outline;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
485 if (glyph.cached_outline) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
486 outline = glyph.cached_outline;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
487 } else {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
488 outline = glyph.o.split(' ');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
489 glyph.cached_outline = outline;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
490 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
491
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
492 var outlineLength = outline.length;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
493 for (var i = 0; i < outlineLength; ) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
494
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
495 var action = outline[i++];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
496
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
497 switch(action) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
498 case 'm':
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
499 ctx.moveTo(outline[i++], outline[i++]);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
500 break;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
501 case 'l':
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
502 ctx.lineTo(outline[i++], outline[i++]);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
503 break;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
504
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
505 case 'q':
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
506 var cpx = outline[i++];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
507 var cpy = outline[i++];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
508 ctx.quadraticCurveTo(outline[i++], outline[i++], cpx, cpy);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
509 break;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
510
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
511 case 'b':
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
512 var x = outline[i++];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
513 var y = outline[i++];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
514 ctx.bezierCurveTo(outline[i++], outline[i++], outline[i++], outline[i++], x, y);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
515 break;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
516 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
517 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
518 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
519 if (glyph.ha) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
520 var letterSpacingPoints =
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
521 style.letterSpacing && style.letterSpacing != 'normal' ?
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
522 this.pointsFromPixels(face, style, style.letterSpacing) :
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
523 0;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
524
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
525 ctx.translate(glyph.ha + letterSpacingPoints, 0);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
526 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
527 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
528
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
529 _renderWord: function(face, style, text) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
530 var surface = this.initializeSurface(face, style, text);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
531 var ctx = surface.context;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
532 var canvas = surface.canvas;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
533 ctx.beginPath();
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
534 ctx.save();
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
535
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
536 var chars = text.split('');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
537 var charsLength = chars.length;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
538 for (var i = 0; i < charsLength; i++) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
539 this.renderGlyph(ctx, face, chars[i], style);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
540 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
541
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
542 ctx.fill();
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
543
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
544 if (style.textDecoration == 'underline') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
545
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
546 ctx.beginPath();
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
547 ctx.moveTo(0, face.underlinePosition);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
548 ctx.restore();
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
549 ctx.lineTo(0, face.underlinePosition);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
550 ctx.strokeStyle = style.color;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
551 ctx.lineWidth = face.underlineThickness;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
552 ctx.stroke();
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
553 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
554
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
555 return { element: ctx.canvas, width: Math.floor(canvas.width) };
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
556
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
557 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
558 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
559
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
560 vml: {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
561
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
562 _initializeSurface: function(face, style, text) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
563
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
564 var shape = document.createElement('v:shape');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
565
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
566 var extents = this.getTextExtents(face, style, text);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
567
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
568 shape.style.width = shape.style.height = style.fontSize + 'px';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
569 shape.style.marginLeft = '-1px'; // this seems suspect...
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
570
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
571 if (extents.x > extents.ha) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
572 shape.style.marginRight = this.pixelsFromPoints(face, style, extents.x - extents.ha, 'horizontal') + 'px';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
573 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
574
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
575 this.applyElementVerticalMetrics(face, style, shape);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
576
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
577 var resolutionScale = face.resolution * 100 / 72;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
578 shape.coordsize = (resolutionScale / style.fontStretchPercent) + "," + resolutionScale;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
579
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
580 shape.coordorigin = '0,' + face.ascender;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
581 shape.style.flip = 'y';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
582
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
583 shape.fillColor = style.color;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
584 shape.stroked = false;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
585
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
586 shape.path = 'hh m 0,' + face.ascender + ' l 0,' + face.descender + ' ';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
587
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
588 return shape;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
589 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
590
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
591 _renderGlyph: function(shape, face, char, offsetX, style, vmlSegments) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
592
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
593 var glyph = face.glyphs[char];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
594
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
595 if (!glyph) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
596 this.log("glyph not defined: " + char);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
597 this.renderGlyph(shape, face, this.fallbackCharacter, offsetX, style);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
598 return;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
599 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
600
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
601 vmlSegments.push('m');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
602
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
603 if (glyph.o) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
604
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
605 var outline, outlineLength;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
606
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
607 if (glyph.cached_outline) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
608 outline = glyph.cached_outline;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
609 outlineLength = outline.length;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
610 } else {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
611 outline = glyph.o.split(' ');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
612 outlineLength = outline.length;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
613
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
614 for (var i = 0; i < outlineLength;) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
615
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
616 switch(outline[i++]) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
617 case 'q':
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
618 outline[i] = Math.round(outline[i++]);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
619 outline[i] = Math.round(outline[i++]);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
620 case 'm':
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
621 case 'l':
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
622 outline[i] = Math.round(outline[i++]);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
623 outline[i] = Math.round(outline[i++]);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
624 break;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
625 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
626 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
627
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
628 glyph.cached_outline = outline;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
629 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
630
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
631 var prevX, prevY;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
632
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
633 for (var i = 0; i < outlineLength;) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
634
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
635 var action = outline[i++];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
636
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
637 var x = Math.round(outline[i++]) + offsetX;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
638 var y = Math.round(outline[i++]);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
639
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
640 switch(action) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
641 case 'm':
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
642 vmlSegments.push('xm ', x, ',', y);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
643 break;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
644
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
645 case 'l':
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
646 vmlSegments.push('l ', x, ',', y);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
647 break;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
648
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
649 case 'q':
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
650 var cpx = outline[i++] + offsetX;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
651 var cpy = outline[i++];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
652
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
653 var cp1x = Math.round(prevX + 2.0 / 3.0 * (cpx - prevX));
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
654 var cp1y = Math.round(prevY + 2.0 / 3.0 * (cpy - prevY));
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
655
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
656 var cp2x = Math.round(cp1x + (x - prevX) / 3.0);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
657 var cp2y = Math.round(cp1y + (y - prevY) / 3.0);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
658
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
659 vmlSegments.push('c ', cp1x, ',', cp1y, ',', cp2x, ',', cp2y, ',', x, ',', y);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
660 break;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
661
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
662 case 'b':
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
663 var cp1x = Math.round(outline[i++]) + offsetX;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
664 var cp1y = outline[i++];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
665
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
666 var cp2x = Math.round(outline[i++]) + offsetX;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
667 var cp2y = outline[i++];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
668
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
669 vmlSegments.push('c ', cp1x, ',', cp1y, ',', cp2x, ',', cp2y, ',', x, ',', y);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
670 break;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
671 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
672
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
673 prevX = x;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
674 prevY = y;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
675 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
676 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
677
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
678 vmlSegments.push('x e');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
679 return vmlSegments;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
680 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
681
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
682 _renderWord: function(face, style, text) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
683 var offsetX = 0;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
684 var shape = this.initializeSurface(face, style, text);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
685
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
686 var letterSpacingPoints =
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
687 style.letterSpacing && style.letterSpacing != 'normal' ?
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
688 this.pointsFromPixels(face, style, style.letterSpacing) :
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
689 0;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
690
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
691 letterSpacingPoints = Math.round(letterSpacingPoints);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
692 var chars = text.split('');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
693 var vmlSegments = [];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
694 for (var i = 0; i < chars.length; i++) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
695 var char = chars[i];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
696 vmlSegments = this.renderGlyph(shape, face, char, offsetX, style, vmlSegments);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
697 offsetX += face.glyphs[char].ha + letterSpacingPoints ;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
698 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
699
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
700 if (style.textDecoration == 'underline') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
701 var posY = face.underlinePosition - (face.underlineThickness / 2);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
702 vmlSegments.push('xm ', 0, ',', posY);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
703 vmlSegments.push('l ', offsetX, ',', posY);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
704 vmlSegments.push('l ', offsetX, ',', posY + face.underlineThickness);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
705 vmlSegments.push('l ', 0, ',', posY + face.underlineThickness);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
706 vmlSegments.push('l ', 0, ',', posY);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
707 vmlSegments.push('x e');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
708 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
709
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
710 // make sure to preserve trailing whitespace
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
711 shape.path += vmlSegments.join('') + 'm ' + offsetX + ' 0 l ' + offsetX + ' ' + face.ascender;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
712
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
713 return {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
714 element: shape,
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
715 width: Math.floor(this.pixelsFromPoints(face, style, offsetX, 'horizontal'))
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
716 };
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
717 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
718
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
719 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
720
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
721 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
722
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
723 setVectorBackend: function(backend) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
724
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
725 this.vectorBackend = backend;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
726 var backendFunctions = ['renderWord', 'initializeSurface', 'renderGlyph'];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
727
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
728 for (var i = 0; i < backendFunctions.length; i++) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
729 var backendFunction = backendFunctions[i];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
730 this[backendFunction] = this.vectorBackends[backend]['_' + backendFunction];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
731 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
732 },
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
733
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
734 initialize: function() {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
735
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
736 // quit if this function has already been called
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
737 if (arguments.callee.done) return;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
738
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
739 // flag this function so we don't do the same thing twice
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
740 arguments.callee.done = true;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
741
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
742 // kill the timer
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
743 if (window._typefaceTimer) clearInterval(_typefaceTimer);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
744
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
745 this.renderDocument( function(e) { e.style.visibility = 'visible' } );
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
746
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
747 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
748
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
749 };
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
750
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
751 // IE won't accept real selectors...
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
752 var typefaceSelectors = ['.typeface-js', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
753
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
754 if (document.createStyleSheet) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
755
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
756 var styleSheet = document.createStyleSheet();
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
757 for (var i = 0; i < typefaceSelectors.length; i++) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
758 var selector = typefaceSelectors[i];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
759 styleSheet.addRule(selector, 'visibility: hidden');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
760 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
761
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
762 styleSheet.addRule(
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
763 '.typeface-js-selected-text',
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
764 '-ms-filter: \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
765 "Chroma(color=black) \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
766 progid:DXImageTransform.Microsoft.MaskFilter(Color=white) \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
767 progid:DXImageTransform.Microsoft.MaskFilter(Color=blue) \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
768 alpha(opacity=30)" !important; \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
769 color: black; \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
770 font-family: Modern; \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
771 position: absolute; \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
772 white-space: pre; \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
773 filter: alpha(opacity=0) !important;'
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
774 );
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
775
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
776 styleSheet.addRule(
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
777 '.typeface-js-vector-container',
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
778 'position: relative'
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
779 );
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
780
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
781 } else if (document.styleSheets) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
782
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
783 if (!document.styleSheets.length) { (function() {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
784 // create a stylesheet if we need to
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
785 var styleSheet = document.createElement('style');
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
786 styleSheet.type = 'text/css';
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
787 document.getElementsByTagName('head')[0].appendChild(styleSheet);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
788 })() }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
789
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
790 var styleSheet = document.styleSheets[0];
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
791 document.styleSheets[0].insertRule(typefaceSelectors.join(',') + ' { visibility: hidden; }', styleSheet.cssRules.length);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
792
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
793 document.styleSheets[0].insertRule(
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
794 '.typeface-js-selected-text { \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
795 color: rgba(128, 128, 128, 0); \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
796 opacity: 0.30; \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
797 position: absolute; \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
798 font-family: Arial, sans-serif; \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
799 white-space: pre \
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
800 }',
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
801 styleSheet.cssRules.length
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
802 );
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
803
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
804 try {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
805 // set selection style for Mozilla / Firefox
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
806 document.styleSheets[0].insertRule(
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
807 '.typeface-js-selected-text::-moz-selection { background: blue; }',
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
808 styleSheet.cssRules.length
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
809 );
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
810
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
811 } catch(e) {};
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
812
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
813 try {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
814 // set styles for browsers with CSS3 selectors (Safari, Chrome)
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
815 document.styleSheets[0].insertRule(
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
816 '.typeface-js-selected-text::selection { background: blue; }',
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
817 styleSheet.cssRules.length
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
818 );
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
819
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
820 } catch(e) {};
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
821
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
822 // most unfortunately, sniff for WebKit's quirky selection behavior
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
823 if (/WebKit/i.test(navigator.userAgent)) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
824 document.styleSheets[0].insertRule(
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
825 '.typeface-js-vector-container { position: relative }',
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
826 styleSheet.cssRules.length
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
827 );
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
828 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
829
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
830 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
831
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
832 var backend = window.CanvasRenderingContext2D || document.createElement('canvas').getContext ? 'canvas' : !!(window.attachEvent && !window.opera) ? 'vml' : null;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
833
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
834 if (backend == 'vml') {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
835
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
836 document.namespaces.add("v","urn:schemas-microsoft-com:vml","#default#VML");
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
837
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
838 var styleSheet = document.createStyleSheet();
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
839 styleSheet.addRule('v\\:shape', "display: inline-block;");
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
840 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
841
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
842 _typeface_js.setVectorBackend(backend);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
843 window._typeface_js = _typeface_js;
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
844
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
845 if (/WebKit/i.test(navigator.userAgent)) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
846
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
847 var _typefaceTimer = setInterval(function() {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
848 if (/loaded|complete/.test(document.readyState)) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
849 _typeface_js.initialize();
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
850 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
851 }, 10);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
852 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
853
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
854 if (document.addEventListener) {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
855 window.addEventListener('DOMContentLoaded', function() { _typeface_js.initialize() }, false);
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
856 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
857
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
858 /*@cc_on @*/
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
859 /*@if (@_win32)
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
860
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
861 document.write("<script id=__ie_onload_typeface defer src=//:><\/script>");
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
862 var script = document.getElementById("__ie_onload_typeface");
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
863 script.onreadystatechange = function() {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
864 if (this.readyState == "complete") {
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
865 _typeface_js.initialize();
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
866 }
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
867 };
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
868
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
869 /*@end @*/
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
870
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
871 try { console.log('initializing typeface.js') } catch(e) {};
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
872
bb27170e2218 Updated from typeface.js 0.13 to 0.15 for IE9 compat.
Tatham Oddie <tatham@oddie.com.au>
parents:
diff changeset
873 })();