我的网络服务器上托管了一个 cloud.typography 字体。当我尝试使用stripe.elements()
我的字体将其链接到条带时,它不会显示,并且默认为 Helvetica。我也没有收到任何 javascript 错误。
这是我的javascript代码:
var elements = stripe.elements({
fonts: [
{
cssSrc: 'localhost:8080/static/fonts/######/#################.css',
},
],
});
var baseStyle = {
fontFamily: 'Gotham Narrow A, Gotham Narrow B, sans-serif',
fontSize: '16px',
lineHeight: '1.5',
fontWeight: '300',
color: '#2d3138',
'::placeholder': {
color: '#8f95a3'
}
};
var invalidStyle = {
fontFamily: 'Gotham Narrow A',
fontSize: '16px',
lineHeight: '1.5',
fontWeight: '300',
color: '#e70000'
};
var style = {
base: baseStyle,
invalid: invalidStyle
};
var styles = {style: style};
var card = elements.create('cardNumber', styles);
如果我尝试使用它给我的 css 链接直接链接到排版,我会收到以下错误:
Failed to load https://cloud.typography.com/#######/#######/css/fonts.css:
Redirect from 'https://cloud.typography.com/#######/#######/css/fonts.css'
to 'https://myhostedwebsite.com/fonts/######/#################.css'
has been blocked by CORS policy: No 'Access-Control-Allow-Origin'
header is present on the requested resource. Origin 'http://localhost:8080'
is therefore not allowed access.
我也尝试将我的字体作为字体系列对象导入。
var elements = stripe.elements({
fonts: [
{
family: 'Gotham Narrow A',
src: 'url(https://myhostedwebsite.com/fonts/######/#################.eot)',
style: 'normal',
weight: '300',
},
],
});
请帮忙。