WEBVTT 00:00:06.280 --> 00:00:09.300 Okay, good morning everyone. 00:00:09.300 --> 00:00:12.540 I'm going to talk about the Linux Font Rendering stack, 00:00:12.860 --> 00:00:18.680 and that is what I learned the last four and a half years. 00:00:18.680 --> 00:00:22.080 I worked at the city administration of Munich. 00:00:22.920 --> 00:00:28.400 For introduction to font rendering, 00:00:30.320 --> 00:00:34.780 I can say writing is the most used interface, 00:00:34.780 --> 00:00:39.080 or probably the most used interface between humans and the machines. 00:00:39.080 --> 00:00:45.700 So all of you probably use it everyday on your computer. 00:00:48.500 --> 00:00:52.780 Screen text is replacing text on paper more and more 00:00:52.780 --> 00:00:56.820 and this is still an ongoing process. 00:01:00.620 --> 00:01:09.160 The way from a string in a computer to display text is surprisingly complex, 00:01:09.160 --> 00:01:14.640 And writing in itself is quite profound. 00:01:14.640 --> 00:01:24.960 For example, it's influenced by history so probably all, or at least most, 00:01:24.960 --> 00:01:30.680 writing systems are derived from some pictograph writing systems. 00:01:31.140 --> 00:01:34.440 This is also true for Roman letters. 00:01:36.080 --> 00:01:43.980 And also the Roman letters themselves, they changed a lot since 2000 years ago. 00:01:43.980 --> 00:01:51.120 In the Roman Empire they used some different letters than we use now. 00:01:51.120 --> 00:01:56.980 So the goal of this talk is to raise awareness of font rendering in computing, 00:01:56.980 --> 00:02:00.740 with the focus on the Linux desktop. 00:02:04.740 --> 00:02:11.680 Now to the history, and then I talk about typography. 00:02:13.780 --> 00:02:17.400 Text display in early computing. 00:02:17.400 --> 00:02:24.760 In early computing it was just a way to display results. 00:02:26.380 --> 00:02:29.900 Before that there were only flashing lights 00:02:29.900 --> 00:02:34.420 where you can read the results and... 00:02:35.660 --> 00:02:39.840 [audience member] ??... BT100 ?? raise your hand 00:02:43.300 --> 00:02:47.660 [Max] And the output device receives a page or a character stream, 00:02:47.660 --> 00:02:52.000 and then the presentation is the job of the output device. 00:02:52.000 --> 00:02:58.000 So for example, a typewriter or a printer or a terminal. 00:02:58.000 --> 00:03:05.780 line:1 And this is a BT100 you can see on the right side. 00:03:05.780 --> 00:03:08.340 line:1 So this is a real terminal. 00:03:13.260 --> 00:03:19.420 But going on in history there's the home computer era. 00:03:21.860 --> 00:03:25.730 In the home computer era you have fixed character sets 00:03:25.730 --> 00:03:31.840 and most of the time due to system limitations, memory limitations, 00:03:31.840 --> 00:03:35.700 you have graphics mode and text mode. 00:03:38.100 --> 00:03:46.840 In the graphics mode you can basically set the pixels more or less as you want, 00:03:46.840 --> 00:03:53.000 and in the text mode you can use fonts. 00:03:55.620 --> 00:03:59.540 The screen configuration at that time is more or less defined 00:03:59.540 --> 00:04:01.540 by the state of technology. 00:04:01.540 --> 00:04:07.740 So every screen at that time has more or less the same resolution, 00:04:07.740 --> 00:04:15.680 and that's something that the engineers of that time relied on, 00:04:15.680 --> 00:04:18.200 and also software engineers relied on. 00:04:19.660 --> 00:04:24.980 The text rendering was just using bitmap fonts. 00:04:24.980 --> 00:04:37.120 That means you have a fixed size character and you just define it pixelwise 00:04:38.780 --> 00:04:45.040 so it's some kind of hand-crafted characters. 00:04:45.040 --> 00:04:51.320 You have a given raster and then you really display 00:04:51.320 --> 00:04:54.340 these hard-defined characters. 00:04:59.520 --> 00:05:06.740 So then I need to introduce a few typography terms. 00:05:12.380 --> 00:05:16.260 First, there's glyph or a character. 00:05:21.320 --> 00:05:25.420 That's...well you can say a symbol. 00:05:26.920 --> 00:05:31.700 So I think most people can understand what that means. 00:05:31.700 --> 00:05:36.240 Then a font, this is a set of glyphs. 00:05:38.040 --> 00:05:45.320 And then we have a collection of fonts, that is called typeface or font family. 00:05:45.320 --> 00:05:53.020 Those are closely related fonts with the same visual appearance, 00:05:53.020 --> 00:05:59.920 And they differ only in slopes or widths or weights for example. 00:06:03.880 --> 00:06:12.480 Usually with typesetting, with moving letters in the printing press, 00:06:12.480 --> 00:06:25.140 you really had, for weight for example, different pieces/letters/hardware. 00:06:27.740 --> 00:06:31.460 And then the point size, or typographic unit. 00:06:32.560 --> 00:06:41.770 This is a measure of the size, and derives directly from the printing press 00:06:41.770 --> 00:06:44.560 with moving letters. 00:06:48.400 --> 00:06:56.500 There are different definitions, and what we probably all use as point size is the 00:06:56.500 --> 00:07:03.760 DTP point – desktop publishing point, 00:07:03.760 --> 00:07:18.520 where one point is defined as 1/72 inch, which is 0.3527 period millimeters. 00:07:18.520 --> 00:07:25.980 It is interesting to note that this has nothing to do with pixels. 00:07:28.600 --> 00:07:30.980 [audience] (unintelligible question) 00:07:30.980 --> 00:07:34.700 [Max] Please use the microphone if you a question. 00:07:35.900 --> 00:07:39.440 [audience] ...3257, what's the bar over the 7 mean? 00:07:39.440 --> 00:07:43.160 [Max] It means that the 7 goes on and on and on forever. 00:07:51.000 --> 00:07:58.500 So this is typography of the Latin alphabet...terminology. 00:07:58.500 --> 00:08:01.740 There's something called kerning. 00:08:02.400 --> 00:08:08.380 You can see an example of kerning on the right side. 00:08:08.380 --> 00:08:19.180 So in the printing press you have letters and they usually have a gap. 00:08:21.400 --> 00:08:29.600 To improve the readability, and to make all the text appear more uniform 00:08:31.140 --> 00:08:33.760 the typesetter reduces the gap. 00:08:35.659 --> 00:08:39.700 With moving letters they have special letter pairs... 00:08:40.679 --> 00:08:46.180 if you go on with this there are ligatures, 00:08:46.180 --> 00:08:50.620 which are replacement glyphs for close standing characters. 00:08:52.140 --> 00:08:57.300 An example of this is a double f, fi or fl. 00:08:58.300 --> 00:09:05.440 So you can see also in the slides here that double f is such a ligature. 00:09:06.320 --> 00:09:08.600 It's one connected glyph. 00:09:10.980 --> 00:09:16.480 And then there's a speciality if you reverse all of the ?? [static]. 00:09:18.120 --> 00:09:20.040 The term non-proportional font. 00:09:20.040 --> 00:09:27.300 So you have a font where very character, every glyph, has the same width. 00:09:27.300 --> 00:09:30.640 This is also called monospace font. 00:09:33.640 --> 00:09:40.820 Sometimes you distinguish half-width and full width letters. 00:09:41.480 --> 00:09:45.740 This is also something you would see on a typewriter for example. 00:09:47.440 --> 00:09:54.020 Early bitmap fonts are usually monospaced fonts. 00:09:56.440 --> 00:10:01.740 Okay, let's go to the text rendering stack. 00:10:06.520 --> 00:10:08.980 Text rendering today. 00:10:10.400 --> 00:10:15.090 In all computing nowadays, typography is introduced. 00:10:15.090 --> 00:10:24.500 So won't find many devices on the market which don't use accurate typography. 00:10:28.160 --> 00:10:32.280 Glyphs are now represented as size-independent outlines. 00:10:32.280 --> 00:10:37.520 We can see on the right side there's a font editor: Font Forge. 00:10:37.520 --> 00:10:41.900 This is the way that such fonts are created. 00:10:41.900 --> 00:10:47.160 So you can see here in the picture the outline of the "S". 00:10:49.200 --> 00:10:55.960 It's a size-independent outline and you can just use that for 00:10:55.960 --> 00:10:59.180 every kind of display. 00:10:59.180 --> 00:11:04.020 And then you do something that is called rasterization, or sampling, or rendering 00:11:04.020 --> 00:11:08.000 for displaying it at the actual display. 00:11:09.660 --> 00:11:13.760 In the past this allowed for new applications for computers. 00:11:13.760 --> 00:11:19.680 First it allowed word processing and computer-based typesetting. 00:11:21.240 --> 00:11:26.320 Before that typesetting was a very hard job. 00:11:26.740 --> 00:11:30.800 It allowed internationalization. 00:11:36.600 --> 00:11:41.500 It allows universal graphical interface which goes 00:11:41.500 --> 00:11:45.420 hand-in-hand with internationalization. 00:11:46.280 --> 00:11:52.380 Come to think of it, not so long ago it was not so common that you could 00:11:52.380 --> 00:11:58.280 buy devices where you can easily switch the language to 00:11:58.280 --> 00:12:01.680 any language you would like. 00:12:01.680 --> 00:12:05.320 This is just a recent development. 00:12:06.600 --> 00:12:15.600 So now I will give you an overview of the formats we see on Linux systems. 00:12:15.600 --> 00:12:18.880 First I talk about the bitmap formats. 00:12:18.880 --> 00:12:27.120 Today we have bitmap formats in the PC Screen Font format, 00:12:27.120 --> 00:12:28.960 PSF or PSFU. 00:12:28.960 --> 00:12:36.180 These are the fonts that are used for the Linux VT, also known as the console. 00:12:36.180 --> 00:12:45.700 Usually you can store in such a font 256 or 512 glyphs. 00:12:45.700 --> 00:12:52.540 Some of them contain a Unicode translation table. 00:12:53.800 --> 00:12:59.500 And on the other hand there are X Window System Bitmap Fonts. 00:12:59.500 --> 00:13:02.820 There are three formats: 00:13:02.820 --> 00:13:07.060 There's a Sever Normal Format (SNF). 00:13:07.060 --> 00:13:11.340 Glyph Bitmap Distribution Format (BDF). 00:13:11.340 --> 00:13:13.960 And Portable Compiled Format (PCF). 00:13:13.960 --> 00:13:22.680 Nowadays PCF is the only letter that you can find on a Linux system if so, 00:13:22.680 --> 00:13:29.160 and the first two are deprecated. 00:13:29.160 --> 00:13:40.220 And also the X Window Bitmap Fonts themselves are not very common these days. 00:13:44.560 --> 00:13:47.380 To the outline font formats. 00:13:49.020 --> 00:13:51.960 There are Postscript Formats. 00:13:53.920 --> 00:14:05.240 Postscript Formats have different versions as I would call them. It's called types. 00:14:05.240 --> 00:14:11.540 Type 1 is the one that is still relevant, to a certain degree. 00:14:11.540 --> 00:14:16.760 Those are the ones you can probably 00:14:16.760 --> 00:14:21.400 find on a standard Debian installation for example. 00:14:21.400 --> 00:14:23.880 It uses cubic bezier curves. 00:14:26.120 --> 00:14:35.760 The file format is divided into different files. 00:14:35.760 --> 00:14:39.500 So for every font you have Printer Font ASCII 00:14:39.500 --> 00:14:44.200 or a Printer Font Binary file, and you have 00:14:44.200 --> 00:14:49.120 a Print Font Metric or Adobe Font Metric file. 00:14:54.740 --> 00:15:00.900 Then you have the Truetype file format. 00:15:02.860 --> 00:15:07.700 This is more common. I guess everyone heard of that already. 00:15:08.940 --> 00:15:12.140 It uses quadratic bezier curves. 00:15:13.760 --> 00:15:21.420 It can contain optional code for TrueType Hinting Virtual Machine. 00:15:21.420 --> 00:15:25.120 What that means I will explain latter. 00:15:25.120 --> 00:15:30.740 There's a third format, the OpenType format, 00:15:30.740 --> 00:15:35.160 which has two possible glyph formats: one is TrueType, 00:15:35.160 --> 00:15:40.980 and the other is Compact Font Format, which is based on Postscript Type 2. 00:15:40.980 --> 00:15:47.880 So you can say what is new in this format, or what's the difference? 00:15:47.880 --> 00:15:51.700 Well it supports so-called Smartfonts. 00:15:53.580 --> 00:15:59.600 That means you can have language-specific ligatures or character substitutions. 00:16:01.360 --> 00:16:09.560 For example, kerning classes, which means you have a class of characters like 00:16:09.560 --> 00:16:13.520 the A and different variations. 00:16:13.520 --> 00:16:19.820 So these are A with different diacritic symbols, 00:16:19.820 --> 00:16:30.560 and you can just use one kerning class for all of those characters and don't have to 00:16:30.560 --> 00:16:37.580 invent the wheel for every A with diacritic symbols anew. 00:16:43.540 --> 00:16:50.140 Now to the font rendering techniques that I use today. 00:16:53.540 --> 00:17:02.360 This only applies to the outline fonts because well rendering bitmap fonts is 00:17:02.360 --> 00:17:11.020 obviously quite easy. You just paint the pixels that are in the bitmap. 00:17:11.020 --> 00:17:17.480 So rasterization is all about using outline fonts. 00:17:19.280 --> 00:17:24.619 The one library library that is used all over the free and open source world 00:17:24.619 --> 00:17:26.180 is FreeType. 00:17:26.180 --> 00:17:40.600 It is used on Linux system, BSD desktops, Android, and ReactOS, and some others. 00:17:40.600 --> 00:17:47.300 For example it is contained in Ghostscript and therefore in most of the printers. 00:17:49.040 --> 00:17:52.140 It's also on iOS [exhale]. 00:17:53.140 --> 00:17:59.750 So the naive rasterization algorithm would be just lay a pixel raster over the 00:17:59.750 --> 00:18:06.350 outline font, over the character you want to display, and if the center of the pixel 00:18:06.350 --> 00:18:09.900 is inside the outline then you set the color to black. 00:18:14.960 --> 00:18:19.340 The problem is the so called aliasing effect. 00:18:19.340 --> 00:18:23.820 line:1 This is what you can see in the picture below. 00:18:23.820 --> 00:18:29.760 line:1 So those are the same words, rendered at different resolutions. 00:18:29.760 --> 00:18:36.440 line:1 The left one has 10x the resolution of the right one. 00:18:38.620 --> 00:18:49.540 line:1 You can see that, for example, the 'w' is quite deformed. 00:18:49.540 --> 00:18:55.340 line:1 Or the curl of the 'g'; there's even a part missing. 00:18:55.340 --> 00:18:59.800 line:1 So you have details of the font which are lost, 00:18:59.800 --> 00:19:02.040 line:1 and you have artefacts. 00:19:04.240 --> 00:19:11.580 line:1 Somehow, especially in the early computing days you wanted to reduce those, 00:19:11.580 --> 00:19:15.480 and therefore you used a technique called hinting. 00:19:15.480 --> 00:19:20.820 This is to avoid such artefacts and improve the readability 00:19:20.820 --> 00:19:22.520 at lower resolutions. 00:19:22.520 --> 00:19:34.660 Therefore the outline is adjusted to fit the pixel raster at the rasterization. 00:19:36.900 --> 00:19:41.840 Some of the fonts can contain instructions, the so-called hints 00:19:41.840 --> 00:19:46.020 where the the name comes from: "hinting". 00:19:51.360 --> 00:19:58.860 You can see in the example here, in the picture above, 00:19:58.860 --> 00:20:07.860 that it's quite a good result. 00:20:07.860 --> 00:20:15.480 This is much more readable than the word above. 00:20:15.480 --> 00:20:22.560 However, with the use of hinting, there are also characteristics of the font lost 00:20:24.200 --> 00:20:27.540 which is obvious because if you change the outline 00:20:27.540 --> 00:20:31.160 then obviously characteristics get lost. 00:20:31.160 --> 00:20:37.260 And especially important for word processing, 00:20:37.260 --> 00:20:39.640 what you see is what you get word processing, 00:20:39.640 --> 00:20:43.680 is that the tracking of the font is changed. 00:20:45.920 --> 00:20:49.960 So tracking means the width of single characters. 00:20:49.960 --> 00:20:56.680 line:1 The picture below, this is a picture I took from LibreOffice. 00:20:56.680 --> 00:21:05.300 line:1 If you have a close look, you can see that the gap between those 'i' characters 00:21:05.300 --> 00:21:07.300 line:1 is not always the same. 00:21:08.040 --> 00:21:16.880 line:1 But if do word processing, you actually want to have a result which looks the same 00:21:16.880 --> 00:21:18.880 line:1 as on the printout. 00:21:20.480 --> 00:21:26.840 So I would recommend not to hint fonts in 00:21:26.840 --> 00:21:29.860 a what you see is what you get word processor. 00:21:33.520 --> 00:21:40.980 If you have a look beyond the backyard, on macOS there exists no hinting, 00:21:40.980 --> 00:21:45.780 and in the Windows world, hint can't be turned off, 00:21:45.780 --> 00:21:52.320 so this is hardwired in the font rendering of the Windows system. 00:21:56.120 --> 00:22:03.480 Well another approach to improve readability is anti-aliasing 00:22:03.480 --> 00:22:08.400 which applies multisampling. 00:22:08.400 --> 00:22:15.920 So for every pixel you take samples at different spots 00:22:15.920 --> 00:22:22.240 and then you compute from that a gray value, 00:22:22.240 --> 00:22:29.240 which is a measure of how much of the area of the pixel is covered by the glyph. 00:22:33.260 --> 00:22:40.040 On the picture you can see again the simple raster word, 00:22:40.040 --> 00:22:45.840 and then in the middle you see the word with anti-aliasing, 00:22:46.240 --> 00:22:56.000 line:1 and below you can see a combination of hinting and antialiasing. 00:22:58.700 --> 00:23:02.860 line:1 Suddenly the text becomes very readable also on low resolutions. 00:23:04.740 --> 00:23:12.460 This is what was usually used in computing in the 90s. 00:23:18.440 --> 00:23:23.560 So there is another approach to improve and therefore I have to 00:23:23.560 --> 00:23:27.080 talk a bit about LCD displays. 00:23:27.080 --> 00:23:37.140 So in the picture on the left, above you can see tube monitor pixels and 00:23:37.140 --> 00:23:40.680 line:1 on the bottom you can see LCD monitor pixels. 00:23:40.680 --> 00:23:50.400 All of the pixels consist of so-called subpixels with different colors. 00:23:52.160 --> 00:23:55.940 The mixture of the three different colors 00:23:55.940 --> 00:24:01.660 gives them a wide range of different colors. 00:24:04.560 --> 00:24:12.540 With the tube monitors this is not used, but with LCD display 00:24:12.540 --> 00:24:18.680 depending on the configuration of the subpixels 00:24:18.680 --> 00:24:23.320 it can be used to improve improve the resolution in one direction. 00:24:23.320 --> 00:24:29.400 Therefore you have to know how the configuration of the display is. 00:24:29.400 --> 00:24:36.980 line:1 So usually, one pixel, which you can see in the picture below right? 00:24:36.980 --> 00:24:40.120 These are the usual computer monitors. 00:24:40.120 --> 00:24:51.860 One pixel consists of a red, green and a blue subpixel in this order. 00:24:51.860 --> 00:24:58.400 But you have to keep in mind, especially with tablets, or smartphones, 00:24:58.400 --> 00:25:05.200 you can rotate the screen, so you have to keep that in mind. 00:25:06.060 --> 00:25:11.280 Also there are other subpixel configurations. 00:25:11.280 --> 00:25:17.880 For example, depending on the technology there can be additional red or green 00:25:17.880 --> 00:25:20.180 or even white subpixels. 00:25:24.180 --> 00:25:30.400 So there are also multiple possibilities of the configuration. 00:25:33.840 --> 00:25:39.500 We can use this configuration as I said to improve the resolution 00:25:39.500 --> 00:25:45.000 and in the usual case this is horizontally. 00:25:45.000 --> 00:25:50.440 You can see on the picture on the left side, 00:25:52.800 --> 00:25:59.400 first there's the naive, simple rendered character, 00:25:59.400 --> 00:26:03.880 then the character just using anti-aliasing, 00:26:03.880 --> 00:26:08.340 line:1 and then there's the subpixel rendered character. 00:26:10.060 --> 00:26:16.260 line:1 This one is the most readable or most sharp character. 00:26:16.260 --> 00:26:25.100 line:1 Not sharp!... but it's most correctly rendered according to the outline font. 00:26:25.960 --> 00:26:31.420 Depending on the technique of the display, 00:26:31.420 --> 00:26:41.340 you can see a color haze around the characters. 00:26:44.080 --> 00:26:49.260 So this happens when the software and the display technology 00:26:49.260 --> 00:26:52.020 don't match each other. 00:26:54.180 --> 00:26:59.320 line:1 So this is what you can see on the picture on the right. 00:27:01.340 --> 00:27:07.900 Okay, let's talk about the font rendering software parts in the Linux desktop. 00:27:10.660 --> 00:27:15.340 There's the so-called server-side text rendering. 00:27:16.600 --> 00:27:21.760 So in the X server there's the Core Font subsystem. 00:27:25.040 --> 00:27:31.940 With that, X11 clients can request the server to display a text 00:27:31.940 --> 00:27:36.160 by sending a string via libXfont 00:27:36.160 --> 00:27:45.220 and using the so-called X Logical Font Description (XLFD). 00:27:45.220 --> 00:27:52.920 Here's an example for Adobe Career font, 00:27:52.920 --> 00:28:02.600 then the X server has to render the text using the font. 00:28:05.980 --> 00:28:10.940 If you imagine a terminal server setup with thin clients, 00:28:10.940 --> 00:28:18.500 then the thin client runs the X server and the terminal server runs the X client 00:28:18.500 --> 00:28:27.620 and every thin client then has to handle the font rendering. 00:28:27.620 --> 00:28:34.520 So I don't know if this is the only reason, 00:28:34.520 --> 00:28:40.880 but nowadays server-side font rendering is not so common. 00:28:40.880 --> 00:28:47.620 Probably not used anymore. 00:28:52.540 --> 00:28:56.160 Now I have to talk first about font management. 00:28:56.160 --> 00:29:01.720 In Linux systems there is a software called fontconfig, 00:29:01.720 --> 00:29:05.280 which manages installed fonts on the system 00:29:05.280 --> 00:29:15.640 and it configures for example how to substitute fonts. 00:29:17.160 --> 00:29:24.280 For example if in a document there's a font to render a text 00:29:24.280 --> 00:29:27.120 and the font is not available on the system 00:29:27.120 --> 00:29:33.860 then in the font config system there can be rules to replace the font 00:29:33.860 --> 00:29:36.640 with a similar font. 00:29:37.380 --> 00:29:41.020 This is heavily used in Linux systems. 00:29:41.020 --> 00:29:47.760 There are also rules for what font to use if the current selected font 00:29:47.760 --> 00:29:51.480 doesn't contain a character you want to display. 00:29:52.940 --> 00:29:59.020 You can see on the picture on the right that this is also used... 00:29:59.020 --> 00:30:01.800 although I have to admit, 00:30:01.800 --> 00:30:07.920 I had to take this picture on a Debian 5.0 system in LibreOffice 00:30:07.920 --> 00:30:12.000 because nowadays it works a bit different, 00:30:12.000 --> 00:30:17.780 but this is a good example where you can see that those characters 00:30:17.780 --> 00:30:20.820 come from different fonts actually. 00:30:23.220 --> 00:30:27.920 There's also a command line tool which is quite nice. 00:30:27.920 --> 00:30:29.580 fc-match command line tool. 00:30:29.580 --> 00:30:37.460 So for example if you want to see what is the replacement font for, let's say, Arial 00:30:37.460 --> 00:30:40.960 then you get the output: okay, it's Nimbus Sans. 00:30:44.840 --> 00:30:47.960 And you can also set rendering options, 00:30:47.960 --> 00:30:55.880 which means you can set anti-aliasing or you can turn off hinting. 00:31:00.260 --> 00:31:06.700 Usually these configurations are stored in /etc/fonts 00:31:06.700 --> 00:31:11.800 and there is also a per-user configuration in .config/fontconfig 00:31:11.800 --> 00:31:19.680 and it's in XML file format snippets. 00:31:21.500 --> 00:31:24.920 In the picture you can see an example. 00:31:24.920 --> 00:31:33.020 This is the replacement rule for Carlito and Calibri. 00:31:35.540 --> 00:31:41.540 Carlito is a replacement font for the nowadays often used 00:31:41.540 --> 00:31:44.200 Calibri font from Microsoft. 00:31:45.780 --> 00:31:54.380 So this configuration says the one way, Carlito is the same as Calibri, 00:31:54.380 --> 00:31:56.240 and the other way around. 00:31:56.240 --> 00:31:58.280 This is just an example, 00:31:58.280 --> 00:32:03.940 you can have a look at /etc/fonts and a lot of such snippets. 00:32:07.340 --> 00:32:12.640 It defines how fonts are displayed on the system. 00:32:16.180 --> 00:32:23.720 Another thing, and this is the reason why I had to take the screenshot 00:32:23.720 --> 00:32:29.780 on an older system, there's a piece of software called HarfBuzz. 00:32:29.780 --> 00:32:35.240 HarfBuzz is Persian for OpenType, 00:32:35.240 --> 00:32:41.460 so this software relies on the OpenType font format. 00:32:41.460 --> 00:32:46.400 line:1 You can see on the right side the HarfBuzz logo 00:32:46.400 --> 00:32:50.180 line:1 that actually says HarfBuzz in Persian. 00:32:53.500 --> 00:32:56.240 Before I talked about ligatures, 00:32:56.240 --> 00:33:02.840 In some languages ligatures are required to render fonts correctly 00:33:02.840 --> 00:33:09.220 and this is an example on the left of Devanagari, which is an Indic script. 00:33:11.720 --> 00:33:17.700 So if you have the first two characters combined then this is the rule 00:33:17.700 --> 00:33:24.500 of how to replace those characters with a third glyph. 00:33:29.480 --> 00:33:34.280 There were early implementations by Qt and Pango 00:33:34.280 --> 00:33:38.740 and those were integrated in HarfBuzz. 00:33:41.140 --> 00:33:44.780 Well those parts are now known as Harfbuzz Old, 00:33:44.780 --> 00:33:50.220 and the current HarfBuzz is a rewrite. 00:33:51.580 --> 00:33:57.020 Nowadays it's also used for the so-called simple script, 00:33:59.260 --> 00:34:03.660 meaning especially Latin script, 00:34:03.660 --> 00:34:12.060 and is integrated into Qt, GTK, LibreOffice, Firefox, Android, and XETEX. 00:34:12.060 --> 00:34:14.880 This is what I use for the slides here, 00:34:14.880 --> 00:34:20.840 so all the slides here are also rendered using HarfBuzz. 00:34:20.840 --> 00:34:24.880 And of course the whole font rendering stack. 00:34:26.300 --> 00:34:34.860 HarfBuzz also has fancy features like variable widths or weight 00:34:34.860 --> 00:34:45.760 with only one font or you can define in the font characters with 00:34:45.760 --> 00:34:55.540 variable widths and without stepping you can change it using HarfBuzz. 00:34:59.940 --> 00:35:04.760 Those techniques are used in client-side rendering. 00:35:06.860 --> 00:35:15.100 One library often was until recently often used, Xft. 00:35:17.820 --> 00:35:22.480 Well this is the applications meaning the X clients render the text 00:35:24.060 --> 00:35:27.280 based on FreeType and fontconfig. 00:35:27.800 --> 00:35:31.240 Then the X server only displays the results. 00:35:32.160 --> 00:35:36.140 Well, there is some caching involved, 00:35:36.140 --> 00:35:42.200 and it requires an extension to the protocol. 00:35:51.160 --> 00:35:56.120 In the widget libraries this was also used a long time, 00:35:56.120 --> 00:36:01.540 but now Qt, for example, has its own code for font rendering 00:36:01.540 --> 00:36:05.240 based on HarfBuzz, FreeType, and fontconfig. 00:36:05.240 --> 00:36:09.140 There's the combination of Pango and Cairo, 00:36:09.140 --> 00:36:13.000 which is used in the GTK environment. 00:36:13.000 --> 00:36:22.660 Pango derives from Greek and Japanese: pan means all and go means languages. 00:36:22.660 --> 00:36:29.660 So this is the background to write in all languages. 00:36:29.660 --> 00:36:34.000 This also uses HarfBuzz, FreeType, and fontconfig. 00:36:34.000 --> 00:36:39.780 And if you look at Wayland clients, they only do client-side rendering. 00:36:42.660 --> 00:36:48.140 To sum it up, we have a variety of techniques for text display. 00:36:50.340 --> 00:36:53.600 Some have historical than practical value nowadays. 00:36:53.600 --> 00:36:58.940 The modern font rendering stack is quite complex. 00:37:03.840 --> 00:37:08.820 But writing is one of the main interface to computers, 00:37:08.820 --> 00:37:12.160 so developers should be aware of the complexity. 00:37:14.460 --> 00:37:16.560 Keep that in mind. 00:37:17.720 --> 00:37:18.540 Thank you. 00:37:20.280 --> 00:37:24.080 [applause] 00:37:33.640 --> 00:37:35.440 Are there any questions? 00:37:41.100 --> 00:37:45.040 [audience] More a request than a question, I find the topic very interesting 00:37:45.040 --> 00:37:51.240 and I'd like to check it again. I know your video was not recorded 00:37:51.240 --> 00:37:53.640 or I think it was not recorded... 00:37:53.640 --> 00:37:57.080 [Max] Well it was I think. 00:37:58.340 --> 00:38:04.550 [audience] Okay so nevermind, but still if you are able to share your presentation 00:38:04.550 --> 00:38:05.380 [Max] Yes 00:38:05.380 --> 00:38:08.300 [audience] I would be very happy to look at it. Thank you. 00:38:16.960 --> 00:38:25.640 [audience] [tests mic] What's the problem due to the 00:38:25.640 --> 00:38:32.900 complexity from the software stack in your open ??. 00:38:32.900 --> 00:38:36.240 [Max] The problem of what? 00:38:36.240 --> 00:38:48.320 [audience] What's the problem it came from this complex software stack 00:38:48.320 --> 00:38:50.320 in your open ??. 00:38:50.320 --> 00:38:59.420 There's no problem with that, or there's some problem 00:38:59.420 --> 00:39:11.300 with these lot of layers, very lot of components to render the font. 00:39:11.300 --> 00:39:17.440 [Max] Okay, I try to rephrase the question [audience] Please. 00:39:17.440 --> 00:39:22.820 [Max] What is the reason there is so many layers in the font rendering stack today. 00:39:22.820 --> 00:39:23.980 [Max] Is that correct? 00:39:23.980 --> 00:39:38.120 [audience] And it caused some problem. Do you know any problem 00:39:38.120 --> 00:39:41.600 with current font rendering system. 00:39:41.600 --> 00:39:43.700 [Max] Colored font rendering system? 00:39:43.700 --> 00:39:45.700 [audience] Current, now. 00:39:48.040 --> 00:39:49.440 [Max] Ah current font- 00:39:49.440 --> 00:39:52.500 [audience 2] The question is whether the complexity 00:39:52.500 --> 00:39:55.520 means that there are difficulties for developers. 00:39:55.520 --> 00:39:56.700 Is it too complex? 00:39:56.700 --> 00:39:58.200 Does that cause problems? 00:39:58.200 --> 00:40:02.640 [Max] Well the complexity is hidden behind the font rendering stack. 00:40:02.640 --> 00:40:10.560 So it's a huge collection of software, 00:40:10.560 --> 00:40:17.620 usually there's HarfBuzz, fontconfig, and FreeType heavily used nowadays. 00:40:17.620 --> 00:40:22.300 But it's all encapsulated in these libraries 00:40:22.300 --> 00:40:29.140 and it's used all over the free software world 00:40:30.240 --> 00:40:39.080 and it makes it easy to write applications which are easily translatable. 00:40:39.840 --> 00:40:47.800 [audience] Yes but for example, the fontconfig is not so flexible. 00:40:47.800 --> 00:40:55.080 For example, when we're using mainly Japanese 00:40:55.080 --> 00:41:01.800 and other display of the language, 00:41:01.800 --> 00:41:13.160 then the font of config chooses the non-Japanese font like the Chinese one. 00:41:13.160 --> 00:41:28.220 I know some distributions like Ubuntu make language specific fontconfig file 00:41:28.220 --> 00:41:36.500 for each language to deal with but Debian doesn't have such a mechanism. 00:41:38.880 --> 00:41:47.800 So in my opinion the fontconfig is a bit terrible so 00:41:47.800 --> 00:41:55.260 is there any ?? meant or any hack for it? 00:41:55.260 --> 00:42:04.760 [Max] Okay, the fontconfig system comes from the time where XML was popular. 00:42:04.760 --> 00:42:06.600 [audience] Mhmm [Max] As you can see. 00:42:08.520 --> 00:42:15.360 Well the problem here is not so much the software stack 00:42:15.360 --> 00:42:18.960 more than the Unicode system. 00:42:18.960 --> 00:42:25.300 So in the Unicode system there are same code points for 00:42:25.300 --> 00:42:31.240 Japanese and Chinese characters somewhere although they have different appearances. 00:42:31.240 --> 00:42:39.200 In the fontconfig system there are replacement rules for characters 00:42:39.200 --> 00:42:48.380 and it is just a list and usually Chinese fonts are listed first. 00:42:48.380 --> 00:42:54.540 So that is the reason why in the Japanese language you get Chinese characters 00:42:54.540 --> 00:42:56.620 instead of Japanese characters. 00:42:56.620 --> 00:43:01.760 So I also think there's room to improve the software stack, yes. 00:43:01.760 --> 00:43:03.180 [audience] Thank you. 00:43:15.500 --> 00:43:19.520 [Max] Okay, done. Thank you. 00:43:20.080 --> 00:43:24.640 [applause]