From 5b2b7ed604a6aad13b79158f8bbbc211cecb9c87 Mon Sep 17 00:00:00 2001 From: mcelrath Date: Sun, 10 Jun 2012 11:32:40 -0700 Subject: [PATCH] Add bad font detection, and a dialog informing the user. --- .../html/notebook/static/css/notebook.css | 4 +++ .../html/notebook/static/js/notebookmain.js | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/IPython/frontend/html/notebook/static/css/notebook.css b/IPython/frontend/html/notebook/static/css/notebook.css index 0a1f975e0..3202f377d 100644 --- a/IPython/frontend/html/notebook/static/css/notebook.css +++ b/IPython/frontend/html/notebook/static/css/notebook.css @@ -334,3 +334,7 @@ p.dialog { to not honor it correctly. Webkit browsers (Chrome, rekonq, Safari) do. */ pre, code, kbd, samp { white-space: pre-wrap; } + +#fonttest { + font-family: monospace; +} diff --git a/IPython/frontend/html/notebook/static/js/notebookmain.js b/IPython/frontend/html/notebook/static/js/notebookmain.js index 01b19ebc9..69562d1f4 100644 --- a/IPython/frontend/html/notebook/static/js/notebookmain.js +++ b/IPython/frontend/html/notebook/static/js/notebookmain.js @@ -35,6 +35,40 @@ $(document).ready(function () { IPython.layout_manager.do_resize(); + $('body').append('
x'+
+                     'x'+
+                     'x
') + var nh = $('#test1').innerHeight(); + var bh = $('#test2').innerHeight(); + var ih = $('#test3').innerHeight(); + var dialog = $('
'); + if(nh != bh || nh != ih) { + dialog.html('We have detected that your browser is using a '+ + 'monospace font that has an '+ + 'inconsistent size between '+ + 'normal, '+ + 'bold, and '+ + 'italic '+ + 'variants, which are used by IPython for syntax highlighting. '+ + 'This will cause visual artifacts. (The font is probably "Courier New") '+ + 'We recommend that you configure your browser to use a different '+ + 'monospace font.

'+ + 'normal='+String(nh)+'px bold='+String(bh)+'px italic='+String(ih)+'px'); + $(document).append(dialog); + dialog.dialog({ + resizable: false, + modal: true, + title: "Bad fonts detected", + closeText: '', + buttons : { + "Ok": function () { + $(this).dialog('close'); + } + } + }); + $('#fonttest').remove(); + } + if(IPython.read_only){ // hide various elements from read-only view $('div#pager').remove();