如何在网页中使用计算机现代字体? [英] How to use the computer modern font in webpages?

查看:268
本文介绍了如何在网页中使用计算机现代字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



如何更改CSS以使字体<

在网页中使用计算机现代字体已经变得非常容易了!

只需在HTML代码的head部分粘贴以下几行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镜像加载当前版本的字体可以很慢。这可以用于测试目的,但长期以来,我建议您下载这些.otf文件到您的自己的网络服务器。


I never see Computer Modern font, the one shipped as default for LaTeX type setting system, on any webpage.

How to change the CSS so that font will actually work?

解决方案

Using the Computer Modern font in webpages has become very easy! Just paste the following lines of CSS code in the head section of your html code in order to activate the sans-serif version of that font.

<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>

Note that the solution here makes the browser load the current version of the fonts from a CTAN mirror, which can be very slow. This is okay for testing purposes, but in the long run I'd recommend you download these .otf files to your own webserver.

这篇关于如何在网页中使用计算机现代字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆