为什么我的下载字体显示不正确?

huangapple go评论44阅读模式
英文:

Why isn't my downloaded font displaying correctly?

问题

I downloaded a font, and in a zip came multiple files. I followed the instruction in the .txt file, which told me to put it in as a font face. However, when I put it in, it looks nothing like the font I downloaded. Is this a thing with Chrome, and if it is, what do I do now? Also, is there an easier way to turn a Figma design into HTML CSS? It's always a pain.

CSS:

@tailwind base;
@tailwind components;
@tailwind utilities;

@import url('https://fonts.googleapis.com/css2?family=League+Spartan&display=swap');

@font-face {
    font-family: 'Spartan-MB-SemiBold', sans-serif;
    src: url('./assets/Spartan-MB-SemiBold.ttf.woff') format('woff'),
        url('./assets/Spartan-MB-SemiBold.ttf.svg') format('svg'),
        url('./assets/Spartan-MB-SemiBold.ttf.eot'), format('embedded-opentype');
        font-weight: normal;
        font-style: sans-serif;
}
h1 { 
    font-family: 'Spartan-MB-SemiBold';
}  

TAILWIND OUTPUT (some of it)

.font-spartan {
  font-family: Spartan, sans-serif;
}

.text-2xl {
  font-size: 1.5rem;
  line-height: 2rem;
}

.text-title-text {
  color: 579229;
}

@font-face {
  font-family: 'Spartan-MB-SemiBold', sans-serif;

  src: url('./assets/Spartan-MB-SemiBold.ttf.woff') format('woff'),
        url('./assets/Spartan-MB-SemiBold.ttf.svg') format('svg'),
        url('./assets/Spartan-MB-SemiBold.ttf.eot'), format('embedded-opentype');

  font-weight: normal;

  font-style: sans-serif;
}

h1 {
  font-family: 'Spartan-MB-SemiBold';
}

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>StudyConnect</title>
    <link rel="stylesheet" href="./tailwind/output.css">
</head>
<body class="">
    <nav class="w-100% h-10% text-2xl">
        <div class="flex mx-auto px-4 flex items-center justify-between">
            <div class="flex">
                <img src="./assets/rocketpencilgreen-removebg-preview.png" alt="logo" class="h-16 w-16">
                <h1 class="flex flex-end mt-4 bold font-spartan text-title-text">StudyConnect</h1>
            </div>
        </div>
    </nav>
    <div class="slide-1">

    </div>
</body>
</html>

TAILWIND CONFIG

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["index.html"],
  theme: {
    extend: {
      colors: {
        'navbar-left': '#E8FFDA',
        'navbar-right': '#67FB0D',
        'title-text': '#579229',
        'login-button': '#B9E198',
        'login-text': '#102400',
        'square-one': '#FFECA9',
        'square-two': '#FF9393',
        'square-three': '#93D3FF',
      },
      backgroundImage: {
        'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
      },
      fontFamily: {
        'league-spartan': ['League Spartan', 'sans-serif'],
        'spartan': ['Spartan', 'sans-serif'],
      },
    },
  },
  plugins: [],
}

Hope this helps!

英文:

I downloaded a font, and in a zip came multiple files. I followed the instruction in the .txt file, which told me to put it in as a font face. However, when I put it in, it looks nothing like the font I downloaded. Is this a thing with Chrome, and if it is, what do I do now? Also, is there an easier way to turn a Figma design into HTML CSS? It's always a pain.

CSS:


@tailwind base;
@tailwind components;
@tailwind utilities;

@import url(&#39;https://fonts.googleapis.com/css2?family=League+Spartan&amp;display=swap&#39;);

@font-face {
    font-family: &#39;Spartan-MB-SemiBold&#39;, sans-serif;
    src:url(&#39;./assets/Spartan-MB-SemiBold.ttf.woff&#39;) format(&#39;woff&#39;),
        url(&#39;./assets/Spartan-MB-SemiBold.ttf.svg&#39;) format(&#39;svg&#39;),
        url(&#39;./assets/Spartan-MB-SemiBold.ttf.eot&#39;), format(&#39;embedded-opentype&#39;);
        font-weight: normal;
        font-style: sans-serif;
}
h1 { 
    font-family: &#39;Spartan-MB-SemiBold&#39;;
 }  
 

TAILWIND OUTPUT (some of it)

.font-spartan {
  font-family: Spartan, sans-serif;
}

.text-2xl {
  font-size: 1.5rem;
  line-height: 2rem;
}

.text-title-text {
  color: 579229;
}

@font-face {
  font-family: &#39;Spartan-MB-SemiBold&#39;, sans-serif;

  src:url(&#39;./assets/Spartan-MB-SemiBold.ttf.woff&#39;) format(&#39;woff&#39;),
        url(&#39;./assets/Spartan-MB-SemiBold.ttf.svg&#39;) format(&#39;svg&#39;),
        url(&#39;./assets/Spartan-MB-SemiBold.ttf.eot&#39;), format(&#39;embedded-opentype&#39;);

  font-weight: normal;

  font-style: sans-serif;
}


h1 {
  font-family: &#39;Spartan-MB-SemiBold&#39;;
}  

HTML

&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot;&gt;
    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
    &lt;title&gt;StudyConnect&lt;/title&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;./tailwind/output.css&quot;&gt;
&lt;/head&gt;
&lt;body class=&quot;&quot;&gt;
    &lt;nav class=&quot;w-100% h-10% text-2xl&quot;&gt;
        &lt;div class=&quot;flex mx-auto px-4 flex items-center justify-between&quot;&gt;
            &lt;div class=&quot;flex&quot;&gt;
                &lt;img src=&quot;./assets/rocketpencilgreen-removebg-preview.png&quot; alt=&quot;logo&quot; class=&quot;h-16 w-16&quot;&gt;
                &lt;h1 class=&quot;flex flex-end mt-4 bold font-spartan text-title-text&quot;&gt;StudyConnect&lt;/h1&gt;
            &lt;/div&gt; 
        &lt;/div&gt;
    &lt;/nav&gt;
    &lt;div class=&quot;slide-1&quot;&gt;

    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;

TAILWIND CONFIG

/** @type {import(&#39;tailwindcss&#39;).Config} */
module.exports = {
  content: [&quot;index.html&quot;],
  theme: {
    extend: {
      colors: {
        &#39;navbar-left&#39;: &#39;#E8FFDA&#39;,
        &#39;navbar-right&#39;: &#39;#67FB0D&#39;,
        &#39;title-text&#39;: &#39;579229&#39;,
        &#39;login-button&#39;: &#39;#B9E198&#39;,
        &#39;login-text&#39;: &#39;#102400&#39;,
        &#39;square-one&#39;: &#39;#FFECA9&#39;,
        &#39;square-two&#39;: &#39;#FF9393&#39;,
        &#39;square-three&#39;: &#39;#93D3FF&#39;,
      },
      backgroundImage: {
        &#39;gradient-radial&#39;: &#39;radial-gradient(var(--tw-gradient-stops))&#39;,
      },
      fontFamily: {
        &#39;league-spartan&#39;: [&#39;League Spartan&#39;, &#39;sans-serif&#39;],
        &#39;spartan&#39;: [&#39;Spartan&#39;, &#39;sans-serif&#39;],
      },
    },
  },
  plugins: [],
}

Thanks!

答案1

得分: 0

这看起来不正确:

      fontFamily: {
        'league-spartan': ['League Spartan', 'sans-serif'],
        'spartan': ['Spartan', 'sans-serif'],
      },

尝试:

      fontFamily: {
        'spartan': ['Spartan-MB-SemiBold', 'sans-serif'],
      },

如果需要进一步的帮助,请告诉我。

英文:

this looks wrong:


      fontFamily: {
        &#39;league-spartan&#39;: [&#39;League Spartan&#39;, &#39;sans-serif&#39;],
        &#39;spartan&#39;: [&#39;Spartan&#39;, &#39;sans-serif&#39;],
      },

try:


      fontFamily: {
        &#39;spartan&#39;: [&#39;Spartan-MB-SemiBold&#39;, &#39;sans-serif&#39;],
      },

huangapple
  • 本文由 发表于 2023年6月1日 02:07:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76376235.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定