【问题标题】:Getting italic font everywhere in HTML在 HTML 中随处获取斜体字体
【发布时间】:2020-11-27 22:49:23
【问题描述】:

我从 Mathjax 网站下载了一个示例页面,并从 Github 下载了他们的包以在本地使用。另外,我想使用计算机现代字体,所以我将包含ttf文件的存档解压缩到fonts/cmu。

这是修改后的 HTML 代码:

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <meta name="viewport" content="width=device-width">
  <title>MathJax v3 with TeX input and HTML output</title>
  
  <script>
  MathJax = {
    tex: {inlineMath: [['$', '$'], ['\\(', '\\)']]}
  };
  </script>
  <script id="MathJax-script" async src="MathJax-master/es5/tex-chtml.js"></script>

  <style type="text/css">
    @font-face {
      font-family: "Computer Modern";
      src: url('fonts/cmu/cmunrm.ttf');
      font-weight: normal;
      font-style: normal;
    }
    @font-face {
      font-family: "Computer Modern";
      src: url('fonts/cmu/cmunbx.ttf');
      font-weight: bold;
      font-style: normal;
    }
    @font-face {
      font-family: "Computer Modern";
      src: url('fonts/cmu/cmunti.ttf');
      font-weight: normal;
      font-style: italic, oblique;
    }
    @font-face {
      font-family: "Computer Modern";
      src: url('fonts/cmu/cmunbi.ttf');
      font-weight: bold;
      font-style: italic, oblique;
    }

    body {
      font-family: "Computer Modern", sans-serif;
      margin:2em;
      padding:0em;
    }

    p {
      text-align: justify;
    }
  </style>
</head>
<body>
    <h1>MathJax v3 beta: TeX input, HTML output test</h1>
    asdasd
    <p>
    When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
    $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
    </p>

    <h2>The Lorenz Equations</h2>

    <p>
    \begin{align}
    \dot{x} &amp; = \sigma(y-x) \\
    \dot{y} &amp; = \rho x - y - xz \\
    \dot{z} &amp; = -\beta z + xy
    \end{align}
    </p>

    <h2>In-line Mathematics</h2>

    <p>Finally, while display equations look good for a page of samples, the
    ability to mix math and text in a paragraph is also important.  This
    expression $\sqrt{3x-1}+(1+x)^2$ is an example of an inline equation.  As
    you see, MathJax equations can be used this way as well, without unduly
    disturbing the spacing between lines.</p>

</body>
</html>

当我在 Chrome 浏览器 (Mac OS) 中打开 html 文件时,由于某种原因,所有文本都是斜体。我确定 cmunrm 是常规字体,并且我没有使用 &lt;i&gt; 标签,所以我不明白为什么所有内容都以斜体呈现。有人可以帮忙吗?

这是屏幕截图:

【问题讨论】:

  • 能把截图给我们看看就好了。
  • 如果你只有一个字体文件,你可以尝试使用@font-face 一次。也许这会有所帮助。
  • @m4n0:完成!编辑了问题。
  • @MaciejBłędkowski:但是字体的常规版本和斜体版本在完全不同的文件中,并且应用于常规字体的 标签并没有给出预期的结果——它与斜体版
  • 好像你在声明字体样式:斜体、斜体;

标签: html css mathjax


【解决方案1】:

经过一番研究,我找到了this post on StackOverflow,显然你只需要删除倾斜。

【讨论】:

    猜你喜欢
    • 2010-12-13
    • 2011-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-18
    • 2020-10-24
    • 2013-02-18
    • 2014-03-01
    相关资源
    最近更新 更多