lartpang / LinuxNote

:penguin: Store some notes about linux.
12 stars 1 forks source link

Ubuntu安装Windows的字体 #25

Open lartpang opened 5 years ago

lartpang commented 5 years ago

Ubuntu安装Windows的字体

image

Christian Cawley is Deputy Editor for Security, Linux, DIY, Programming, and Tech Explained. He also produces The Really Useful Podcast and has extensive experience in desktop and software support. A contributor to Linux Format magazine, Christian is a Raspberry Pi tinkerer, Lego lover and retro gaming fan.

问题介绍

Ubuntu下没有一些Windows上常用的字体,导致办公软件里字体缺失,没法调整,不方便,所以这里找到了一篇关于这个问题的文章:How to Install Microsoft Text Fonts in Ubuntu Linux。这里记录下。

造成原因

估计是因为字体版权原因吧。

解决方案

Windows-based fonts don’t appear by default on Linux-based systems like Ubuntu. In most cases, this isn’t a huge problem, but if you want to improve compatibility between word processors, then it might be useful to have Microsoft fonts on your Ubuntu PC.

For instance, you might be a student, using a Windows PC at college, and your own Ubuntu device at home — or vice versa. You might have other versions for importing Microsoft fonts into Ubuntu, though. Perhaps you want the Verdana or Times New Roman fonts on your Ubuntu desktop. Or you might be working on some DTP or artistic project, and need some Microsoft-originated fonts.

Either way, this is a straightforward change to make to your Ubuntu Linux computer.

Microsoft TrueType Fonts

Back in 1996, Microsoft released a package of fonts, called “TrueType core fonts for the web” with a licence giving any user permission to install them. Naturally, in true Microsoft style, the aim was for their fonts to become dominant.

Although cancelled six years later, the font pack is still available, and includes:

You’ll probably recognize most of these; Times New Roman used to be the default text for Word (replaced by Calibri in 2007), while Impact is the sort of font that appears on posters around the word. And as for webdings…

Of course, you might not require any of these fonts. After all, Ubuntu and other distributions already feature a wide selection of adequate substitute fonts thanks to the inclusion of the Red Hat “Liberation Fonts” package. They’re not completely identical, but these fonts do use the same widths as the Microsoft fonts they replace.

Which is why you might want the real thing.

In short, if Microsoft fonts were installed in Linux, your Linux apps — anything ranging from LibreOffice Writer (which takes seconds to install) to GIMP — would present them as options. LibreOffice could benefit from it, especially if you’re struggling to transition from Microsoft Word.

Install Microsoft TrueType Fonts in Ubuntu

In older versions of Ubuntu, it was possible to install these fonts using the Software Center, but this is no longer an option. Fortunately, you can just use the command line instead.

Launch the terminal, then use this command to install the ttf-mscorefonts-installer package.

sudo apt-get install ttf-mscorefonts-installer

Unusually, you’ll be prompted to agree to a Microsoft EULA (here’s how to understand an EULA). Now, this is the bristly bit: you might have reservations about this. Although these TrueType fonts—different from OpenType fonts—have been made available for free, you’ll notice that they’re not open source. Also, the EULA has “Microsoft” pasted all over it.

But, if you aren’t a pure open source user, carry on, scrolling through the EULA with the Page Up/Down keys. Use Tab or the arrow keys to select Yes and agree to the EULA with Enter.

Once downloaded into your system, the fonts will be configured so that they can be used in the usual apps.

If you’re using a different Linux distribution, you may find that the ttf-mscorefonts-installer package isn’t available. However, an alternative should be open to you, under a slightly different name. A few minutes of research should turn this up.

Running a Dual Boot Windows and Linux System? Try This!

If you have both Windows and Ubuntu operating systems installed on the same PC, you don’t even need to download the fonts, as you already have them installed in Windows. This means that you can copy the fonts into Ubuntu.

More importantly, this is a great way to pull all manner of modern, cool fonts from Windows into Linux. ClearType fonts like Calibri can be added to your system this way.

In Ubuntu, you should be able to easily browse the partition where Windows is installed, using your default file manager. Next, you’ll need to copy fonts from the directory in the Windows partition to your Linux fonts directory.

mkdir /usr/share/fonts/WindowsFonts

Then copy the contents of the mounted Windows drive fonts directory into the WindowsFonts location:

cp /Windowsdrive/Windows/Fonts/* /usr/share/fonts/WindowsFonts

如果你用了shell extensions中的User themes,那么直接将这里的/usr/share/fonts/WindowsFonts改为/home/username/.local/share/fonts即可

Change permissions for the directory and its contents:

chmod 755 /usr/share/fonts/WindowsFonts/*

Then regenerate the Linux fontconfig cache with

fc-cache

That’s all there is to it.

All Done? Test Your Fonts

As with anything, it’s worth checking that the fonts have been installed. The easiest way to check is to open LibreOffice Writer, or find an art package and create a text box. If they don’t look right, you may need to enable smoothing. In Ubuntu, this is handled by default. (On other Linux operating systems, you can fix it by checking the font settings (typically in the Preferences screen) and find the option to enable smoothing.)

Once you’re happy with the fonts, you can even set your favorite as a default option in LibreOffice writer. With the word processor running, open Tools > Options > LibreOffice Writer > Basic Fonts (Western) and select your preferred font. Click OK to confirm; all future documents you create will use these defaults.

For wider use of the new fonts, use Unity Tweak Tool (or GNOME Tweak Tool, or whatever suits your desktop environment) to apply the new fonts.

And if neither of the above methods worked for you, perhaps the slightly easier option of installing Microsoft Office on Linux might solve your missing Microsoft fonts problem?

参考链接

https://www.makeuseof.com/tag/how-to-install-microsoft-core-fonts-in-ubuntu-linux/