Html 嵌入字体的 SVG 图像的正确 mime 类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11918977/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Right mime type for SVG images with fonts embedded
提问by cmplieger
This is the usual SVG mime type:
这是通常的 SVG mime 类型:
image/svg+xml
And it works great. However, when embedding an SVG font, chrome tells you the mime type is incorrect, obviously because you return a font instead of an image.
而且效果很好。但是,当嵌入 SVG 字体时,chrome 会告诉您 mime 类型不正确,这显然是因为您返回的是字体而不是图像。
Is there any universal mime type? is chrome wrong? is application/svg+xml
accepted somehow?
有没有通用的 mime 类型?铬错了吗?application/svg+xml
以某种方式被接受?
I guess this is still a gray area in HTML5 but someone here might know.
我想这仍然是 HTML5 中的灰色区域,但这里有人可能知道。
回答by Erik Dahlstr?m
There's only one registered mediatypefor SVG, and that's the one you listed, image/svg+xml
. You can of course serve SVG as XML too, though browsers tend to behave differently in some scenarios if you do, for example I've seen cases where SVG used in CSS backgrounds fail to display unless served with the image/svg+xml
mediatype.
SVG只有一种已注册的媒体类型,这就是您列出的一种,image/svg+xml
. 您当然也可以将 SVG 作为 XML 提供,但如果您这样做,浏览器在某些情况下往往会表现出不同的行为,例如,我见过在 CSS 背景中使用的 SVG 无法显示的情况,除非与image/svg+xml
媒体类型一起提供。