aboutsummaryrefslogtreecommitdiff
path: root/pyblog
diff options
context:
space:
mode:
authorZhiming Wang <zmwangx@gmail.com>2015-06-16 01:11:43 -0700
committerZhiming Wang <zmwangx@gmail.com>2015-06-16 01:11:43 -0700
commite851ce49f5db841855cd0f653dcb202a4ec7d11d (patch)
tree1bbfd861af9282d4ab23dfdc8199e143754c73a7 /pyblog
parent0cc01b0bbe6282ae173e6fc1760c3f2d1995fd73 (diff)
downloadmy_new_personal_website-e851ce49f5db841855cd0f653dcb202a4ec7d11d.tar.xz
my_new_personal_website-e851ce49f5db841855cd0f653dcb202a4ec7d11d.zip
fix font issues: moving back to Droid Sans Mono for code
I just noticed that code font is crazy without Consolas installed (I recently reinstalled my OS and got rid of Office for Mac 2011 — that's probably why). The line numbers are all off (since the line heights are carefully pre-calculated, and fallback fonts of different leadings won't help). Therefore, I'm moving to the quite nice looking and controllable Droid Sans Mono. Isn't as satisfactory as Consolas on the web, but certainly better than Monaco. Note: I originally copied my list Consolas, Monaco, 'Andale Mono', monospace (I added Courier since I like it a lot as the primitive monospace font) from MDN Wiki, but now it looks like a bad choice when I don't have Consolas any more. By the way, MDN Wiki renders line numbers using JS, so at least they are able to calculate the line heights. I'm serving everything statically, so this is a problem.
Diffstat (limited to '')
-rwxr-xr-xpyblog6
1 files changed, 3 insertions, 3 deletions
diff --git a/pyblog b/pyblog
index 75512bc9..8b500a03 100755
--- a/pyblog
+++ b/pyblog
@@ -576,12 +576,12 @@ def _pre_tag_insert_line_numbers(soup, pre_tag):
num_lines = len(pre_tag.text.split("\n"))
for line_number in range(1, num_lines + 1):
# line number divs will look like:
- # <span class="line-number" data-line="1" style="top: 0px"><!----></span>
- # <span class="line-number" data-line="2" style="top: 18px"><!----></span>
+ # <span class="line-number" data-line="1" style="top: 1px"><!----></span>
+ # <span class="line-number" data-line="2" style="top: 19px"><!----></span>
ln_tag = soup.new_tag("span")
ln_tag["class"] = "line-number"
ln_tag["data-line"] = line_number
- ln_tag["style"] = "top: %dpx" % ((line_number - 1) * CODE_LINE_HEIGHT)
+ ln_tag["style"] = "top: %dpx" % ((line_number - 1) * CODE_LINE_HEIGHT + 1)
# add a comment to the content of the span to suppress tidy5
# empty <span> tag warning
ln_tag.append(soup.new_string("", bs4.Comment))