css - 在 visual studio 2015 中嵌入字体

标签 css visual-studio-2015 fonts

我有一个自定义字体 .ttf 和 .otf 文件,我已将它们添加到我的 mvc 元素中的字体文件夹中。我如何从 CSS 中调用它们?看到一些文章谈论打开字体管理器或 html 设计器,但我看不到任何东西来嵌入它们以便它们在所有浏览器上工作?

谢谢

最佳答案

您已经将自定义字体添加到 Visual Studio 中的字体文件夹中。

现在您所要做的就是在@font-face 规则中指向您的字体:

@font-face {
        font-family: "MyCustomFont.ttf";
        font-style: normal;
        src: url(../fonts/MyCustomFont.ttf); /*if IE */
        src: local("MyCustomFont"), url("../fonts/MyCustomFont.ttf") format("truetype"); /* non-IE */
}

如果您需要其他字体,只需添加另一个@font-face 规则

@font-face {
        font-family: "MyCustomFont2.otf";
        font-style: normal;
        src: url(../fonts/MyCustomFont2.otf); /*if IE */
        src: local("MyCustomFont2"), url("../fonts/MyCustomFont2.otf") format("truetype"); /* non-IE */
}

这种方法适用于所有浏览器。

来源: https://forums.asp.net/t/1589195.aspx?Adding+a+font+to+use+in+visual+studio

关于css - 在 visual studio 2015 中嵌入字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42720000/

相关文章:

javascript - 我如何为 window.getSelection 值分配文本方向 RTL,我试过了但是如何从文本区域的现有值中删除 getSelection

css - bootstrap 隐藏了我的领域或者它减少了它的宽度

javascript - meteor 将 json 结果解析为 span 或 div?

c# - 从 Windows 服务以编程方式锁定工作站

wpf - Visual Studio Windows 模拟器

html - Muli 字体无法正确呈现

html - 如何将三个 div 合并为一个以共享背景?

ios_base 类的 C++ 未声明标识符

javascript - Webfont 在 Chrome 扩展程序中不起作用

html - CSS @font-face 的问题