Ticket #14560: tor_font_probing.html

File tor_font_probing.html, 9.5 KB (added by Peter_Baumann_TUD, 4 years ago)

Font probing script

Line 
1<html>
2<body>
3<div id="base"><canvas id="fallback" style="display:none;"></canvas></div>
4
5<script type="text/javascript">
6  var size = "2000"; //large size for accuracy of measurement
7  var text = "a"; //One character is enough
8  var fonts = "Helvetica;Lucida Grande;Lucida Sans;Tahoma;Arial;Verdana;Geneva;Monaco;Microsoft Sans Serif;Times New Roman;Trebuchet MS;Courier New;Courier;Lucida Bright;Lucida Sans;Lucida Sans Typewriter;Comic Sans MS;Georgia;Lucida Sans Unicode;Palatino Linotype;Times;Lucida Console;Franklin Gothic Medium;Helvetica Neue;Verdana;Impact;URW Chancery L;Arial;Century Schoolbook L;URW Gothic L;Georgia;Nimbus Sans L;URW Bookman L;URW Palladio L;Times New Roman;Nimbus Mono L;Nimbus Roman No9 L;Sylfaen;MV Boli;Trebuchet MS;DejaVu Sans;DejaVu Sans Mono;DejaVu Serif;Tunga;Estrangelo Edessa;Gautami;Arial Black;Mangal;Raavi;Latha;Shruti;Gill Sans;Arial Narrow;Impact;Arial Black;Courier New;Arial Rounded MT Bold;Andale Mono;Futura;DejaVu Sans Light;Marker Felt;Tahoma;Baskerville;Skia;Comic Sans MS;American Typewriter;Apple Chancery;Optima;Didot;Hoefler Text;Zapfino;Papyrus;Big Caslon;DejaVu Sans Condensed;DejaVu Serif Condensed;Copperplate;Kartika;Vrinda;Brush Script MT;Herculanum;Hiragino Kaku Gothic ProN;Hiragino Mincho ProN;Bitstream Charter;Liberation Serif;Liberation Mono;Calibri;Cambria;Liberation Sans;Candara;Cambria Math;Corbel;Consolas;Constantia;Hiragino Maru Gothic ProN;Hiragino Kaku Gothic StdN;Arial Narrow;Palatino;Century Gothic;FreeSans;Garamond;Book Antiqua;Bookman Old Style;FreeMono;FreeSerif;Courier 10 Pitch;Segoe UI;Kokonor;Kailasa;Monotype Corsiva;MS Mincho;Lucida Bright;MS Reference Sans Serif;Lucida Sans Typewriter;Hiragino Sans GB;PCMyungjo;PilGi;Heiti SC;Heiti TC;HeadLineA;Menlo;Meiryo UI;Arial Unicode MS;Tempus Sans ITC;Kristen ITC;Chalkduster;Mistral;Juice ITC;Malgun Gothic;Microsoft Himalaya;Microsoft JhengHei;Microsoft YaHei;MingLiU-ExtB;MingLiU_HKSCS;MingLiU_HKSCS-ExtB;PMingLiU-ExtB;SimSun-ExtB;GungSeo;Freestyle Script;Papyrus;Microsoft Uighur;MoolBoran;Gisha;Leelawadee;DFKai-SB;Jokerman;French Script MT;Bradley Hand ITC;KaiTi;FangSong;Verdana;Vivaldi;UnDotum;Georgia;Arial;Times New Roman;Courier New;Impact;Trebuchet MS;Batang;Lohit Bengali;Lohit Tamil;Comic Sans MS;Lucida Handwriting;Lohit Gujarati;Waree;Haettenschweiler;Arial Black;SimSun;Lohit Punjabi;Pristina;Franklin Gothic Book;Copperplate Gothic Light;Copperplate Gothic Bold;Maiandra GD;Eras Demi ITC;Franklin Gothic Demi;OCR A Extended;Perpetua;Eras Light ITC;Felix Titling;Rockwell;Edwardian Script ITC;Franklin Gothic Medium Cond;MS PGothic;Rockwell Extra Bold;Engravers MT;MS Gothic;MS Mincho;Andale Mono;Franklin Gothic Heavy;Curlz MT;Franklin Gothic Demi Cond;Blackadder ITC;MS PMincho;Segoe Script;Casual;Segoe UI Light;PMingLiU;Segoe Print;MS Gothic;Segoe UI Semibold;Lucida Calligraphy;Harrington;Iskoola Pota;MS UI Gothic;Viner Hand ITC;Cooper Black;Onyx;Mongolian Baiti;GulimChe;Old English Text MT;Kalinga;Baskerville Old Face;Bauhaus 93;Britannic Bold;MS PGothic;Wide Latin;Euphemia;Gulim;Microsoft Yi Baiti;Nyala;Playbill;Algerian;BatangChe;Gungsuh;GungsuhChe;Snap ITC;DaunPenh;Broadway;Dotum;DotumChe;Footlight MT Light;Matura MT Script Capitals;UnBatang;DokChampa;Kunstler Script;MS PMincho;MingLiU;Vladimir Script;Arabic Typesetting;Bernard MT Condensed;Harlow Solid Italic;Chiller;NSimSun;Informal Roman;Stencil;Bell MT;Colonna MT;Ravie;Gabriola;Berlin Sans FB;Centaur;High Tower Text;Ubuntu;Californian FB;Mukti Narrow;Purisa;Niagara Engraved;Niagara Solid;Showcard Gothic;Lohit Hindi;Sawasdee;SimHei;Garuda;Loma;Norasi;Tlwg Typist;TlwgTypewriter;Brush Script MT;Kinnari;TlwgMono;Umpush;utkal;Bodoni MT Poster Compressed;Century Gothic;Mallige;Vemana2000;KacstOne;Berlin Sans FB Demi;Phetsarath OT;Tlwg Typo;Magneto;Aparajita;Garamond;Rachana;Lucida Fax;Book Antiqua;Arial Rounded MT Bold;Bookman Old Style;Lucida Handwriting;Gill Sans MT;Century Schoolbook;Monotype Corsiva;Century Schoolbook;Calisto MT;Copperplate Gothic Bold;Haettenschweiler;Goudy Old Style;Script MT Bold;Gill Sans MT Condensed;Gill Sans Ultra Bold;Goudy Old Style;Imprint MT Shadow;Braggadocio;Gill Sans MT Ext Condensed Bold;Palace Script MT;Eras Bold ITC;Eras Medium ITC;Goudy Stout;News Gothic MT;Playbill;Rockwell Condensed;Castellar;Forte;Agency FB;Rage Italic;Gill Sans Ultra Bold Condensed;Tw Cen MT;Colonna MT;Tw Cen MT Condensed;Britannic Bold;Calisto MT;Desdemona;Wide Latin;Gigi;Gloucester MT Extra Condensed;Tw Cen MT Condensed Extra Bold;Footlight MT Light;Matura MT Script Capitals;Perpetua Titling MT;Abadi MT Condensed Light;Adobe Ming Std;Adobe Myungjo Std;Kino MT;Adobe Song Std;Bodoni MT;Bodoni MT Black;Bodoni MT Condensed;Adobe Fangsong Std;Adobe Heiti Std;Adobe Kaiti Std;MS Reference Sans Serif;Calibri;Ubuntu Light;Lucida Sans;Lucida Bright;Lucida Sans Typewriter;Cambria;Consolas;Corbel;Candara;Capitals;Constantia;Adobe Fan Heiti Std;Adobe Gothic Std;Adobe Arabic;Adobe Hebrew;Kozuka Gothic Pr6N;Kozuka Mincho Pr6N;Bitstream Vera Sans;Bitstream Vera Sans Mono;DejaVu Sans;Bitstream Vera Serif;DejaVu Sans Mono;DejaVu Sans Condensed;DejaVu Serif;DejaVu Serif Condensed;Gabriola;Gentium;Utopia;Eurostile;Metal;Luxi Sans;Luxi Mono;Luxi Serif;Matisse ITC;Electron;Nice;Bitstream Vera Sans Mono;Courier;Domestic Manners;Dustismo;MgOpen Modata;MgOpen Moderna;MgOpen Canonica;MgOpen Cosmetica;AR PL UMing CN;AR PL UMing HK;AR PL UMing TW;AR PL UMing TW MBE;Staccato222 BT;Penguin Attack;Balker;Marked Fool;Bitstream Vera Sans;Univers;Junkyard;Linux Libertine O;Bitstream Vera Serif;Linux Biolinum O;Broadway BT;Square721 BT;ParkAvenue BT;MisterEarl BT;Calligraph421 BT;DejaVu LGC Sans Mono;Cataneo BT;Rage Italic LET;La Bamba LET;Blackletter686 BT;Ruach LET;John Handy LET;DejaVu LGC Sans;DejaVu LGC Sans Condensed;DejaVu LGC Sans Light;DejaVu LGC Serif;DejaVu LGC Serif Condensed;Isabella;Linux Libertine;Scruff LET;Westwood LET;AlArabiya;Milano LET;Tiranti Solid LET;One Stroke Script LET;Orange LET;Smudger LET;Victorian LET;Academy Engraved LET;Mekanik LET;Odessa LET;Pump Demi Bold LET;Quixley LET;Inconsolata;Jokerman LET;OldDreadfulNo7 BT;University Roman LET;Highlight LET;Nimbus Sans L Condensed;Gotham;Helvetica;News Gothic Std;AlBattar;AlHor;AlManzomah;Arab;Cortoba;Dimnah;Furat;Granada;Graph;Hani;Hor;Interstate;Japan;Jet;Khalid;Mashq;Mashq-Bold;Nada;Nagham;Ostorah;Ouhod-Bold;Petra;Rasheeq-Bold;Rehan;Salem;Shado;Sharjah;Tarablus;Tholoth;Chicago;Textile;Linux Libertine C;TradeGothic;Hypatia Sans Pro;Frutiger LT Std;Myriad Std;Garamond;Bitstream Vera Sans Mono;Charcoal;Gadget;Avenir;Techno;Delicious;Bitstream Vera Serif;Bitstream Vera Sans;Baby Kruffy;Berthold Akzidenz Grotesk BE;New York;DINSchrift;Sand;ITC Franklin Gothic;Abadi MT Condensed Light;Verdana Ref;Univers;Helvetica Narrow;Caflisch Script Pro;Ubuntu;Alba Super;Caslon;Andale Mono;Kabel Ult BT;Alba;AlMateen-Bold;AlMohanad;AlMothnna-Bold;Andy;Alba Matter;Palatino;Times;Bembo;News Gothic MT;Chick;Adobe Garamond;Bernhard Modern Std;Beesknees ITC;New Century Schoolbook;HelveticaNeue;Minion Std;Frosty;Braggadocio;Kino MT;Formata;ITC Franklin Gothic Std;Pussycat;GENUINE;OCRB;Freshbot;Jenkins v2.0;Placard Condensed;Gentium;Croobie;GlooGun;Weltron Urban;Abadi MT Condensed Extra Bold;Jokewood;Pepita MT;Arial Narrow;Georgia Ref;Poornut;Fat;Ubuntu;Gentium;Andale Mono IPA;RotisSemiSans;Sabon;MS Reference Serif;Abadi MT Condensed;Ubuntu Light;Ubuntu-Title;Monaco;Runic MT Condensed;Shelley;Courier Std;Gill Sans;Optima;Desdemona;Bickley Script;New Century Schoolbook;Archer;BauerBodoni;Monaco;Base 02;ITC Century;Porcelain;Geneva;AkzidenzGrotesk;Cronos Pro;Times CY;CAMPBELL;DomBold BT;Fine Hand;Mercurius Script MT Bold;Chicago;MARKETPRO;Kaufmann;Berkeley;Bookman;Franklin Gothic;Ryo Display Std;Utopia;Aachen;Adobe Sans MM;Helvetica Neue;A Charming Font;Champignon;Apple Casual;Futura;Apple Chancery;Belwe;FreeSans;Minion Web;New York;Algerian;Mead Bold;Avant Garde;FIRSTHOME;Hoefler Text;Helvetica;Monotype.com;FreeSerif;Zapf Chancery;DecoType Naskh;The Sans-;Ubuntu-Title;Caslon;FreeMono;Imprint MT Shadow;04b_21;BudHand;Minion Web;Palatino;Linux Libertine O;Monotype.com;URW Antiqua T;URW Grotesk T;Ubuntu-Title;Helvetica Narrow;Linux Biolinum O;MgOpen Canonica;Bookman;Fixed;Helvetica Narrow;Times;Gadget;Terminal;Textile".split(";");
9
10  //Calculating Fallback measurements
11  var ctx = document.getElementById("fallback").getContext("2d");
12  ctx.font = size + "px FallBackFont";
13  var fallback_width = ctx.measureText(text).width;
14
15  var offset = 10; // font loading limit (could be detected on the fly)
16  var fp = "Fingerprint: "; //will store the result
17
18  //Creates a new iframe and canvas for every 10 fonts to be probed.
19  for (i = 0; i < fonts.length; i++) {
20    id = Math.floor(i/offset);
21    if(i == 0 || Math.floor((i-1)/offset) < id){
22      iframe = document.createElement('iframe');
23      html = '<body><div id="base"></div></body>';
24      document.body.appendChild(iframe);
25      iframe.contentWindow.document.open();
26      iframe.contentWindow.document.write(html);
27      iframe.contentWindow.document.close();
28      iframe.id = 'iframe' + id;
29      iframe.style.display = "none";
30    }
31    idocument = document.getElementById('iframe' + id).contentWindow.document;
32    if(i == 0 || Math.floor((i-1)/offset) < id){
33      idocument.getElementById("base").innerHTML = 
34        '<canvas id="probe_canvas" style="display:none;"></canvas>';
35    }
36    canvi = idocument.getElementById("probe_canvas").getContext("2d");
37    canvi.font = size + "px " + fonts[i];
38    width = canvi.measureText(text).width;
39
40    fp += (fallback_width != width) ? fonts[i] + " - " : "";
41  }
42  alert(fp);
43</script>
44</body>
45</html>