{"id":20664,"date":"2023-08-31T17:08:14","date_gmt":"2023-08-31T17:08:14","guid":{"rendered":"https:\/\/linuxways.net\/?p=20664"},"modified":"2023-08-31T17:12:43","modified_gmt":"2023-08-31T17:12:43","slug":"how-to-render-fonts-in-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/linux-commands\/how-to-render-fonts-in-linux\/","title":{"rendered":"How to Render Fonts in Linux?"},"content":{"rendered":"<p>Linux used the GUI of the old X11 window system. The API for that was horrendous with plenty of libraries stacked upon one another to make it work. The font rendering across Linux depends on the distribution, with Ubuntu having the best default font rendering settings and Fedora Linux having the worst. Having a bad font rendering, we will see a rough and jagged font rendering across websites when using Linux.<\/p>\n<p>In this article, we will discuss how we can improve the font rendering on Linux.<\/p>\n<h2><strong>How to Render Fonts in Linux?<\/strong><\/h2>\n<p>To improve Font Rendering, you will have to make some necessary changes to the font configuration files involving some steps.<\/p>\n<h3><strong>Step 1: Creating Local Config File<\/strong><\/h3>\n<p>First, you have to create a local config file using the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">nano<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>fonts<span class=\"sy0\">\/<\/span>local.config<\/div><\/div>\n<p>It will ask for the user password:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1028\" height=\"45\" class=\"wp-image-20665\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-1.png 1028w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-1-300x13.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-1-1024x45.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-1-768x34.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-1-1020x45.png 1020w\" sizes=\"auto, (max-width: 1028px) 100vw, 1028px\" \/><\/p>\n<h3><strong>Step 2: Adding Content in the File<\/strong><\/h3>\n<p>Open the \u201clocal.config\u201d file and add the following content to the file:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;height:100%;\"><div class=\"bash codecolorer\"><span class=\"sy0\">&lt;<\/span>?xml <span class=\"re2\">version<\/span>=<span class=\"st0\">&quot;1.0&quot;<\/span>?<span class=\"sy0\">&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;!<\/span>DOCTYPE fontconfig SYSTEM <span class=\"st0\">&quot;fonts.dtd&quot;<\/span><span class=\"sy0\">&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>fontconfig<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>match<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;<\/span> <span class=\"re2\">target<\/span>=<span class=\"st0\">&quot;font&quot;<\/span><span class=\"sy0\">&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>edit<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;<\/span> <span class=\"re2\">name<\/span>=<span class=\"st0\">&quot;antialias&quot;<\/span> <span class=\"re2\">mode<\/span>=<span class=\"st0\">&quot;assign&quot;<\/span><span class=\"sy0\">&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>bool<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><span class=\"kw2\">true<\/span><span class=\"sy0\">&lt;\/&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>bool<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;\/&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>edit<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>edit<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;<\/span> <span class=\"re2\">name<\/span>=<span class=\"st0\">&quot;hinting&quot;<\/span> <span class=\"re2\">mode<\/span>=<span class=\"st0\">&quot;assign&quot;<\/span><span class=\"sy0\">&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>bool<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><span class=\"kw2\">true<\/span><span class=\"sy0\">&lt;\/&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>bool<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;\/&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>edit<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>edit<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;<\/span> <span class=\"re2\">mode<\/span>=<span class=\"st0\">&quot;assign&quot;<\/span> <span class=\"re2\">name<\/span>=<span class=\"st0\">&quot;rgba&quot;<\/span><span class=\"sy0\">&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>const<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span>rgb<span class=\"sy0\">&lt;\/&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>const<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;\/&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>edit<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>edit<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;<\/span> <span class=\"re2\">mode<\/span>=<span class=\"st0\">&quot;assign&quot;<\/span> <span class=\"re2\">name<\/span>=<span class=\"st0\">&quot;hintstyle&quot;<\/span><span class=\"sy0\">&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>const<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span>hintslight<span class=\"sy0\">&lt;\/&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>const<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;\/&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>edit<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>edit<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;<\/span> <span class=\"re2\">mode<\/span>=<span class=\"st0\">&quot;assign&quot;<\/span> <span class=\"re2\">name<\/span>=<span class=\"st0\">&quot;lcdfilter&quot;<\/span><span class=\"sy0\">&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>const<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span>lcddefault<span class=\"sy0\">&lt;\/&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>const<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;\/&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>edit<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;\/&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>match<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;\/&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>fontconfig<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span><\/div><\/div>\n<p>Once added, save the file and Exit using \u201cCtrl+X\u201d:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1033\" height=\"721\" class=\"wp-image-20666\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-2.png 1033w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-2-300x209.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-2-1024x715.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-2-768x536.png 768w\" sizes=\"auto, (max-width: 1033px) 100vw, 1033px\" \/><\/p>\n<h3><strong>Step 3: Create a Backup of Resources File<\/strong><\/h3>\n<p>Create a backup of the resource file. Add the following code in it:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">cp<\/span> ~<span class=\"sy0\">\/<\/span>.Xresources ~<span class=\"sy0\">\/<\/span>.Xresources.bak<\/div><\/div>\n<p>Create the file if it does not exist. Here we don\u2019t have the resource file:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1030\" height=\"69\" class=\"wp-image-20667\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-3.png 1030w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-3-300x20.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-3-1024x69.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-3-768x51.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-3-1020x69.png 1020w\" sizes=\"auto, (max-width: 1030px) 100vw, 1030px\" \/><\/p>\n<h3><strong>Step 4: Configuring Resources File<\/strong><\/h3>\n<p>Use the command below to create a Resources file. This command will open the file if it was already made:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">nano<\/span> ~<span class=\"sy0\">\/<\/span>.Xresources<\/div><\/div>\n<p>Once created, it will open up the file. Add the script below to your resource file:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">Xft.antialias: <span class=\"nu0\">1<\/span><br \/>\nXft.hinting: <span class=\"nu0\">1<\/span><br \/>\nXft.rgba: rgb<br \/>\nXft.hintstyle: hintslight<br \/>\nXft.lcdfilter: lcddefault<\/div><\/div>\n<p>In these attributes, \u201c<strong>Anti-Aliasing<\/strong>\u201d is enabled, and \u201c<strong>Hinting<\/strong>\u201d is set to 1 which is \u201cSlight\u201d. Use the following command now:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">xrdb <span class=\"re5\">-merge<\/span> ~<span class=\"sy0\">\/<\/span>.Xresources<\/div><\/div>\n<p>Once you hit enter, it will merge the settings and the command line will move to the next line:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1032\" height=\"45\" class=\"wp-image-20668\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-4.png 1032w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-4-300x13.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-4-1024x45.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-4-768x33.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-4-1020x45.png 1020w\" sizes=\"auto, (max-width: 1032px) 100vw, 1032px\" \/><\/p>\n<p><strong>Step 5: Verify Changes<\/strong><\/p>\n<p>Now to verify your changes, search for \u201c<strong>KDE System Settings<\/strong>\u201d in the search bar:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"910\" height=\"240\" class=\"wp-image-20669\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-5.png 910w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-5-300x79.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-5-768x203.png 768w\" sizes=\"auto, (max-width: 910px) 100vw, 910px\" \/><\/p>\n<p>Open it and search for \u201cFonts\u201d in the search box of the settings window:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1128\" height=\"303\" class=\"wp-image-20670\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-6.png 1128w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-6-300x81.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-6-1024x275.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-6-768x206.png 768w\" sizes=\"auto, (max-width: 1128px) 100vw, 1128px\" \/><\/p>\n<p>Open the fonts settings and here you can see that the Anti-Aliasing is enabled and the Hinting is set to \u201cSlight\u201d:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"838\" height=\"670\" class=\"wp-image-20671\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-7.png 838w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-7-300x240.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-7-768x614.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/08\/word-image-20664-7-150x120.png 150w\" sizes=\"auto, (max-width: 838px) 100vw, 838px\" \/><\/p>\n<h3><strong>Step 6: Reboot System<\/strong><\/h3>\n<p>You have to reboot your system now to apply the changes to fonts for them to render better.<\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>The font rendering across Linux depends on the distribution. Having bad rendering leads to a rough and jagged user interface. This article explains how to create a local config file, add content to it, then add resource files and necessary attributes to it, and once our system restarts we can see the fonts render better across web pages.<\/p>","protected":false},"excerpt":{"rendered":"<p>Render the fonts in Linux by creating and managing a local config file. Add a resource file and update it by adding the necessary attributes to it.<\/p>","protected":false},"author":110,"featured_media":20672,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1049],"tags":[],"class_list":["post-20664","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-commands"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/20664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=20664"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/20664\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/20672"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=20664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=20664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=20664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}