[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] shr-fontified adfb5ab 2/2: Don't have shr bug out on degen
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] shr-fontified adfb5ab 2/2: Don't have shr bug out on degenerate fonts |
Date: |
Wed, 28 Jan 2015 03:20:54 +0000 |
branch: shr-fontified
commit adfb5ab968c3fdd07d0bc2d5bb3ae8581bcc083e
Author: Lars Magne Ingebrigtsen <address@hidden>
Commit: Lars Magne Ingebrigtsen <address@hidden>
Don't have shr bug out on degenerate fonts
(shr-tag-h1): Make the font larger.
(shr-pixel-column): Protect against degenerate fonts.
---
lisp/ChangeLog | 2 ++
lisp/net/shr.el | 10 +++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f81b2b4..cfaeb9d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -6,6 +6,8 @@
(shr-render-td): Change all table computations to use pixel widths.
(shr-insert-table): Do the alignment here.
(shr-insert-table): Get colorisation right again.
+ (shr-tag-h1): Make the font larger.
+ (shr-pixel-column): Protect against degenerate fonts.
2015-01-26 Lars Ingebrigtsen <address@hidden>
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 39cddd9..c25a656 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -454,7 +454,10 @@ size, and full-buffer size."
(while (< start (length string))
(let ((glyphs (font-get-glyphs (font-at start nil string)
start (1+ start) string)))
- (setq width (+ width (aref (aref glyphs 0) 4))))
+ (if (not (aref glyphs 0))
+ ;; If we have a degenerate font, just say "10".
+ 10
+ (setq width (+ width (aref (aref glyphs 0) 4)))))
(setq start (1+ start)))
width))
@@ -1401,7 +1404,7 @@ The preference is a float determined from
`shr-prefer-media-type'."
(shr-generic dom))
(defun shr-tag-h1 (dom)
- (shr-heading dom 'bold 'underline))
+ (shr-heading dom '(variable-pitch (:height 1.5 :weight bold))))
(defun shr-tag-h2 (dom)
(shr-heading dom 'bold))
@@ -1589,7 +1592,8 @@ The preference is a float determined from
`shr-prefer-media-type'."
;; Sum up all the widths from the column. (There may be
;; more than one if this is a "colspan" column.)
(dotimes (i (nth 3 column))
- (setq align (+ align 20 (aref widths column-number))
+ (setq align (+ align 20 (aref widths (min (1- (length widths))
+ column-number)))
column-number (1+ column-number)))
(let ((lines (nth 2 column)))
(dolist (line lines)