Skip to content

Instantly share code, notes, and snippets.

@rougier
Last active December 2, 2021 06:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rougier/2fe7766cf833a93ea1a153a7f7a7f73f to your computer and use it in GitHub Desktop.
Save rougier/2fe7766cf833a93ea1a153a7f7a7f73f to your computer and use it in GitHub Desktop.
Emacs drop shadows
(require 'xml)
(require 'svg)
(let* ((text "Hello world!")
(font (query-font (font-at (point-min))))
(font-size (elt font 2))
(family (face-attribute 'default :family))
(descent (elt font 4))
(ascent (elt font 5))
(svg-height (+ ascent descent))
(char-width (elt font 7))
(svg-width (+ (* char-width (+ (length text) 2))))
(svg (svg-create svg-width svg-height)))
(dom-append-child svg
(dom-node 'defs nil
(dom-node 'filter '((id . "shadow"))
(dom-node 'feGaussianBlur '((stdDeviation . "1.5"))))))
(svg-text svg text
:fill "#666666"
:stroke-width 0
:font-family family
:font-weight "300"
:font-size font-size
:filter "url(#shadow)"
:x char-width
:y descent)
(svg-text svg text
:fill "black"
:stroke-width 0
:font-family family
:font-weight "300"
:font-size font-size
:x char-width
:y descent)
;;(message (svg-print svg))
(insert-image (svg-image svg :ascent 'center)))
@rougier
Copy link
Author

rougier commented Dec 2, 2021

Screenshot 2021-12-01 at 19 28 05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment