适用于嵌入字体的SVG图像 [英] Right mime type for SVG images with fonts embedded

查看:380
本文介绍了适用于嵌入字体的SVG图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是通常的SVG mime类型:

  image / svg + xml 

它的效果很好。但是,在嵌入SVG字体时,chrome会告诉您mime类型不正确,显然是因为您返回字体而不是图像。



是否有任何通用MIME类型?铬错了?是 application / svg + xml 以某种方式接受了吗?



我猜这仍然是HTML5中的一个灰色区域,但这里有人可能知道。

解决方案

只有一个注册媒体类型,这就是你列出的那个, image / svg + xml 。您当然也可以将SVG作为XML来使用,尽管如果您使用的浏览器在某些场景中的行为往往不尽相同,例如我曾经见过使用CSS背景的SVG无法显示的情况,除非使用图像/ svg + xml mediatype。


This is the usual SVG mime type:

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.

Is there any universal mime type? is chrome wrong? is application/svg+xml accepted somehow?

I guess this is still a gray area in HTML5 but someone here might know.

解决方案

There's only one registered mediatype for 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图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆