FreeType 2.7 - Superb Linux Font Quality
In the first decade of September , FreeType version 2.7 was released without fanfare and hype , and this event can undoubtedly be called a holiday on the street of Linux, FreeBSD, NetBSD, ReactOS and other comrades. Let's try to figure out why we have such unbridled fun.
FreeType is an open source C library that is used to rasterize fonts and operations on them. The new version uses the TrueTypev40 instruction processing algorithm by default .

This allowed us to achieve high-quality sub-pixel smoothing of fonts, as in Microsoft DirectWrite/ClearType, but in fact, no sub-pixel smoothing is used . In addition, the v40 Infinalityalgorithm renders faster , which was used in the previous v38 algorithm, while the final result is no worse.
Infinality, patents and SH
Historically, there have been two font problems in Linux. Firstly , this is a minefield of Microsoft and Apple patents, which is why the developers painfully walked around workarounds. In part, a set of patchesInfinality solved this problem , but the price was a low speed and an overly complicated code. In addition, according to the maintainer, the FreeTypedeveloper has Infinalitylost interest in his project.
Let's take a closer look at these patents. On May 10, 2010, three Apple patents for bytecode TrueTypefont smoothing expired . Now there is no need to disable its use by default.
Patent US5155805:
Method and apparatus for moving control points in displaying digital typeface on raster output devices
Patent US5159668:
Method and apparatus for manipulating outlines in improving digital typeface on raster output devices
Patent US5325479:
Method and apparatus for moving control points in displaying digital typeface on raster output devices
But 9 more ClearTypeMicrosoft patents remain valid.
Patent US6239783:
Weighted mapping of image data samples to pixel sub-components on a display device
Patent US6243070:
Method and apparatus for detecting and reducing color artifacts in images
Patent US6282327:
Maintaining advance widths of existing characters that have been resolution enhanced
Patent US6307566:
Methods and apparatus for performing image rendering and rasterization operations
Patent US6393145:
Methods apparatus and data structures for enhancing the resolution of images to be rendered on patterned display devices
Patent US6421054:
Methods and apparatus for performing grid fitting and hinting operations
Patent US6624828:
Method and apparatus for improving the quality of displayed images through the use of user reference information
These patents can be divided into three conditional categories:
- showing pictures when information is displayed at the level of individual LCD subpixels, instead of solid pixels
- displaying the same pictures after applying various filters, for example, to suppress color border artifacts
- handling dimensions and distances in the colorful world of subpixels
And that’s not all, there are other patents. The beauty of the situation is that Microsoft and Apple have signed a cross-licensing agreement , while developers FreeTypeand their open source software workers must heroically overcome SH obstacles.
The value of these patents is highly doubtful. Immediately after Microsoft patented ClearType, doubts arose about their eligibility and novelty, moreover, they wrote about this in the New York Times , not at an unknown random forum. One of the active whistleblowers Steve Gibson writes on his website that ClearType is a well-forgotten technology that Steve Wozniak patented 20 years ago for Apple II. There is no significant breakthrough in technical thought in sight, and therefore there is no intellectual property .
Thus, Microsoft's 'ClearType' application of sub-pixel text rendering does not represent the dramatic breakthrough that they claim and it can not be the valid subject for intellectual property acquisition.
Unfortunately, US patent law is structured in such a way that all this remains a conversation in favor of the poor . It is good or bad, but there is a patent, which means that the rest must pay money for its use.

I allow myself a little pathos. So far, Microsoft is in no hurry to give ClearType patents to the open source community, as Adobe did with the OpenType/CFFengine. It's good to remember this when we once again see the Microsoft slogan as the heart of Linux . Following the example of US President Reagan, I want to exclaim: "Mr. Nadella, if Microsoft loves Linux, destroy these patent walls!"
New rendering for TrueType
The legacy of software font rendering algorithms for CRT monitors of the 90s. of the last century is the second Linux font problem. The TrueTypefont family was born in the era of granular monitors with cathode ray tubes. In Windows 95 screen shots, pixels climb from the text. Each individual glyph tightly hammered into a grid of pixels. Microsoft has invested a lot of man-hours in this business, calculating and optimizing glyphs for various sizes, so that the so-called. the main web fonts ( Arial, Times New Roman, Courier Newetc.) on the screen looked decent.
Sisyphean labor, however, had consequences. The new era of LCD monitors has come and it turned out that the old TrueTypeinstructions must be reprogrammed in order to use these new features or at least to ensure that the fonts are displayed correctly. There is no need to fasten each glyph to a grid of full pixels; instead, they can be fastened to one of the three subpixels, even to parts of them, and a much better image can be achieved due to such subpixel smoothing. Soundly judging that rewriting all the old baggage of TrueTypeinstructions was unrealistic, MS came up with asymmetric over-sampling and compatibility mode, which used a lot of dashing tricks and crutches from the instructions of the old fonts. Thus, the old fonts could to some extent take advantage of the increased multiple horizontal resolution.
The developers FreeTypedecided not to block this garden and ignored the compatibility mode . This of course had consequences. New fonts, trained for crutch compatibility mode and asynchronous over-sampling, looked crooked.

However, there was a hero who went the hard way and implemented in Infinalityall of the above spaghetti old and new instructions. For some time the FreeTypev38 interpreter included a set of patches Infinality, but then the code was removed in favor of the v35 interpreter. The developer Infinalitytruly embarked on an impossible mission - to make the fonts look better than in Windows, and so that they can be finely tuned.
Here is the core secret to making fonts render like through DirectWrite / ClearType on Windows: There actually is no subpixel hinting going on here. Shock. The code simply ignores all horizontal hinting instructions.
As a result, having deleted Infinality, the maintainer FreeTypeopted for simplicity and cleanliness of the code . This is how the TrueTypev40 instruction processing algorithm appeared . Its principle is as simple as a penny — completely ignoring all horizontal smoothing instructions . No subpixel smoothing. Much less labor, and the result is practically the same. At the same time, the problem with glyph pitch and inter-character distances in old untrained fonts is solved.
How to achieve font harmony with FreeType 2.7
The good news is that you don’t need to do anything for this, the updates themselves will appear in the repository of your Linux or BSD distribution. Just upgrade to the new version and restart X.Org Server. Customize FontConfigto taste. And the bad news is that you want it right now, and waiting a few days or weeks is sometimes hard. Well, especially impatient users can themselves build a new version from the sources or install using a regular package installer. In my Gentoo FreeType 2.7has not stabilized yet.
$ eix freetype
$ [I] media-libs/freetype
Доступные версии: (2) 2.5.5^d 2.6.3-r1^d ~2.6.5^d ~2.7-r1^d
{X +adobe-cff auto-hinter bindist bzip2 (+)cleartype_hinting debug doc fontforge harfbuzz infinality png static-libs utils ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32"}For a conservative Debian, you probably have to wait for the next release, and Ubuntu users are doing fine with fonts, they have nowhere to rush.