Last active
December 2, 2021 06:23
-
-
Save rougier/2fe7766cf833a93ea1a153a7f7a7f73f to your computer and use it in GitHub Desktop.
Emacs drop shadows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) |
Author
rougier
commented
Dec 2, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment