update how custom font paths are interpreted
i don't actually think it was possible to supply a relative path with the way this worked before? now it definitely is, which is super nice for loading fonts from the classpath. absolute font paths can still be used if needed, but they absolutely must include a scheme prefix, e.g. 'file:/path/to/font.ttf'
This commit is contained in:
parent
da6d229734
commit
76bbb1afec
|
@ -209,7 +209,8 @@
|
|||
(fn [{:keys [font-family src]}]
|
||||
["@font-face"
|
||||
{:font-family font-family
|
||||
:src (str "url(\"" (utils/string->url-or-file src) "\")")}])
|
||||
; TODO: maybe should use whatever the current uri-resolver function is for this ?
|
||||
:src (str "url(\"" src #_(utils/string->url-or-file src) "\")")}])
|
||||
fonts)))
|
||||
|
||||
(defn build-base-css-styles
|
||||
|
|
BIN
test-resources/FirstTimeWriting-DOy8d.ttf
Normal file
BIN
test-resources/FirstTimeWriting-DOy8d.ttf
Normal file
Binary file not shown.
|
@ -185,3 +185,21 @@
|
|||
:page nil
|
||||
:debug {:display-html? true
|
||||
:display-options? true}})))
|
||||
|
||||
(comment
|
||||
(let [filename "test-custom-font.pdf"
|
||||
relative-font-path "FirstTimeWriting-DOy8d.ttf"
|
||||
absolute-font-path (str (io/resource relative-font-path))]
|
||||
(println "\n **** " filename " **** \n")
|
||||
(->pdf
|
||||
[:div
|
||||
[:h1 "Custom fonts!"]
|
||||
[:p {:style "font-family: custom-font-relative"} "This should be styled in a custom font, specified via relative path!"]
|
||||
[:p {:style "font-family: custom-font-absolute"} "This should also be styled with a custom font, but specified via an absolute path!"]]
|
||||
filename
|
||||
{:styles {:fonts [{:font-family "custom-font-relative"
|
||||
:src relative-font-path}
|
||||
{:font-family "custom-font-absolute"
|
||||
:src relative-font-path}]}
|
||||
:debug {:display-html? true
|
||||
:display-options? true}})))
|
||||
|
|
Loading…
Reference in a new issue