Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vertical offset due to bold/italics, and bad browser fonts. #1883

Merged
merged 2 commits into from Jun 10, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions IPython/frontend/html/notebook/static/css/notebook.css
Expand Up @@ -242,6 +242,10 @@ div.text_cell_render {
color: black;
}

.CodeMirror span {
vertical-align: bottom;
}

.CodeMirror {
line-height: 1.231; /* Changed from 1em to our global default */
}
Expand Down Expand Up @@ -330,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;
}
34 changes: 34 additions & 0 deletions IPython/frontend/html/notebook/static/js/notebookmain.js
Expand Up @@ -35,6 +35,40 @@ $(document).ready(function () {

IPython.layout_manager.do_resize();

$('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
'<span id="test2" style="font-weight: bold;">x</span>'+
'<span id="test3" style="font-style: italic;">x</span></pre></div>')
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');
}
}
});
$('#fonttest').remove();
}

if(IPython.read_only){
// hide various elements from read-only view
$('div#pager').remove();
Expand Down