Allow using variable-width fonts in eww

* lisp/gnus/mm-decode.el (mm-shr): Only pass the fill column when not using
fonts, because limiting the width to what's appropriate for followups
doesn't really help when not using proportional fonts.

* lisp/net/shr.el (shr-use-fonts): New variable.
(shr-fill-text): Rename from "fold".
(shr-pixel-column, shr-pixel-region, shr-string-pixel-width): New
functions.
(shr-insert): Just insert, don't fill the text.  Filling is now
done afterwards per display unit.
(shr-fill-lines, shr-fill-line): New functions to fill text on a
per-unit base.
(shr-find-fill-point): Take a "beginning" parameter.
(shr-indent): Indent using the :width display parameter when using
fonts.
(shr-parse-style): Ignore "inherit" values, since we already do that.
(shr-tag-img): Remove the insertion states.
(shr-tag-blockquote): New-style filling.
(shr-tag-dd): Ditto.
(shr-tag-li): Ditto.
(shr-mark-fill): New function to mark lines that need filling.
(shr-tag-h1): Use a larger font.
(shr-tag-table-1): Get the natural and suggested widths in one
rendering.
(shr-tag-table): Create the "fixed" version of the table only once
so that we can cache data in the table.
(shr-insert-table): Get colspan calculations right by having
zero-width columns after colspan ones.
(shr-expand-alignments): New function to make :align-to specs work
right when rendered in one buffer and displayed in another one.
(shr-insert-table-ruler): Use :align-to to get the widths right.
(shr-make-table): Cache more.
(shr-make-table-1): Use the new <td> data layout.
(shr-pixel-buffer-width): New function.
(shr-render-td): Add a caching layer.
(shr-dom-max-natural-width): New function.
This commit is contained in:
Lars Magne Ingebrigtsen 2015-02-10 16:29:05 +11:00
parent 880415a6a6
commit 656caef350
5 changed files with 512 additions and 263 deletions

View file

@ -409,7 +409,6 @@ See the `eww-search-prefix' variable for the search engine used."
(form . eww-tag-form)
(input . eww-tag-input)
(textarea . eww-tag-textarea)
(body . eww-tag-body)
(select . eww-tag-select)
(link . eww-tag-link)
(a . eww-tag-a))))
@ -495,15 +494,6 @@ See the `eww-search-prefix' variable for the search engine used."
(replace-regexp-in-string "[ \t\r\n]+" " " (dom-text dom))))
(eww-update-header-line-format))
(defun eww-tag-body (dom)
(let* ((start (point))
(fgcolor (or (dom-attr dom 'fgcolor) (dom-attr dom 'text)))
(bgcolor (dom-attr dom 'bgcolor))
(shr-stylesheet (list (cons 'color fgcolor)
(cons 'background-color bgcolor))))
(shr-generic dom)
(shr-colorize-region start (point) fgcolor bgcolor)))
(defun eww-display-raw (buffer &optional encode)
(let ((data (buffer-substring (point) (point-max))))
(unless (buffer-live-p buffer)
@ -653,6 +643,7 @@ the like."
(define-key map "H" 'eww-list-histories)
(define-key map "E" 'eww-set-character-encoding)
(define-key map "S" 'eww-list-buffers)
(define-key map "F" 'eww-toggle-fonts)
(define-key map "b" 'eww-add-bookmark)
(define-key map "B" 'eww-list-bookmarks)
@ -1425,6 +1416,15 @@ Differences in #targets are ignored."
(eww-reload nil 'utf-8)
(eww-reload nil charset)))
(defun eww-toggle-fonts ()
"Toggle whether to use monospaced or font-enabled layouts."
(interactive)
(message "Fonts are now %s"
(if (setq shr-use-fonts (not shr-use-fonts))
"on"
"off"))
(eww-reload))
;;; Bookmarks code
(defvar eww-bookmarks nil)