| 1 | <html> |
| 2 | <title>Test of TADS.swf</title> |
| 3 | |
| 4 | <body onload="javascript:init();"> |
| 5 | |
| 6 | <div style="position: absolute; left: -10000px; top: -10000px;"> |
| 7 | <object id="__TADS_swf" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" |
| 8 | codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" |
| 9 | width="0" height="0" align="middle"> |
| 10 | <param name="movie" value="TADS.swf"/> |
| 11 | <param name="quality" value="high"/> |
| 12 | <param name="bgcolor" value="#ffffff"/> |
| 13 | <param name="allowScriptAccess" value="always"/> |
| 14 | <param name="FlashVars" value="onload=TADS_swf.onDone"/> |
| 15 | <embed name="__TADS_swf" src="TADS.swf" |
| 16 | width="0" height="0" |
| 17 | quality="high" bgcolor="#ffffff" allowScriptAccess="always" |
| 18 | align="middle" type="application/x-shockwave-flash" |
| 19 | pluginspage="http://www.macromedia.com/go/getflashplayer" |
| 20 | FlashVars="onload=TADS_swf.onDone"/> |
| 21 | </object> |
| 22 | <span id="__font_test"> |
| 23 | ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$$%^*()-+=.,?/'":; |
| 24 | </span> |
| 25 | <span id="__font_ref" style="font-family: Comic Sans MS, Times New Roman;"> |
| 26 | ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$$%^*()-+=.,?/'":; |
| 27 | </span> |
| 28 | </div> |
| 29 | |
| 30 | <div id="fontlist"> |
| 31 | <b>Fonts installed:</b><br> |
| 32 | </div> |
| 33 | |
| 34 | <script type="text/javascript"> |
| 35 | |
| 36 | var TADS_swf = new AbsEvent(); |
| 37 | |
| 38 | function init() |
| 39 | { |
| 40 | TADS_swf.whenDone(buildFontList); |
| 41 | } |
| 42 | |
| 43 | function buildFontList() |
| 44 | { |
| 45 | // In case Flash isn't available, set up a list of common fonts to |
| 46 | // test. We'll check each entry to see if it's actually installed, |
| 47 | // so the final list won't include any missing fonts. We can't |
| 48 | // guess at all of the fonts a given system might have installed, |
| 49 | // but the idea is to list lots of fonts in the hope of finding a |
| 50 | // reasonably large subset of installed fonts on typical systems. |
| 51 | var defaultFonts = [ |
| 52 | "Absalom", |
| 53 | "Academy Engraved LET", |
| 54 | "Alibi", |
| 55 | "Allegro BT", |
| 56 | "Alleycat ICG", |
| 57 | "Almanac MT", |
| 58 | "American Uncial", |
| 59 | "Americana", |
| 60 | "Amiga Forever", |
| 61 | "Anivers", |
| 62 | "Anna", |
| 63 | "Arial", |
| 64 | "Arial Black", |
| 65 | "Arial Narrow", |
| 66 | "Arial Unicode MS", |
| 67 | "Augsburger Initials", |
| 68 | "AvantGarde", |
| 69 | "BankGothic Md BT", |
| 70 | "Batang", |
| 71 | "BatangChe", |
| 72 | "Batavia", |
| 73 | "Bauhaus 93", |
| 74 | "Bernhard Modern Roman", |
| 75 | "BernhardFashion BT", |
| 76 | "BernhardMod BT", |
| 77 | "Bitstream Vera Sans Mono", |
| 78 | "Blackletter686 BT", |
| 79 | "Blackoak", |
| 80 | "Boca Raton ICG", |
| 81 | "Boca Raton ICG Solid", |
| 82 | "Book Antiqua", |
| 83 | "Bookman", |
| 84 | "Bookman Old Style", |
| 85 | "Boulevard", |
| 86 | "Bradley Hand ITC", |
| 87 | "Bremen Bd BT", |
| 88 | "Broadway BT", |
| 89 | "BrushScript", |
| 90 | "Calibri", |
| 91 | "Californian FB", |
| 92 | "Calisto MT", |
| 93 | "Calligraph421 BT", |
| 94 | "Cambria", |
| 95 | "Cambria Math", |
| 96 | "Candara", |
| 97 | "Carta", |
| 98 | "Casmira", |
| 99 | "Castellar", |
| 100 | "Cataneo BT", |
| 101 | "Century", |
| 102 | "Century Gothic", |
| 103 | "Chilada ICG Cuatro", |
| 104 | "Chilada ICG Dos", |
| 105 | "Chilada ICG Tres", |
| 106 | "Chilada ICG Uno", |
| 107 | "Comic Sans MS", |
| 108 | "CommonBullets", |
| 109 | "Consolas", |
| 110 | "Constantia", |
| 111 | "Copperplate Gothic", |
| 112 | "Copperplate Gothic Bold", |
| 113 | "Copperplate Gothic Light", |
| 114 | "Copperplate31ab", |
| 115 | "Copperplate33bc", |
| 116 | "CopprplGoth Bd BT", |
| 117 | "Corbel", |
| 118 | "Courier New", |
| 119 | "Debussy", |
| 120 | "Decotura ICG", |
| 121 | "Decotura ICG Inline", |
| 122 | "Desdemona", |
| 123 | "Dotum", |
| 124 | "DotumChe", |
| 125 | "Edda", |
| 126 | "Elegance", |
| 127 | "Ellis", |
| 128 | "English111 Vivace BT", |
| 129 | "Enviro", |
| 130 | "Estrangelo Edessa", |
| 131 | "Eurostile", |
| 132 | "Excess", |
| 133 | "Fajita ICG Mild", |
| 134 | "Felix Titling", |
| 135 | "Fine Hand", |
| 136 | "Franklin Gothic", |
| 137 | "Franklin Gothic Demi", |
| 138 | "Franklin Gothic Demi Cond", |
| 139 | "Franklin Gothic Heavy", |
| 140 | "Franklin Gothic Medium", |
| 141 | "Franklin Gothic Medium Cond", |
| 142 | "Freshbot", |
| 143 | "Futura Lt BT", |
| 144 | "Futura Md BT", |
| 145 | "Futura XBlk BT", |
| 146 | "FuturaBlack BT", |
| 147 | "Garamond", |
| 148 | "Gautami", |
| 149 | "Genuine", |
| 150 | "Georgia", |
| 151 | "Giddyup", |
| 152 | "Giddyup Thangs", |
| 153 | "Gill Sans MT", |
| 154 | "Gill Sans MT Condensed", |
| 155 | "Gill Sans MT Ext Condensed Bold", |
| 156 | "GillSans", |
| 157 | "GoudyHandtooled BT", |
| 158 | "GoudyOlSt BT", |
| 159 | "Gradl", |
| 160 | "Greek Symbols", |
| 161 | "Gulim", |
| 162 | "GulimChe", |
| 163 | "Gungsuh", |
| 164 | "GungsuhChe", |
| 165 | "Harrington", |
| 166 | "Helterskelter", |
| 167 | "Helvetica", |
| 168 | "Helvetica-Narrow", |
| 169 | "Herman", |
| 170 | "Highlight LET", |
| 171 | "HolidayPi BT", |
| 172 | "Humanst521 BT", |
| 173 | "Iconic Symbols Ext", |
| 174 | "Impact", |
| 175 | "Imprint MT Shadow", |
| 176 | "Isabelle", |
| 177 | "Joan", |
| 178 | "John Handy LET", |
| 179 | "Jokerman LET", |
| 180 | "Justice", |
| 181 | "Kartika", |
| 182 | "Kaufmann", |
| 183 | "La Bamba LET", |
| 184 | "Latha", |
| 185 | "LetterGothic", |
| 186 | "Lucida Console", |
| 187 | "Lucida Sans Unicode", |
| 188 | "Mandela", |
| 189 | "Mangal", |
| 190 | "Marlett", |
| 191 | "Matteroffact", |
| 192 | "Mediascape OSD Icon", |
| 193 | "Mekanik LET", |
| 194 | "Microdot", |
| 195 | "Microsoft Sans Serif", |
| 196 | "Milano LET", |
| 197 | "MingLiU", |
| 198 | "MisterEarl BT", |
| 199 | "Monotype Corsiva", |
| 200 | "MV Boli", |
| 201 | "Naturalborn", |
| 202 | "Neolith", |
| 203 | "NewCenturySchlbk", |
| 204 | "NewsGothic", |
| 205 | "Nina", |
| 206 | "NSimSun", |
| 207 | "OCR B MT", |
| 208 | "OCR-A II", |
| 209 | "Odessa LET", |
| 210 | "OldDreadfulNo7 BT", |
| 211 | "One Stroke Script LET", |
| 212 | "Openclassic", |
| 213 | "Orange LET", |
| 214 | "OzHandicraft BT", |
| 215 | "Paisley ICG 01", |
| 216 | "Paisley ICG 01 Alt", |
| 217 | "Paisley ICG 02", |
| 218 | "Paisley ICG 02 Alt", |
| 219 | "Palatino", |
| 220 | "Palatino Linotype", |
| 221 | "Parisian", |
| 222 | "ParkAvenue", |
| 223 | "ParkAvenue BT", |
| 224 | "Perpetua", |
| 225 | "PMingLiU", |
| 226 | "PosterBodoni BT", |
| 227 | "Pretext", |
| 228 | "Pump Demi Bold LET", |
| 229 | "Puppylike", |
| 230 | "Quixley LET", |
| 231 | "Raavi", |
| 232 | "Radagund", |
| 233 | "Rage Italic LET", |
| 234 | "Realvirtue", |
| 235 | "Ruach LET", |
| 236 | "Scruff LET", |
| 237 | "Segoe Condensed", |
| 238 | "Segoe UI", |
| 239 | "Serifa BT", |
| 240 | "Serifa Th BT", |
| 241 | "Shelman", |
| 242 | "Shruti", |
| 243 | "SimHei", |
| 244 | "SimSun", |
| 245 | "SimSun-PUA", |
| 246 | "Smudger LET", |
| 247 | "Staccato222 BT", |
| 248 | "Sylfaen", |
| 249 | "Tahoma", |
| 250 | "Tekton", |
| 251 | "Times", |
| 252 | "Times New Roman", |
| 253 | "Tiranti Solid LET", |
| 254 | "Trajan", |
| 255 | "Trebuchet MS", |
| 256 | "Trendy", |
| 257 | "Tunga", |
| 258 | "TypoUpright BT", |
| 259 | "University Roman LET", |
| 260 | "Venetian301 BT", |
| 261 | "Verdana", |
| 262 | "Victorian LET", |
| 263 | "Village", |
| 264 | "Vrinda", |
| 265 | "Westwood LET", |
| 266 | "Whimsy ICG", |
| 267 | "Whimsy ICG Heavy", |
| 268 | "Wonton ICG", |
| 269 | "ZapfChancery", |
| 270 | "ZapfEllipt BT", |
| 271 | "Zurich Ex BT" |
| 272 | ]; |
| 273 | |
| 274 | // Build the candidate font list. First try the TADS.swf embedded |
| 275 | // Flash object. Flash isn't everywhere, so if we don't find it, |
| 276 | // fall back on our canned list of candidate fonts. |
| 277 | var fonts; |
| 278 | try { |
| 279 | // get the flash object |
| 280 | var ie = navigator.userAgent.indexOf("Microsoft") != -1; |
| 281 | var mobj = (ie ? window["__TADS_swf"] : document["__TADS_swf"]); |
| 282 | |
| 283 | // ask the Flash object for the list of installed fonts |
| 284 | var sfonts = mobj.getFonts(); |
| 285 | |
| 286 | // Build a list of the font names, filtering for "regular" style |
| 287 | // fonts. We ignore other styles (bold, italic, etc), since we |
| 288 | // don't want to show these in the UI. |
| 289 | fonts = []; |
| 290 | for (var i = 0 ; i < sfonts.length ; ++i) |
| 291 | { |
| 292 | if (sfonts[i].fontStyle == "regular") |
| 293 | fonts.push(sfonts[i].fontName); |
| 294 | } |
| 295 | } |
| 296 | catch (e) { |
| 297 | // Couldn't get the fonts from flash, so use our canned list |
| 298 | // of candidates. We'll filter out any fonts that aren't |
| 299 | // actually installed below. |
| 300 | fonts = defaultFonts; |
| 301 | } |
| 302 | |
| 303 | // Filter the fonts by testing to see if they're actually installed. |
| 304 | // The Flash font enumerator reportedly returns garbage font names on |
| 305 | // some systems. Test each font name by styling a test span with it. |
| 306 | // Compare the pixel width of the test span with that of a reference |
| 307 | // span that's styled in a fallback font. If the test and reference |
| 308 | // spans have the same widths, it's a good bet that the test span is |
| 309 | // actually being rendered in the fallback font, which will presumably |
| 310 | // only happen when the tested font doesn't exist on the system. |
| 311 | var goodFonts = []; |
| 312 | var testSpan = document.getElementById("__font_test"); |
| 313 | var refSpan = document.getElementById("__font_ref"); |
| 314 | for (var i = 0 ; i < fonts.length ; ++i) |
| 315 | { |
| 316 | var n = fonts[i]; |
| 317 | testSpan.style.fontFamily = n + ", Comic Sans MS, Times New Roman"; |
| 318 | if (n == "Comic Sans MS" |
| 319 | || n == "Times New Roman" |
| 320 | || testSpan.offsetWidth != refSpan.offsetWidth) |
| 321 | goodFonts.push(n); |
| 322 | } |
| 323 | |
| 324 | // keep the filtered list |
| 325 | fonts = goodFonts; |
| 326 | |
| 327 | // sort the final list by name |
| 328 | fonts.sort(function(a, b) { |
| 329 | return a.toUpperCase().localeCompare(b.toUpperCase()); |
| 330 | }); |
| 331 | |
| 332 | document.getElementById("fontlist").innerHTML += fonts.join("<br>"); |
| 333 | } |
| 334 | |
| 335 | |
| 336 | /* ------------------------------------------------------------------------ */ |
| 337 | /* |
| 338 | * Shorthand to retrieve an object by name. |
| 339 | * |
| 340 | * If 'obj' is a string, we treat it as a path of elements separated by |
| 341 | * periods. Each element can be an object ID, or a class name in [square |
| 342 | * brackets]. For example, "form3.[details]" returns the first child with |
| 343 | * class="details" of the element with ID "form3". |
| 344 | * |
| 345 | * If 'obj' is any other type, we return it as-is. This allows passing in |
| 346 | * an element reference without first checking its type, since it will |
| 347 | * simply be returned unchanged. This makes it easy to write routines that |
| 348 | * accept path names or references as arguments: if the argument is a path |
| 349 | * name, it will be translated to an element; if it's already an element, |
| 350 | * it will be returned as given. |
| 351 | */ |
| 352 | function $(obj) |
| 353 | { |
| 354 | // if it's a string, look it up by name |
| 355 | if (typeof(obj) == "string") |
| 356 | { |
| 357 | // break it up into dot-delimited path elements |
| 358 | var path = obj.split("."); |
| 359 | |
| 360 | // find each item in the path |
| 361 | for (var i = 0 ; i < path.length ; ++i) |
| 362 | { |
| 363 | // check the syntax for this element |
| 364 | var e = path[i]; |
| 365 | var cond; |
| 366 | if (e.match(/^\[.*\]$/)) |
| 367 | { |
| 368 | // search by class name, starting with the body element |
| 369 | e = e.substr(1, e.length - 2); |
| 370 | obj = breadthSearch( |
| 371 | i == 0 ? document.body : obj, |
| 372 | function(x) { return x.className == e; }); |
| 373 | } |
| 374 | else |
| 375 | { |
| 376 | // search by ID |
| 377 | cond = function(x) { return x.id == e; } |
| 378 | if (i == 0) |
| 379 | obj = document.getElementById(e); |
| 380 | else |
| 381 | obj = breadthSearch( |
| 382 | obj, function(x) { return x.id == e; }); |
| 383 | } |
| 384 | |
| 385 | // if we didn't find a match at this point, give up |
| 386 | if (!obj) |
| 387 | return null; |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | // return what we ended with |
| 392 | return obj; |
| 393 | } |
| 394 | |
| 395 | /* |
| 396 | * Do a breadth-first search for a child matching the given condition |
| 397 | */ |
| 398 | function breadthSearch(obj, cond) |
| 399 | { |
| 400 | // first, search all direct children of 'obj' |
| 401 | var chi; |
| 402 | for (chi = obj.firstChild ; chi ; chi = chi.nextSibling) |
| 403 | { |
| 404 | if (cond(chi)) |
| 405 | return chi; |
| 406 | } |
| 407 | |
| 408 | // didn't find it among direct children, so search grandchildren |
| 409 | for (chi = obj.firstChild ; chi ; chi = chi.nextSibling) |
| 410 | { |
| 411 | var gc = breadthSearch(chi, cond); |
| 412 | if (gc) |
| 413 | return gc; |
| 414 | } |
| 415 | |
| 416 | // didn't find it |
| 417 | return null; |
| 418 | } |
| 419 | |
| 420 | |
| 421 | /* ------------------------------------------------------------------------ */ |
| 422 | /* |
| 423 | * Event manipulation. IE has slightly different syntax from all of the |
| 424 | * other browsers (but basically the same semantics, so it's fairly easy to |
| 425 | * create a common handler ourselves). |
| 426 | */ |
| 427 | function addEventHandler(obj, eventName, func) |
| 428 | { |
| 429 | obj = $(obj); |
| 430 | if (obj.addEventListener) |
| 431 | obj.addEventListener(eventName, func, false); |
| 432 | else if (obj.attachEvent) |
| 433 | obj.attachEvent("on" + eventName, func); |
| 434 | } |
| 435 | |
| 436 | function removeEventHandler(obj, eventName, func) |
| 437 | { |
| 438 | obj = $(obj); |
| 439 | if (obj.removeEventListener) |
| 440 | obj.removeEventListener(eventName, func, false); |
| 441 | else if (obj.detachEvent) |
| 442 | obj.detachEvent("on" + eventName, func); |
| 443 | } |
| 444 | |
| 445 | |
| 446 | /* ------------------------------------------------------------------------ */ |
| 447 | /* |
| 448 | * Abstract event handler object. This simplifies handling for code that's |
| 449 | * conditional on some external event or process completing. Use |
| 450 | * whenDone() method to invoke a callback if and when the event has |
| 451 | * occurred: if the event has already occurred, we'll invoke the callback |
| 452 | * immediately, otherwise we'll queue it up to be invoked when the event |
| 453 | * occurs. |
| 454 | */ |
| 455 | function AbsEvent(ele, eventName) |
| 456 | { |
| 457 | // we're not done yet, and we have no callbacks queued yet |
| 458 | this.isDone = false; |
| 459 | this.cb = []; |
| 460 | |
| 461 | // set up our event listener, if applicable |
| 462 | if (ele && eventName) |
| 463 | { |
| 464 | var ae = this; |
| 465 | addEventHandler(ele, eventName, function() { ae.onDone(); }); |
| 466 | } |
| 467 | |
| 468 | // return the new object |
| 469 | return this; |
| 470 | } |
| 471 | |
| 472 | /* |
| 473 | * Invoke a callback if and when the event has occurred. If the event has |
| 474 | * already occurred, we'll invoke the callback immediately; otherwise we'll |
| 475 | * enqueue it to be invoked when the event fires. |
| 476 | */ |
| 477 | AbsEvent.prototype.whenDone = function(cb) |
| 478 | { |
| 479 | // check to see if the event has already fired |
| 480 | if (this.isDone) |
| 481 | { |
| 482 | // the event has fired already - invoke the callback immediately |
| 483 | cb(); |
| 484 | } |
| 485 | else |
| 486 | { |
| 487 | // the event hasn't fired yet - queue the callback for later |
| 488 | this.cb.push(cb); |
| 489 | } |
| 490 | }; |
| 491 | |
| 492 | /* |
| 493 | * Completion event. The caller must invoke this when our external event |
| 494 | * occurs. |
| 495 | */ |
| 496 | AbsEvent.prototype.onDone = function() |
| 497 | { |
| 498 | // note that the event has fired |
| 499 | this.isDone = true; |
| 500 | |
| 501 | // invoke each queued callback |
| 502 | for (var i = 0 ; i < this.cb.length ; ++i) |
| 503 | this.cb[i](); |
| 504 | |
| 505 | // clear the callback list |
| 506 | this.cb = []; |
| 507 | }; |
| 508 | |
| 509 | |
| 510 | </script> |
| 511 | |
| 512 | </body> |
| 513 | </html> |