微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

css – 如何在网页中使用计算机现代字体?

我从来没有看到计算机现代字体,一个作为认为LaTeX类型设置系统,在任何网页上。

如何更改CSS以使字体实际工作?

解决方法

使用计算机现代字体在网页已经变得非常容易!只需在HTML代码的头部粘贴以下几行CSS代码,以激活该字体的sans-serif版本。
<style type="text/css">
  @font-face {
    font-family: "Computer Modern";
    src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');
  }
  @font-face {
    font-family: "Computer Modern";
    src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunsx.otf');
    font-weight: bold;
  }
  @font-face {
    font-family: "Computer Modern";
    src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunsi.otf');
    font-style: italic,oblique;
  }
  @font-face {
    font-family: "Computer Modern";
    src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunbxo.otf');
    font-weight: bold;
    font-style: italic,oblique;
  }

  body {
    font-family: "Computer Modern",sans-serif;
  }
</style>

注意,这里的解决方案使浏览器从CTAN镜像加载当前版本的字体,这可能很慢。这是好的测试目的,但长期来说,我建议你download这些.OTF文件到您自己的网络服务器。

原文地址:https://www.jb51.cc/css/220559.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。