将自定义字体添加到 GitHub 页面 [英] Adding custom fonts to GitHub pages

查看:39
本文介绍了将自定义字体添加到 GitHub 页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在 GitHub 上托管了我的新网站.我使用了一些自定义字体,我将它们上传到 index.htmlstyle.css 文件旁边:

I just hosted my new website on GitHub. I use there a few custom fonts, which I uploaded right next to the index.html and style.css files:

字体代码:

@font-face {
  font-family: "gogoiadeco";
  src: url('gogoia-deco-webfont.eot');
  src: url('gogoia-deco-webfont.eot?#iefix') format('embedded-opentype'),
    url('gogoia-deco-webfont.woff') format('woff'),
    url('gogoia-deco-webfont.ttf') format('truetype'),
    url('gogoia-deco-webfont.svg#Gogoia') format('svg');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'icomoon';
  src:url('icomoon.eot');
  src:url('icomoon.eot?#iefix') format('embedded-opentype'),
    url('icomoon.woff') format('woff'),
    url('icomoon.ttf') format('truetype'),
    url('icomoon.svg#icomoon') format('svg');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'gogoiaregular';
  src: url('gogoia-regular.eot');
  src: url('gogoia-regular.eot?#iefix') format('embedded-opentype'),
    url('gogoia-regular.woff2') format('woff2'),
    url('gogoia-regular.woff') format('woff'),
    url('gogoia-regular.ttf') format('truetype'),
    url('gogoia-regular.svg#gogoiaregular') format('svg');
  font-weight: normal;
  font-style: normal;
}

我是 GitHub 的新手,我不知道要更改什么才能使这些字体正常工作.

I'm new at GitHub and I have no idea what to change to make these fonts work.

推荐答案

我也遇到了这个问题.我的字体在本地可以正常工作,但在 GitHub 上似乎无法正确使用.

I had this problem as well. I had fonts working properly locally, but couldn't seem to get it right on GitHub.

我想出了如何做到这一点:gitHub.io 页面的根目录似乎与本地根目录不同,这导致字体位于错误的文件夹中.

I figured out how to do this: The root of the gitHub.io page appears to be different than the local root directory, which leads to fonts in the wrong folder.

这是我的代码:

@font-face {
    font-family: F16;
    src: url("../SubSkipper/F16_Panel Font.ttf") format('truetype');
    font-weight: bold;
    font-style: normal;
}

SubSkipper 是我的项目名称,.ttf 字体位于明显的根目录中,我的意思是:SubSkipper/".

SubSkipper is the name of my project and the .ttf font is in the apparent root directory what I mean by this is: "SubSkipper/" .

路径 ../ 返回一级,然后打开本地出现的项目根目录(SubSkipper).

The path ../ goes back one level, then opens the root directory (SubSkipper) of the project as it appears locally.

这篇关于将自定义字体添加到 GitHub 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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