По какой-то причине я не могу использовать свой пользовательский шрифт с элементами чередования:
// Case 1
stripe.elements (fonts: {
family: "Indie Flower"
src: "url(https://fonts.gstatic.com/s/indieflower/v11/m8JVjfNVeKWVnh3QMuKkFcZVaUuH99GUDg.woff2)"
weight: 500
})
// Case 2
stripe.elements (fonts: {
family: "Gotham-Light"
src: "url(http://localhost:5000/my-font)"
weight: 500
})
Когда я использую Ind ie Flower в качестве шрифта, используя fontFamily: "Ind ie Flower", я вижу шрифт в элементе полосы, но не с «Gotham-Light».
Вот фактический код clojurescript:
(let [
elements (.elements stripe
(clj->js
;; {:fonts [{:family "Gotham-Light"
;; :src (str "url(" (url) "/gotham-light" ")")
;; :weight 500
;; }]}
{:fonts [{:family "Indie Flower"
:src (str "url(" (url) "/indie)")
;;:src "url(https://fonts.gstatic.com/s/indieflower/v11/m8JVjfNVeKWVnh3QMuKkFcZVaUuH99GUDg.woff2)"
:weight 500
}]}
)
)
card-element
(.create elements "card"
(clj->js
{:style
{:base
{
:fontFamily "Indie Flower, Helvetica, sans-serif"
:fontSize 16
}
:invalid
{:color "#FFC7EE"}
}
}
))]
(.mount card-element "#card-element")
(assoc db :stripe stripe :card-element card-element)
)
Сторона сервера такова: Сторона сервера такая: Сторона сервера это: сторона сервера это:
(defn font-handler2 [req]
(assoc (resource-response "indie.woff2" {:root "public/"})
:headers {
"Age" "608650",
"Content-Type" "font/woff2",
"Access-Control-Allow-Origin" "*",
"Timing-Allow-Origin" "*",
"X-Content-Type-Options" "nosniff",
"Content-Length" "19120",
"Alt-Svc"
"quic=\":443\"; ma=2592000; v=\"46,43\",h3-Q050=\":443\"; ma=2592000,h3-Q049=\":443\"; ma=2592000,h3-Q048=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000",
"Connection" "close",
"Accept-Ranges" "bytes",
"X-XSS-Protection" "0",
"Cache-Control" "public, max-age=31536000"})
)
(def routes ["/indie" font-handler2])
Если это поможет, вот ответы без тела (что очень долго, но в обоих случаях одинаково, что я на самом деле проверил.)
user> (dissoc (http/get "http://localhost:5000/indie") :body)
{:cached nil,
:request-time 7,
:repeatable? false,
:protocol-version {:name "HTTP", :major 1, :minor 1},
:streaming? true,
:http-client
#object[org.apache.http.impl.client.InternalHttpClient 0x1947efde "org.apache.http.impl.client.InternalHttpClient@1947efde"],
:chunked? false,
:reason-phrase "OK",
:headers
{"Content-Type" "font/woff2",
"Server" "Aleph/0.4.4",
"Connection" "Close",
"Date" "Tue, 07 Apr 2020 16:40:53 GMT",
"content-length" "19120"},
:orig-content-encoding nil,
:status 200,
:length 19120,
:trace-redirects []}
user> (dissoc (http/get "https://fonts.gstatic.com/s/indieflower/v11/m8JVjfNVeKWVnh3QMuKkFcZVaUuH99GUDg.woff2") :body)
{:cached nil,
:request-time 47,
:repeatable? false,
:protocol-version {:name "HTTP", :major 1, :minor 1},
:streaming? true,
:http-client
#object[org.apache.http.impl.client.InternalHttpClient 0x4346f38b "org.apache.http.impl.client.InternalHttpClient@4346f38b"],
:chunked? false,
:reason-phrase "OK",
:headers
{"Server" "sffe",
"Age" "608650",
"Content-Type" "font/woff2",
"Access-Control-Allow-Origin" "*",
"Timing-Allow-Origin" "*",
"X-Content-Type-Options" "nosniff",
"Content-Length" "19120",
"Alt-Svc"
"quic=\":443\"; ma=2592000; v=\"46,43\",h3-Q050=\":443\"; ma=2592000,h3-Q049=\":443\"; ma=2592000,h3-Q048=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000",
"Connection" "close",
"Accept-Ranges" "bytes",
"Expires" "Wed, 31 Mar 2021 15:37:07 GMT",
"Date" "Tue, 31 Mar 2020 15:37:07 GMT",
"Last-Modified" "Tue, 16 Jul 2019 23:56:42 GMT",
"X-XSS-Protection" "0",
"Cache-Control" "public, max-age=31536000"},
:orig-content-encoding nil,
:status 200,
:length 19120,
:trace-redirects []}
Первый / ind ie - до того, как я добавил заголовки cors.