在iPhone版本的Safari上不推荐使用@ font-face。我有什么选择?

时间:2021-09-27 16:03:14

According to Apple's documentation, @font-face is deprecated for use on the iPhone version of Safari. The iPhone only includes 11 fonts, AFAIK, and, in any case, I need a nice blackletter font for an app I'm building. I'll be generating random text, so images are not an option. What alternatives do I have? Am I stuck with a JavaScript solution like Cufón?

根据Apple的文档,@ font-face已弃用,可用于iPhone的iPhone版本。 iPhone只包含11种字体,AFAIK,无论如何,我需要一个漂亮的黑色字体,用于我正在构建的应用程序。我将生成随机文本,因此图像不是一个选项。我有什么替代品?我是否坚持像Cufón这样的JavaScript解决方案?

4 个解决方案

#1


18  

Well, just found out @font-face is NOW support on the current iPhone and iPad. The documentation linked to above, which is Safari CSS Reference Shows the example for how to embed the font.

好吧,刚刚发现@ font-face现在支持当前的iPhone和iPad。链接到上面的文档,即Safari CSS参考显示如何嵌入字体的示例。

@font-face {
    font-family: "MyFamilyname", cursive [, ...];
    font-style: normal [, ...];
    font-variant: normal[, ...];
    font-weight: bold[, ...];
    font-stretch: condensed[, ...]; /* Not supported */
    font-size: 12pt;[, ...] /* Not supported */
    src: local("Font Family Name"),
        url(http://..../fontfile.ttf) format("truetype"),
        url(http://..../fontfile.ttf) [, ...];
}

Just wanted to make sure someone else who came along and read this like me, knew the current state.

只是想确保其他人像我一样来到这里,了解当前状态。

#2


17  

You can actually use @font-face. You just need to use SVG fonts. There are utilities to convert TTFs to SVGs

你实际上可以使用@ font-face。您只需要使用SVG字体。有一些工具可以将TTF转换为SVG

See this for more info (not my post)

看到这个更多信息(不是我的帖子)

http://blog.themeforest.net/tutorials/how-to-achieve-cross-browser-font-face-support/

http://blog.themeforest.net/tutorials/how-to-achieve-cross-browser-font-face-support/

#3


3  

Cufón is really the only solution you'll be able to use out of the box. It has the added advantage of being rather quick on the iPhone since it uses canvas rather than inline SVG, and the generated fonts are typically around 60-80% smaller than the original fonts (when compressed).

Cufón真的是你能够开箱即用的唯一解决方案。它具有在iPhone上相当快速的附加优势,因为它使用画布而不是内联SVG,并且生成的字体通常比原始字体(压缩时)小约60-80%。

#4


0  

I’ll be generating random text, so images are not an option.

我将生成随机文本,因此图像不是一个选项。

You could use a graphics library on the server and draw the images on the fly. I’ve done something similar and it works, but of course it depends on the amount of text you want to draw. Plus if the text repeats at least sometimes, you could cache the images.

您可以在服务器上使用图形库并动态绘制图像。我已经做了类似的事情并且它有效,但当然这取决于你想要绘制的文本量。此外,如果文本至少有时重复,您可以缓存图像。

#1


18  

Well, just found out @font-face is NOW support on the current iPhone and iPad. The documentation linked to above, which is Safari CSS Reference Shows the example for how to embed the font.

好吧,刚刚发现@ font-face现在支持当前的iPhone和iPad。链接到上面的文档,即Safari CSS参考显示如何嵌入字体的示例。

@font-face {
    font-family: "MyFamilyname", cursive [, ...];
    font-style: normal [, ...];
    font-variant: normal[, ...];
    font-weight: bold[, ...];
    font-stretch: condensed[, ...]; /* Not supported */
    font-size: 12pt;[, ...] /* Not supported */
    src: local("Font Family Name"),
        url(http://..../fontfile.ttf) format("truetype"),
        url(http://..../fontfile.ttf) [, ...];
}

Just wanted to make sure someone else who came along and read this like me, knew the current state.

只是想确保其他人像我一样来到这里,了解当前状态。

#2


17  

You can actually use @font-face. You just need to use SVG fonts. There are utilities to convert TTFs to SVGs

你实际上可以使用@ font-face。您只需要使用SVG字体。有一些工具可以将TTF转换为SVG

See this for more info (not my post)

看到这个更多信息(不是我的帖子)

http://blog.themeforest.net/tutorials/how-to-achieve-cross-browser-font-face-support/

http://blog.themeforest.net/tutorials/how-to-achieve-cross-browser-font-face-support/

#3


3  

Cufón is really the only solution you'll be able to use out of the box. It has the added advantage of being rather quick on the iPhone since it uses canvas rather than inline SVG, and the generated fonts are typically around 60-80% smaller than the original fonts (when compressed).

Cufón真的是你能够开箱即用的唯一解决方案。它具有在iPhone上相当快速的附加优势,因为它使用画布而不是内联SVG,并且生成的字体通常比原始字体(压缩时)小约60-80%。

#4


0  

I’ll be generating random text, so images are not an option.

我将生成随机文本,因此图像不是一个选项。

You could use a graphics library on the server and draw the images on the fly. I’ve done something similar and it works, but of course it depends on the amount of text you want to draw. Plus if the text repeats at least sometimes, you could cache the images.

您可以在服务器上使用图形库并动态绘制图像。我已经做了类似的事情并且它有效,但当然这取决于你想要绘制的文本量。此外,如果文本至少有时重复,您可以缓存图像。