我对github的默认代码字体Courier New感到不满意。我想将它更改为Monaco,这是我首选的等宽字体。是否可以更改我的github代码字体?如果有,怎么样?
我对github的默认代码字体Courier New感到不满意。我想将它更改为Monaco,这是我首选的等宽字体。是否可以更改我的github代码字体?如果有,怎么样?
铬的解决方案:
安装造型师@ https://chrome.google.com/webstore/detail/pabfempgigicdjjlccdgnbmeggkbjdhd
安装userscript @ http://userstyles.org/styles/39502/github-a-different-font-stack-for-code-listings
请享用!
没有Github设置来执行此操作,您必须考虑编写自己的自定义样式表。这将是特定于浏览器的,您必须手动在所有计算机上同步它,因此它并不理想。
如果您使用兼容的浏览器,您可以使用greasemonkey脚本来定位github.com上的代码块,并使用monaco而不是courier new来呈现它们。
我在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 + '; } ' +
'');