无法使用@ font-face在SVG文件上使用字体

我试图在我的SVG文件上使用自定义字体,但是失败了。我在普通的HTML / CSS网页上进行了尝试,效果很好。但是当涉及到SVG时,我尝试了网站上建议的方法,但是没有用。

<?xml version="1.0"?>
<!-- Generated by SVGo -->
<svg width="500" height="500"
 xmlns="http://www.w3.org/2000/svg" 
 xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<script type="text/css">
<![CDATA[
    @font-face {font-family: "waffle_regularregular";src:url('/font/waffleregular-webfont.eot');src: url('/font/waffleregular-webfont.eot?#iefix') format('embedded-opentype'),url('/font/waffleregular-webfont.woff2') format('woff2'),url('/font/waffleregular-webfont.woff') format('woff'),url('/font/waffleregular-webfont.ttf') format('truetype'),url('/font/waffleregular-webfont.svg#waffle_regularregular') format('svg');font-weight: normal;font-style: normal;}
]]>
</script>
<script type="text/css">
<![CDATA[
    text {font-family: "waffle_regularregular"}
]]>
</script>
</defs>
<text x="250" y="250" style="text-anchor:middle;font-size:30px;fill:white">ทดสอบ test ព័ត៌មានតាមថ្ងៃ 日本語 中文</text>

每次我在Chrome和Firefox上打开它时,他们都会选择Linux系统字体来显示。为了进行测试,我将文本的字体系列样式更改为其他Linux字体,并且效果很好。它只是不使用我的自定义字体。

我的自定义字体是Thai字体,由fontsquirrel.com生成。我正在尝试这样做,以确保所有客户端在我的SVG上都能看到相同的字体。

我在浏览器上检查了自定义字体的路径,它们都可用。请提出建议。

阿尔瓦罗·蒙托罗(Alvaro Montoro)

您需要使用style而不是script加载和指定字体:

<?xml version="1.0"?>
<!-- Generated by SVGo -->
<svg width="500" height="500"
 xmlns="http://www.w3.org/2000/svg" 
 xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<style type="text/css">
<![CDATA[
    @font-face {font-family: "waffle_regularregular";src:url('/font/waffleregular-webfont.eot');src: url('/font/waffleregular-webfont.eot?#iefix') format('embedded-opentype'),url('/font/waffleregular-webfont.woff2') format('woff2'),url('/font/waffleregular-webfont.woff') format('woff'),url('/font/waffleregular-webfont.ttf') format('truetype'),url('/font/waffleregular-webfont.svg#waffle_regularregular') format('svg');font-weight: normal;font-style: normal;}
]]>
</style>
<style type="text/css">
<![CDATA[
    text {font-family: "waffle_regularregular"}
]]>
</style>
</defs>
<text x="250" y="250" style="text-anchor:middle;font-size:30px;fill:white">ทดสอบ test ព័ត៌មានតាមថ្ងៃ 日本語 中文</text>
</svg>

那应该工作正常(只要字体的路径正确)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

我可以强制浏览器使用CSS @ font-face代替系统上安装的字体吗?

来自分类Dev

在Firefox上使用字体

来自分类Dev

如何在多个svg文件中使用字体字形?

来自分类Dev

Font Awesome字体无法加载?

来自分类Dev

在CSS中使用@font_face添加本地ttf字体

来自分类Dev

Font Awesome无法在离线模式下使用

来自分类Dev

@ font-face图标无法在Chrome-Ubuntu中使用

来自分类Dev

无法获取@ font-face中使用的字体文件

来自分类Dev

在Microsoft Edge中使用@ font-face

来自分类Dev

无法使用@ font-face或Google字体在网站上显示任何其他字体

来自分类Dev

我不能使用@ font-face

来自分类Dev

我无法使用font_import导入字体

来自分类Dev

无法使用@ font-face显示自定义字体

来自分类Dev

Font Awesome 5,为什么使用字体时品牌图标不起作用?

来自分类Dev

在python-docx中使用font.name或font.size时,无法使用RTL方向

来自分类Dev

CSS中使用font-face的自定义字体

来自分类Dev

@ font-face仍无法在FireFox中使用。字体类型有问题吗?

来自分类Dev

在我的CSS中使用Lato字体(@ font-face)

来自分类Dev

在Firefox上使用字体

来自分类Dev

无法让@ font-face工作

来自分类Dev

在tumblr中使用@ font-face无法与RTL脚本一起使用

来自分类Dev

@ font-face无法正常工作,似乎无法加载字体

来自分类Dev

CSS WOFF字体-部署时不使用@ Face-Font

来自分类Dev

在Shopify Liquid中使用@ font-face时的字体文件404

来自分类Dev

在哪里放置使用@ font-face的字体文件夹?

来自分类Dev

@ font-face在Android Cordova中无法使用Unicode Malayalam

来自分类Dev

无法获取@ font-face中使用的字体文件

来自分类Dev

无法使用@ font-face加载字体

来自分类Dev

在 Orbeon 中使用 font-awesome(@font-face 不加载本地托管的字体)

Related 相关文章

  1. 1

    我可以强制浏览器使用CSS @ font-face代替系统上安装的字体吗?

  2. 2

    在Firefox上使用字体

  3. 3

    如何在多个svg文件中使用字体字形?

  4. 4

    Font Awesome字体无法加载?

  5. 5

    在CSS中使用@font_face添加本地ttf字体

  6. 6

    Font Awesome无法在离线模式下使用

  7. 7

    @ font-face图标无法在Chrome-Ubuntu中使用

  8. 8

    无法获取@ font-face中使用的字体文件

  9. 9

    在Microsoft Edge中使用@ font-face

  10. 10

    无法使用@ font-face或Google字体在网站上显示任何其他字体

  11. 11

    我不能使用@ font-face

  12. 12

    我无法使用font_import导入字体

  13. 13

    无法使用@ font-face显示自定义字体

  14. 14

    Font Awesome 5,为什么使用字体时品牌图标不起作用?

  15. 15

    在python-docx中使用font.name或font.size时,无法使用RTL方向

  16. 16

    CSS中使用font-face的自定义字体

  17. 17

    @ font-face仍无法在FireFox中使用。字体类型有问题吗?

  18. 18

    在我的CSS中使用Lato字体(@ font-face)

  19. 19

    在Firefox上使用字体

  20. 20

    无法让@ font-face工作

  21. 21

    在tumblr中使用@ font-face无法与RTL脚本一起使用

  22. 22

    @ font-face无法正常工作,似乎无法加载字体

  23. 23

    CSS WOFF字体-部署时不使用@ Face-Font

  24. 24

    在Shopify Liquid中使用@ font-face时的字体文件404

  25. 25

    在哪里放置使用@ font-face的字体文件夹?

  26. 26

    @ font-face在Android Cordova中无法使用Unicode Malayalam

  27. 27

    无法获取@ font-face中使用的字体文件

  28. 28

    无法使用@ font-face加载字体

  29. 29

    在 Orbeon 中使用 font-awesome(@font-face 不加载本地托管的字体)

热门标签

归档