网络上带有特殊字体的 SVG

发布于 2024-12-29 08:38:33 字数 663 浏览 3 评论 0原文

我有一个 SVG 文件,其中使用了一些特殊的(尽管是免费的)字体,我真的很想在浏览器中显示 svg 文件时使用它们。

我尝试过:

  • 添加
  • 文档内的 svg 字体格式本身的数据添加到 部分

但都没有成功。

有谁知道如何实现这一目标的方法?

PS:抱歉,如果我在错误的网站上提问,我无法确定这是编码问题还是设计问题。


编辑

我遇到了同样的问题,尽管经过几个小时的尝试,我还没有找到解决方案。您可以在这里找到测试用例: http://editor.method.ac/font-files /test.html

测试用例适用于 Opera,不适用于 Firefox 或 Chrome。没有测试过IE9。字体声明仅使用 woff 格式。

I have an SVG file with some special - although free - fonts used in it, and I'd really like to use them when the svg file is displayed in a browser.

I've tried:

  • adding <style> and @font-face elements, pointing to absolute urls, with all the possible web fonts (eot, svg, etc.) inside the <defs></defs> section without success
  • adding the data of the svg font format itself inside the document into the <defs></defs> section

but all without success.

Does anyone know a method how to achieve this?

P.S.: Sorry if I'm asking it on the wrong site, I could not decide wether this is a coding or a design question.


Edit

I ran into the same problem, despite hours of trying I havent found a solution. You can find the test case here: http://editor.method.ac/font-files/test.html

Test case works in Opera, not in Firefox or Chrome. Haven't tested IE9. Font-face declaration uses just woff format.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吹梦到西洲 2025-01-05 08:38:33

出于安全原因, 文件必须完全独立,即它们不能引用任何外部文件。为了让 woff 字体在 Firefox 中的图像中工作,您需要将 woff 数据编码为数据 URL 并将其嵌入图像中。 不是 url(arvo-regular-webfont.woff)

因此,您可以使用 url(data:application/octet-stream;base64,'d09GRg...而 在线编码器此处

<img> files must be entirely self-contained for security reasons, i.e. they can't refer to any external files. In order to get woff fonts to work in images in Firefox, you'll need to encode the woff data as a data URL and embed that in the image. So instead of url(arvo-regular-webfont.woff), you would use url(data:application/octet-stream;base64,'d09GRg...

There's an online encoder here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文