Windows 和 Linux 上安装 TTF 字体的方法

简介: 在之前的文章中,我们是通过引入字体文件的方法解决了平台字体兼容性的问题

4.png


前言


在之前的文章中,我们是通过引入字体文件的方法解决了平台字体兼容性的问题。


有同学提出了一个问题:为什么要通文件引入的方式解决问题?难道不考虑带宽问题吗?


其实,我们一开始考虑的方案是将字体文件安装在运行项目的每台客户机上,但是,因为使用项目的客户机实在太多,每台都装的话太过繁琐,所以就采用了文件引用的方式。


但是,我们将本地安装字体的方案作为备用方案,以下是 Windows 和 Linux 系统上安装字体的步骤。


本文所用的字体文件为 .ttf 格式。


Windows 安装字体


方法一


直接把字体文件复制到系统文字的文件夹里。打开C盘—Windows—Fonts文件夹,把字体文件复制到Fonts文件夹里面。


方法二


直接在字体文件右键,点安装


3.png


安装成功后:


2.png


Linux 安装字体


第一步:准备字体文件,这里用的是 .ttf 格式文件。


第二步:打开 /usr/share/fonts 目录,新建一个文件夹,名字随便取,例如:my_fonts 。


第三步:将之前准备的 .ttf 字体文件拷贝到这个目录下(有可能需要sudo的权限)。


第四步:进入到创建的字体文件目录下:cd /usr/share/fonts/my_fonts


第五步:依次执行以下指令:


sudo mkfontscale
sudo mkfontdir
sudo fc-cache


此时文件夹会多两个文件:fonts.dir 以及 fonts.scale,安装成功:


1.png


第六步:查看是否安装成功,执行指令:fc-list


0.png


总结


以上就是 Windows 和 Linux 系统上安装 .ttf 字体文件的方法步骤。


~ 本文完,感谢阅读!


学习有趣的知识,结识有趣的朋友,塑造有趣的灵魂!




相关文章
|
6天前
|
安全 Linux 网络安全
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
91 2
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
|
6天前
|
JSON 安全 Linux
Nexpose 8.22.0 for Linux & Windows - 漏洞扫描
Nexpose 8.22.0 for Linux & Windows - 漏洞扫描
52 1
Nexpose 8.22.0 for Linux & Windows - 漏洞扫描
|
6天前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
122 1
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
|
8天前
|
NoSQL IDE MongoDB
Studio 3T 2025.17 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.17 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
71 1
Studio 3T 2025.17 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
12天前
|
安全 Ubuntu Linux
Nexpose 8.21.0 for Linux & Windows - 漏洞扫描
Nexpose 8.21.0 for Linux & Windows - 漏洞扫描
75 4
Nexpose 8.21.0 for Linux & Windows - 漏洞扫描
|
8天前
|
安全 Linux iOS开发
SonarQube Server 2025 Release 5 (macOS, Linux, Windows) - 代码质量、安全与静态分析工具
SonarQube Server 2025 Release 5 (macOS, Linux, Windows) - 代码质量、安全与静态分析工具
71 0
SonarQube Server 2025 Release 5 (macOS, Linux, Windows) - 代码质量、安全与静态分析工具
|
8天前
|
安全 Linux iOS开发
Tenable Nessus 10.10 (macOS, Linux, Windows) - 漏洞评估解决方案
Tenable Nessus 10.10 (macOS, Linux, Windows) - 漏洞评估解决方案
85 0
Tenable Nessus 10.10 (macOS, Linux, Windows) - 漏洞评估解决方案
|
16天前
|
安全 Linux 网络安全
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
278 0
|
6天前
|
数据管理 Linux iOS开发
Splunk Enterprise 9.4.5 (macOS, Linux, Windows) - 机器数据管理和分析
Splunk Enterprise 9.4.5 (macOS, Linux, Windows) - 机器数据管理和分析
31 0
|
12天前
|
运维 iOS开发 Windows
windows电脑备案ios APP获取公钥和证书指纹Sha-1值的方法
在阿里云进行APP备案、在备案IOS端的环节的时候,发现需要我们将p12证书安装在电脑上,再用xcode或或钥匙串访问来获取这个证书的公钥和sha-1值。 但是大部分开发uniapp应用的同学们,或者进行发布的运维人员的电脑都是windows,无法按照阿里云的教程来获取ios的公钥和sha-1。备案就被卡主了。 这里介绍下另一个方法,就是使用香蕉云编来在线上传证书获取。如下图所示,打开香蕉云编后,找到下图这个功能
153 0