摘要
本文主要讲述了:
- 什么是思源宋体
- 如何在 CSS 中使用思源宋体字体家族
正文
什么是思源宋体
思源宋体,英文名为 Source Han Serif,是继思源黑体之后,由 Adobe 和 Google 领导的技术团队于 2017 年 4 月 3 日推出的一款开源的有衬线的字体家族。
思源宋体支持 4 种文字:
思源宋体从细到粗共有 7 种字重:
- ExtraLight
- Light
- Regular
- Medium
- SemiBold
- Bold
- Heavy
其中,每一种字重都包括 65535 个字形,思源宋体一共包含 458745 个字符。
思源宋体的字体文件在 Github 上开放下载(注意:在release分支上),中国大陆地区的用户也可以在清华大学镜像站进行下载。
如何在 CSS 中使用思源宋体字体家族
示例:
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 
 | <!DOCTYPE html><html lang="en">
 <head>
 <meta charset="UTF-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 <title>Document</title>
 </head>
 <body>
 
 <div class="control-group">思源宋体字体家族</div>
 <hr />
 
 <div class="source-han-serif">
 <div>思源宋体字体家族</div>
 <div>思源宋体字体家族</div>
 <div>思源宋体字体家族</div>
 <div>思源宋体字体家族</div>
 <div>思源宋体字体家族</div>
 <div>思源宋体字体家族</div>
 <div>思源宋体字体家族</div>
 </div>
 <style>
 
 .control-group {
 font-size: 64px;
 }
 
 
 .source-han-serif > div {
 font-size: 64px;
 }
 .source-han-serif > div:nth-child(1) {
 font-family: 'Source Han Serif ExtraLight';
 }
 .source-han-serif > div:nth-child(2) {
 font-family: 'Source Han Serif Light';
 }
 .source-han-serif > div:nth-child(3) {
 font-family: 'Source Han Serif';
 }
 .source-han-serif > div:nth-child(4) {
 font-family: 'Source Han Serif Medium';
 }
 .source-han-serif > div:nth-child(5) {
 font-family: 'Source Han Serif SemiBold';
 }
 .source-han-serif > div:nth-child(6) {
 font-family: 'Source Han Serif';
 font-weight: bold;
 }
 .source-han-serif > div:nth-child(7) {
 font-family: 'Source Han Serif Heavy';
 }
 </style>
 <script>
 window.addEventListener('load', function () {
 document.body.appendChild(document.createElement('hr'));
 const foo = document.createElement('div');
 foo.textContent = navigator.userAgent;
 document.body.appendChild(foo);
 document.body.appendChild(document.createElement('hr'));
 });
 </script>
 </body>
 </html>
 
 | 
测试结果:
| System | Browser Name | Browser Version | Result | 
| Windows 10 | IE | 11.0 | 测试通过 | 
| Windows 10 | Firefox | 78.0 | 测试通过 | 
| Windows 10 | Edg | 83.0.478.58 | 测试通过 | 
| Windows 10 | Chrome | 83.0.4103.116 | 测试通过 | 
参考资料
        
          
        
        
          
          
  本文对你有帮助?请支持我
  
  
    
       支付宝
      支付宝
    
    
       微信
      微信