July 26, 2023

新字体


最近翻阅网页,偶然翻到了谢益辉大佬的博客,发现他的引用部分字体是楷体。而且著名古籍网站书格的引用部分也是楷体。我认为这比我单纯的引用原网页预设的字体要美观些,后来自己研究了下,改了预设字体并成功了。

1.找到设置字体文字部分(ノ*・ω・)ノ

1-1. fonts.css的介绍

我发现这些预设字体通过font.css前端代码渲染,具体是:

.post blockquote, .newsletter blockquote, .home blockquote {
  font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, 'STKaiti', 'KaiTi', '楷体', 'SimKai', 'DFKai-SB', 'NSimSun', serif;
}
blockquote {
  font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, 'STKaiti', 'KaiTi', '楷体', 'SimKai', 'DFKai-SB', 'NSimSun', serif;
}
code {
  font-family: Consolas, Courier, "Courier New", 'STKaiti', 'KaiTi', 'SimKai', monospace;
}
pre, code {
  font-size: .95em;
}

其中.post blockquote, .newsletter blockquote, .home blockquote分别指页面,通讯页,以及主页网站引用内容。而blockquote指代文字引用内容,code指代代码块引用内容,font-family是字族。blockquote首选外文字体是Palatino Linotype字体,中文则是KaiTi。而code外文首选是Consolas字体,中文字体是KaiTisize为字体大小。

1-2.引入代码内容

我是这样做的,先把fonts.css 放到static/css/fonts.css路径下,再到layouts/partials/header中引入链接:

<link rel="stylesheet" href="https://www.zaqizaba.xyz/css/fonts.css" integrity="sha384-FfYjjWEyBTKb6N3GbKPCUIpvhFKlO6lL/1ZSElPI920EmGuDz7dYiNZ37U0ian6Q" crossorigin="anonymous"></script>

注意放到headhead' 之间,然后就可以看到文字块和代码块的字体为预设字体了。

2.试一试(Φ皿Φ)

2-1. 北宋年间,苏轼因 “乌台诗案” 被贬久居黄州期间,思想由郁恨到洒脱。于是写出了著名的词作 《定风波·莫听穿林打叶声》

定风波·莫听穿林打叶声

(宋)苏轼

三月七日,沙湖道中遇雨,雨具先去,同行皆狼狈,余独不觉。已而遂晴,故作此。

莫听穿林打叶声,何妨吟啸且徐行。竹杖芒鞋轻胜马,谁怕?一蓑烟雨任平生。

料峭春风吹酒醒,微冷,山头斜照却相迎。回首向来萧瑟处,归去,也无风雨也无晴。

定风波·莫听穿林打叶声

2-2. 1863年11月19日,也就是美国内战中葛底斯堡战役结束的四个半月后,林肯在宾夕法尼亚州葛底斯堡的葛底斯堡国家公墓(Gettysburg National Cemetery)揭幕式中发表此次演说,哀悼在长达五个半月的葛底斯堡之役中阵亡的将士,此演说即为著名的 《葛底斯堡演说》 ,全文如下:

“speaker:Abraham Lincoln"“adders:Location: Gettysburg, Pennsylvania, USA"“time:Nov. 19, 1863”

Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.

But, in a larger sense, we can not dedicate—we can not consecrate—we can not hallow—this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion—that we here highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom—and that government of the people, by the people, for the people, shall not perish from the earth.


参考:1.谢益辉博客2.书格

本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。

©阿波尔的博客2019-2024