console_fonts.html 7.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <!DOCTYPE html>
  2. <div class="views-field views-field-field-linux-name"> <div class="field-content"><a href="/USERS/CSCHRODER">Carla Schroder</a></div> </div> </div>
  3. </div>
  4. </div>
  5. </div>
  6. <div class="panel-pane pane-node-created node-date" >
  7. January 4, 2018
  8. </div>
  9. </div><div class="lcom-stacked__main"><div class="panel-pane pane-node-title" >
  10. <h1>How to Change Your Linux Console Fonts</h1>
  11. </div>
  12. <div class="panel-pane pane-entity-field pane-node-field-image" >
  13. <div class="field field-name-field-image field-type-image field-label-hidden"><div class="field-items"><div class="field-item even"><div id="file-7295" class="file file-image file-image-png">
  14. <div class="content">
  15. </div>
  16. </div></div></div>
  17. </div>
  18. <div class="panel-pane pane-entity-field pane-node-body" >
  19. <div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>I try to be a peaceful soul, but some things make that difficult, like tiny console fonts. Mark my words, friends, someday your eyes will be decrepit and you won't be able to read those tiny fonts you coded into everything, and then you'll be sorry, and I will laugh.</p>
  20. <p>Fortunately, Linux fans, you can change your console fonts. As always, the ever-changing Linux landscape makes this less than straightforward, and font management on Linux is non-existent, so we'll muddle along as best we can. In this article, I'll show what I've found to be the easiest approach.</p>
  21. <h3>What is the Linux Console?</h3>
  22. <p>Let us first clarify what we're talking about. When I say Linux console, I mean TTY1-6, the virtual terminals that you access from your graphical desktop with Ctrl+Alt+F1 through F6. To get back to your graphical environment, press Alt+F7. (This is no longer universal, however, and your Linux distribution may have it mapped differently. You may have more or fewer TTYs, and your graphical session may not be at F7. For example, Fedora puts the default graphical session at F2, and an extra one at F1.) I think it is amazingly cool that we can have both X and console sessions running at the same time.</p>
  23. <p>The Linux console is part of the kernel, and does not run in an X session. This is the same console you use on headless servers that have no graphical environments. I call the terminals in a graphical session X terminals, and terminal emulators is my catch-all name for both console and X terminals.</p>
  24. <p>But that's not all. The Linux console has come a long way from the early ANSI days, and thanks to the Linux framebuffer, it has Unicode and limited graphics support. There are also a number of console multimedia applications that we will talk about in a future article.</p>
  25. <h3>Console Screenshots</h3>
  26. <p>The easy way to get console screenshots is from inside a virtual machine. Then you can use your favorite graphical screen capture program from the host system. You may also make screen captures from your console with <a href="http://jwilk.net/software/fbcat">fbcat</a> or <a href="https://github.com/jwilk/fbcat/blob/master/fbgrab">fbgrab</a>. <code>fbcat</code> creates a portable pixmap format (PPM) image; this is a highly portable uncompressed image format that should be readable on any operating system, and of course you can convert it to whatever format you want. <code>fbgrab</code> is a wrapper script to <code>fbcat</code> that creates a PNG file. There are multiple versions of <code>fbgrab</code> written by different people floating around. Both have limited options and make only a full-screen capture.</p>
  27. <p><code>fbcat</code> needs root permissions, and must redirect to a file. Do not specify a file extension, but only the filename:</p>
  28. <pre>
  29. $ sudo fbcat &gt; Pictures/myfile
  30. </pre><p>After cropping in GIMP, I get Figure 1.</p>
  31. <p><div class="media media-element-container media-default"><div id="file-7291" class="file file-image file-image-png">
  32. <h2 class="element-invisible"><a href="/files/images/fig-1png-10">fig-1.png</a></h2>
  33. <div class="content">
  34. <img class="media-element file-default" data-delta="1" typeof="Image" src="https://www.linux.com/sites/lcom/files/styles/rendered_file/public/fig-1_10.png?itok=bHOxrZk9" alt="font size" title="font size" /><div class="group-file-info field-group-div"><div class="field field-name-field-caption field-type-text-long field-label-hidden"><div class="field-items"><div class="field-item even">Figure 1: View after cropping.</div></div></div><div class="field field-name-field-license field-type-taxonomy-term-reference field-label-hidden"><div class="field-items"><div class="field-item even"><a href="/LICENSES/CATEGORY/USED-PERMISSION" typeof="Concept" property="prefLabel" datatype="">Used with permission</a></div></div></div></div> </div>
  35. </div>
  36. </div></p>
  37. <p>It would be nice to have a little padding on the left margin, so if any of you excellent readers know how to do this, please tell us in the comments.</p>
  38. <p><code>fbgrab</code> has a few more options that you can read about in <code>man fbgrab</code>, such as capturing a different console, and time delay. This example makes a screen grab just like <code>fbcat</code>, except you don't have to explicitly redirect:</p>
  39. <pre>
  40. $ sudo fbgrab Pictures/myOtherfile
  41. </pre><h3>Finding Fonts</h3>
  42. <p>As far as I know, there is no way to list your installed kernel fonts other than looking in the directories they are stored in: <code>/usr/share/consolefonts/</code> (Debian/etc.), <code>/lib/kbd/consolefonts/</code> (Fedora), <code>/usr/share/kbd/consolefonts</code> (openSUSE)...you get the idea.</p>
  43. <h3>Changing Fonts</h3>
  44. <p>Readable fonts are not a new concept. Embrace the old! Readability matters. And so does configurability, which sometimes gets lost in the rush to the new-shiny.</p>
  45. <p>On Debian/Ubuntu/etc. systems you can run <code>sudo dpkg-reconfigure console-setup</code> to set your console font, then run the <code>setupcon</code> command in your console to activate the changes. <code>setupcon</code> is part of the <code>console-setup</code> package. If your Linux distribution doesn't include it, there might be a package for you at <a href="https://software.opensuse.org/package/console-setup">openSUSE</a>.</p>
  46. <p>You can also edit <code>/etc/default/console-setup</code> directly. This example sets the Terminus Bold font at 32 points, which is my favorite, and restricts the width to 80 columns.</p>
  47. <pre>
  48. ACTIVE_CONSOLES="/dev/tty[1-6]"
  49. CHARMAP="UTF-8"
  50. CODESET="guess"
  51. FONTFACE="TerminusBold"
  52. FONTSIZE="16x32"
  53. SCREEN_WIDTH="80"
  54. </pre><p>The FONTFACE and FONTSIZE values come from the font's filename, <code>TerminusBold32x16.psf.gz</code>. Yes, you have to know to reverse the order for FONTSIZE. Computers are so much fun. Run <code>setupcon</code> to apply the new configuration. You can see the whole character set for your active font with <code>showconsolefont</code>. Refer to <code>man console-setup</code> for complete options.</p>
  55. <h3>Systemd</h3>
  56. <p>Systemd is different from <code>console-setup</code>, and you don't need to install anything, except maybe some extra font packages. All you do is edit <code>/etc/vconsole.conf</code> and then reboot. On my Fedora and openSUSE systems I had to install some extra Terminus packages to get the larger sizes as the installed fonts only went up to 16 points, and I wanted 32. This is the contents of <code>/etc/vconsole.conf</code> on both systems:</p>
  57. <pre>
  58. KEYMAP="us"
  59. FONT="ter-v32b"
  60. </pre><p>Come back next week to learn some more cool console hacks, and some multimedia console applications.</p>
  61. <p><em>Learn more about Linux through the free <a href="https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux">"Introduction to Linux" </a>course from The Linux Foundation and edX.</em></p></div></div></div>
  62. </div>
  63. </body>
  64. </html>