Alternative solution: silently apply some CSS instead of a dialog box.

mcelrath 14 years ago
parent 5b2b7ed604
commit 160fbcdcbc

@ -242,9 +242,16 @@ div.text_cell_render {
color: black;
}
.CodeMirror span {
vertical-align: bottom;
}
/* The following gets added to the <head> if it is detected that the user has a
* monospace font with inconsistent normal/bold/italic height. See
* notebookmain.js. Such fonts will have keywords vertically offset with
* respect to the rest of the text. The user should select a better font.
* See: https://github.com/ipython/ipython/issues/1503
*
* .CodeMirror span {
* vertical-align: bottom;
* }
*/
.CodeMirror {
line-height: 1.231; /* Changed from 1em to our global default */

@ -41,31 +41,8 @@ $(document).ready(function () {
var nh = $('#test1').innerHeight();
var bh = $('#test2').innerHeight();
var ih = $('#test3').innerHeight();
var dialog = $('<div/>');
if(nh != bh || nh != ih) {
dialog.html('We have detected that your browser is using a '+
'<span style="font-family: monospace;">monospace</span> font that has an '+
'inconsistent size between '+
'<span style="font-family: monospace;">normal</span>, '+
'<span style="font-family: monospace; font-weight: bold;">bold</span>, and '+
'<span style="font-family: monospace; font-style: italic;">italic</span> '+
'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.<br/><br/>'+
'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');
}
}
});
$('head').append('<style>.CodeMirror span { vertical-align: bottom; }</style>');
$('#fonttest').remove();
}

Loading…
Cancel
Save