楔子:Jupyter Notebook默认的显示字体是宋体,在高分屏下视觉效果差,看着不舒服,想优化一下,结果一堆推荐安装主题插件的,比如jupyter-themes,某乎上对这类问题的回答,ok,我就是想改个样式,你让我装一个插件?!好嘛,插件装着装着又有各种乱七八糟的问题出现,实在是浪费时间。 本着有问题就解决问题,不要拔个萝卜带出一大堆泥,这里给出一个最简单的办法。
在 C:\User\用户名.jupyter\custom路径下找一个custom.css文件(如果没有,可以手动新建)。 custom.css文件里写入下面内容:
div.notebook {font-family: Cambria, "Microsoft YaHei Mono", "Microsoft YaHei";}
div.CodeMirror pre {font-family: Cambria, "Microsoft YaHei Mono", "Microsoft YaHei"; font-size: 10pt;}
div.CodeMirror-lines {font-family: Cambria, "Microsoft YaHei Mono", "Microsoft YaHei"!important; font-size: 10pt !important;}
div.output_area pre {font-family: Cambria, "Microsoft YaHei Mono", "Microsoft YaHei"; font-size: 10pt;}
div.input_prompt {font-family: Cambria, "Microsoft YaHei Mono", "Microsoft YaHei"; font-size: 10pt;}
div.out_prompt_overlay {font-family: Cambria, "Microsoft YaHei Mono", "Microsoft YaHei"; font-size: 10pt;}
div.prompt {font-family: Cambria, "Microsoft YaHei Mono", "Microsoft YaHei"; font-size: 10pt;}
span.cm-comment {font-family: Cambria, "Microsoft YaHei Mono", "Microsoft YaHei" !important; font-style:normal !important;}
code {font-family: Cambria, "Microsoft YaHei Mono", "Microsoft YaHei";}
保存即可,jupyter notebook不用重启,刷新下页面,样式就生效了。想调整字体的话可以修改font-size参数值。 完美解决!
|