如何在Ubuntu中安装Arial字体(以及其他Windows字体)?

如何在Ubuntu中安装Arial字体?
我找到了许多在Ubuntu中安装字体的方法,但是我没有找到任何适合在Ubuntu中安装(特别是)Arial字体的正确方式或方法。

3sudo apt-get install ttf-mscorefonts-installer - A.B.
6个回答

只需运行
sudo apt install ttf-mscorefonts-installer
sudo fc-cache -f

在终端中执行。
之后,进行检查。
fc-match Arial

1使用sudo apt install fontconfig命令来安装字体配置,然后可以使用sudo fc-cache -ffc-match Ariel命令。 - user2942
请参考下面的@barsmaga解决方案...在安装字体之前,可能需要接受最终用户许可协议(EULA),以使其正常工作。 然后执行以下命令:echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | sudo debconf-set-selections,接着执行sudo apt-get install -y ttf-mscorefonts-installer --reinstall - undefined
谢谢。这个在22.04上有效。 - undefined

由于在Ubuntu 18.04中提到的ttf-mscorefonts-installer机制仍然存在问题,并且我找不到适合的镜像服务器来修复它,因此我建议使用这个手动机制来安装完全相同的字体。
  1. 安装 cabextract,这是一个解压自解压 .exe 文件的工具:

    sudo apt install cabextract
    
  2. 通过 this page 下载提供的字体包(还要注意那里的最终用户许可协议):

    wget https://www.freedesktop.org/software/fontconfig/webfonts/webfonts.tar.gz
    
  3. 进行两次解压:

    tar -xzf webfonts.tar.gz
    cd msfonts/
    cabextract *.exe
    
  4. 将字体移动到您的用户目录以安装其他字体:

    cp *.ttf *.TTF ~/.local/share/fonts/
    
  5. 重新启动您想要使用这些字体的软件,它们应该已经可以使用了。


4这个在Ubuntu 18.04上可以运行。在你运行cp *.ttf *.TTF ~/.local/share/fonts/之前,确保你在那里创建或拥有/font目录。 - MAPK
在Ubuntu 19.04上也能正常工作。 - jfaccioni

我一直在获取 LiberationSans-Regular.ttf: "Liberation Sans" "Regular" 以便在 sudo fc-match Arial 中使用。
所以我尝试以下步骤使其正常工作:
1)创建一个目录来下载字体:sudo mkdir ~/ms-fonts/
2)cd ~/ms-fonts/
3)手动下载字体:
wget http://downloads.sourceforge.net/corefonts/andale32.exe
wget http://downloads.sourceforge.net/corefonts/arial32.exe
wget http://downloads.sourceforge.net/corefonts/arialb32.exe
wget http://downloads.sourceforge.net/corefonts/comic32.exe
wget http://downloads.sourceforge.net/corefonts/courie32.exe
wget http://downloads.sourceforge.net/corefonts/georgi32.exe
wget http://downloads.sourceforge.net/corefonts/impact32.exe
wget http://downloads.sourceforge.net/corefonts/times32.exe
wget http://downloads.sourceforge.net/corefonts/trebuc32.exe
wget http://downloads.sourceforge.net/corefonts/verdan32.exe
wget http://downloads.sourceforge.net/corefonts/webdin32.exe

4) 运行 sudo dpkg-reconfigure ttf-mscorefonts-installer 并按照说明进行操作。当被询问时,请使用字体下载的完整路径,例如 /home/root2/ms-fonts/

5) 运行 sudo fc-cache

6) 检查安装是否成功:sudo fc-match Arial

希望这能帮到您。


你可以简单地下载这些文件并提取出所有的 .ttf 文件,然后将它们移动到 ~/.local/share/fonts 目录。 - Alex Jones
顺便说一句,上面的答案在基于Ubuntu 16.04的Elementary OS 0.4.1上没有起作用。 - Alex Jones
在Ubuntu 22.04上,对我有效的唯一方法是... - Daniel Loureiro

我在准备Docker文件时寻找类似问题的解决方案。
当您使用相同的命令安装字体时:
DEBIAN_FRONTEND="noninteractive" apt-get -y ttf-mscorefonts-installer

没有应用许可协议,也没有安装Arial和其他字体!

您可以使用以下解决方案:

echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections
apt-get install -y ttf-mscorefonts-installer

你可以使用以下命令来检查结果:
fc-match Arial 

1非常感谢!这终于解决了我的问题! echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | sudo debconf-set-selections sudo apt-get install -y ttf-mscorefonts-installer --reinstall fc-match Arial - undefined
1我可以确认我的问题最初是通过@barsmanga的答案解决的。然而,问题又出现了,后来通过@igormcoelho建议使用--reinstall来解决。 - undefined

其他答案中提到的ttf-mscorefonts软件包包含了非常有限的字体选择,而且它们的版本相对较旧。
为了获得更好的、最新的字体选择,你可以从Windows安装中提取它们。微软自己提供了免费的Win 11虚拟机映像,表面上是为了“在MS Edge上测试网站”,你可以用它来做这个。
以这种方式获取的字体分发可能是非法的,但是自己使用它们可能是可以的。
  1. 在这里获取一个镜像here,选择"VirtualBox"。

    下面的文件名将根据虚拟机镜像版本而有所不同。

  2. unzip WinDev2301Eval.VirtualBox.zip - 这可能需要一些时间

  3. tar -xf 'WinDev2301Eval.ova' - 这可能需要一些时间

  4. sudo apt install libguestfs-tools
    sudo mkdir /mnt/foo
    sudo guestmount -a 'WinDev2301Eval-disk001.vmdk' -i --ro /mnt/foo
    sudo cp -r /mnt/foo/Windows/Fonts/ .
    sudo umount /mnt/foo
    sudo rm -r /mnt/foo
    sudo mv Fonts WindowsFonts
    
现在你应该在当前目录下有一个名为WindowsFonts的文件夹,其中包含你想要的所有字体。
  • 要为所有用户安装字体,请将其复制到/usr/local/share/fonts

  • 要仅为自己安装字体,请运行sudo chown -R "$USER:$USER" WindowsFonts以更改所有者为你自己,然后将该目录复制到~/.local/share/fonts/


按照以下步骤操作:
1. 如果你使用的是Mint系统,打开软件管理器;如果你使用的是Ubuntu系统,打开Ubuntu软件中心。 2. 搜索“ttf-mscorefonts”。 3. 安装它。

无法确认这个答案适用于Ubuntu 19.04。 - MERose