问题 更改默认的github代码字体


我对github的默认代码字体Courier New感到不满意。我想将它更改为Monaco,这是我首选的等宽字体。是否可以更改我的github代码字体?如果有,怎么样?


3480
2017-09-10 14:07


起源

当我作为我未定义的人时,我会尝试在没有该字体的情况下在github上查看你的项目(你知道,就像在非苹果设备上一样)会发生什么?
我希望在我的浏览器中看到摩纳哥的github代码。这些设置不应影响任何其他用户。他们仍然会在Courier New中看到它(或者他们配置的任何字体(假设这样的配置是可能的))。 - missingfaktor


答案:


铬的解决方案:

  1. 安装造型师@ https://chrome.google.com/webstore/detail/pabfempgigicdjjlccdgnbmeggkbjdhd

  2. 安装userscript @ http://userstyles.org/styles/39502/github-a-different-font-stack-for-code-listings

请享用!


7
2018-03-14 19:29



哇,这很有效。非常感谢! :-) - missingfaktor
在Android上不起作用---字体特别难以阅读。 - rwst


没有Github设置来执行此操作,您必须考虑编写自己的自定义样式表。这将是特定于浏览器的,您必须手动在所有计算机上同步它,因此它并不理想。


4
2017-09-10 14:55





如果您使用兼容的浏览器,您可以使用greasemonkey脚本来定位github.com上的代码块,并使用monaco而不是courier new来呈现它们。


2
2017-09-10 22:00





我在Firefox中遇到同样的问题,所以这里是我正在使用的Greasemonkey的用户脚本。只需将其粘贴到脚本编辑器窗口中即可。

// ==UserScript==
// @name        Github font changer
// @namespace   local.greasemonkey.githubfontchanger
// @include     https://github.com/*
// @version     1
// @grant       none
// ==/UserScript==

var fontdef ="Monaco, Monospace ! important"; // Set your font here.

// Function helper to inject css
function addGlobalStyle(css) {
    var head, style;
    head = document.getElementsByTagName('head')[0];
    if (!head) { return; }
    style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = css;
    head.appendChild(style);
}

// Apply the font-family definition to code styles.
addGlobalStyle(
  '.blob-code { font-family: ' + fontdef + '; } ' +
  '.blob-num { font-family: ' + fontdef + '; } ' +
  '');

0
2018-06-24 08:56