|
Last updates: Thu Mar 23 14:01:42 2017
How to I change the font size in a X11 terminal window?
Use Ctl-button-3 (that is, hold down the Control key while pressing mouse button three, which is the rightmost button on a right-handed mouse) to bring up a font menu with seven different font sizes.
How do I start an X11 terminal window with a specified font?
Most X11 Window System utilities, including xterm, accept a -fn command-line option to set the font. For example, to use a somewhat larger font than the default:
% xterm -fn 10x20 &
How do I change the default terminal fonts permanently?
Most X11 Window System utilities, including xterm, use default options that are set in the X11 resource database. That database is loaded by the xrdb utility, normally in the $HOME/.xinitrc or $HOME/.xsession file:
% xrdb -merge $HOME/.Xdefaults.X11R4
The -merge option tells xrdb to add resources, replacing any existing ones with the same name. Had the -load option been used instead, all existing resources would first be discarded.
Each line of the .Xdefaults.X11R4 file contains either a comment beginning with an exclamation mark, or is blank, or has an option name, a colon, and a value. Here is an sample fragment of such a file:
! Use the Lucida Typewriter fonts for xterm: XTerm*VT100*font1 : nil2 XTerm*VT100*font2 : -*-lucidatypewriter-medium-*-*-*-10-*-*-*-*-*-*-* XTerm*VT100*font3 : -*-lucidatypewriter-medium-*-*-*-14-*-*-*-*-*-*-* XTerm*VT100*font4 : -*-lucidatypewriter-medium-*-*-*-17-*-*-*-*-*-*-* XTerm*VT100*font5 : -*-lucidatypewriter-medium-*-*-*-20-*-*-*-*-*-*-* XTerm*VT100*font6 : -*-lucidatypewriter-medium-*-*-*-24-*-*-*-*-*-*-*
Option names are case sensitive, and regrettably, frequently hard to find in online documentation, such as the Unix manual pages.
After merging your changes, you can check them by filtering a dump of the resource database:
% xrdb -query | grep -i xterm ... XTerm*VT100*font1 : nil2 XTerm*VT100*font2 : -*-lucidatypewriter-medium-*-*-*-10-*-*-*-*-*-*-* ...
How do I change the fonts in the Emacs text editor?
When emacs is running in a terminal window (e.g., with emacs -nw), it just uses the font supplied by the window. See earlier FAQ entries on this page to learn how to change the terminal font.
When emacs runs in an X window, there is a font menu on Shift-button-1. The paths Misc -> 10x20 and Misc -> 12x24 lead to highly readable fonts that are somewhat larger than normal.
Changing the emacs font menus is a much more complicated process. See the Emacs manual and the Emacs Lisp Reference manual in the info system.
How do I change the font in a Web browser?
GUI-based Web browsers, and Web pages, make such extensive use of fonts that there is little value in having a default font that can be set on the browser command line.
The firefox, mozilla, and netscape browsers all recognize the keystrokes Ctl-minus and Ctl-plus as requests to decrease or increase the font size. This is handy when a Web page forces a font size that you find uncomfortably small or large.
The amaya browser recognizes keystrokes Alt-minus and Alt-plus to decrease or increase the font size. It also has the feature in the menu paths Views -> Zoom in and Views -> Zoom out.
The iexplorer browser does not recognize keystrokes for fontsize changes, but instead, has the feature in the menu path View -> Text Size.
The opera browser also does not recognize keystrokes for fontsize changes, but instead, has the feature in the menu path View -> Zoom.
Terminal-based browsers, such as elinks, links, lynx, netrik, and w3m, use the fonts provided by the terminal window. Change terminal fonts as described in an earlier FAQ on this page.
How do I change the fonts in office software?
Word processors and spreadsheets typically allow you to change font names, sizes, and types from menus. For example, with ooffice and soffice, the toolbar has scrolling menus for the font name and size, and buttons to select bold, italic, or upright styles.
How do I change the fonts in the (La)TeX typesetting systems?
Fonts are a very complex issue in typesetting systems, since much more information is needed about fonts (e.g., special dimensions of mathematical characters), many more characters are available for typesetting (e.g., accented characters, and mathematical characters), and the ordering of characters within a font is often quite different from that used for screen fonts, necessitating a remapping of input characters to font glyphs.
Plain TeX uses low-level commands to associate a control sequence with a font name that corresponds to a TeX Font Metric (.tfm) file for a particular font, style, weight, and size:
\font \myrm = cmr17 at 17pt \font \mysmallrm = cmr17 at 12pt \myrm This is Computer Modern 17pt type. \mysmallrm This is Computer Modern 17pt type squished to 12pt. \end
LaTeX has a much more powerful font mechanism that allows you to load a font package at the start of your document, then access various sizes with the control sequences \tiny, \scriptsize, \footnotesize, \small, \normalsize, \large, \Large, \LARGE, \huge, and \Huge. Here is an example:
\documentclass{article} \usepackage{newcent} \begin{document} This is normalsize New Century type. {\LARGE This is LARGE New Century type.} \end{document}
While you can typeset prose in more than 20,000 different text fonts, the font repertoire for serious mathematical typesetting is sharply limited, with only about a half-dozen choices. The default Computer Modern fonts are always available. LaTeX packages shown in this table combine text and math fonts from different families; you must judge for yourself how well they look together.
Package | Text and math fonts |
mathpazo | Palatino + Computer Modern math |
mathpple | Palatino + Euler math |
unknown | Latin Modern + Latin Modern Math |
unknown | Lucida + Lucida Math |
mathptm | Times + Symbol + Computer Modern math |
mathtime | Times + MathTime |
mtpro | Times + MathTime Professional |
The Lucida and MathTime fonts are proprietary and licensed; ask systems staff whether you can use them, and under what conditions.
Consult books listed in the TeX and METAFONT FAQ for more details on this very complex topic. Alan Hoenig's book TeX Unbound has a particularly good discussion of the problem of combining text and math fonts, and shows 32 pages of examples.
Why are characters sometimes displayed incorrectly?
This happens if the encoding of the font that you are using does not match that expected by the file that you are displaying. An encoding is simply an assignment of a glyph or symbol to a standard position in a character table. To understand at least a little of the problem of character encodings, some historical background is helpful.
From the invention of punched cards by Hermann Hollerith in the 1880s (to handle the processing of the 1880 US Census data), up to the mid-1960s, most computers used six-bit characters, allowing 26 = 64 different characters, permitting the encoding of 26 uppercase letters, 10 digits, and assorted punctuation, but leaving no space for lowercase letters.
In 1963, the ASCII (American Standard Code for Information Interchange) character set used seven-bit characters, giving 128 possible glyphs. Of these, 33 were assigned as control characters without a visible representation, and the other 95 were used to add lowercase letters and more punctuation, such as the braces and brackets required by many programming languages.
By the 1970s, most new computer designs were based on eight-byte characters (called bytes), giving 256 possible glyphs. Most vendors put the ASCII characters in the first 128 positions, and then allowed customers, or their vendor offices in other countries, to add characters to the upper 128 slots. Each such assignment of glyphs to a 256-element table was called a code page. Several hundred different code pages are in common use around the world.
As you would expect, this practice led to a nightmare of encoding incompatibilities: an acute-e (é) at one site might display as slash-o (ø), or some other unexpected character, at another, making data exchange via files difficult, if not impossible.
Few computer systems provide for tagging file contents with a record of the character encoding, so humans, or clever computer programs, have to try to figure this out, but as we know, guesses by humans and programs are frequently wrong.
To try to reduce the Babel of confusion, the International Standards Organization, ISO, introduced the ISO8859-n code pages, where n is currently 0, 1, 2, ..., 15. For details, see the document Fonts in the X Window System.
The ISO8859-1 encoding is known as Latin-1, and has enough accented characters to handle the needs of the major languages of Western Europe. However, it has no empty slots left to handle additional characters required by the languages of Eastern Europe, such as Czech and Polish. When the European Union introduced the new euro currency symbol in the late 1990s, there was no space for that either, so a new code page, ISO8859-15 (also called Latin-9), was derived from ISO8859-1 by replacing the generic currency symbol with the euro symbol (€), and replacing the fractions 1/4, 1/2, and 3/4 by three letters: OE-ligature (Œ), oe-ligature (œ), and Y-diaeresis (a character that most browsers cannot display).
Code pages are clearly a bad solution in a worldwide networked computing environment, and users of languages other than English have suffered from the encoding Babel for decades.
For that reason, in the early 1990s, ISO and a consortium of vendors began competing projects to produce a universal character encoding that can handle all of the world's writing systems, including long-dead ones, like Egyptian hieroglyphics and Phoenician. The two projects were fortunately reconciled, so that ISO10646-1 and Unicode are now for most purposes equivalent encodings, and can handle more than a million characters. At Unicode version 4.1 in early 2005, the repertoire looks like this:
51640 graphic characters assigned (BMP) 35 format control characters assigned (BMP) 65 control characters assigned (BMP) 6400 private use characters assigned (BMP) 2048 surrogate code points designated (BMP) 34 noncharacter code points designated (BMP) 5314 reserved code points (BMP) 45875 graphic characters assigned (supplementary planes) 105 format characters assigned (supplementary planes) 131068 private use characters assigned (supplementary planes) 32 noncharacter code points designated (supplementary planes) 871496 reserved code points (supplementary planes) ------------------------------------------------------------------ 1114112 code points altogether
The task is enormous, because there are large numbers of characters in Asian character sets (and new ones continue to be invented), and for dead languages, scholars are unsure of the complete sets. Font have to be designed to handle all of the encoded characters (about 100,000 so far), and this work has to be repeated in many designs, styles, sizes, and weights. There are about 20,000 commercial fonts available for the ASCII-based encodings. Were they all extended to the full Unicode repertoire, about 200,000,000 new character glyphs would have to be designed.
The Unicode set requires 21 bits for each character, but many programming languages are defined to handle only eight bits per character, although Java and a few other newer languages handle sixteen bits per character. Thus, all computer programming languages and their libraries need to be updated. To ease the transition, 21-bit characters can represented in 16-bit chunks or chunk pairs (UTF-16), or variable numbers of eight-bit bytes (UTF-8).
The UTF-8 encoding is the one adopted in the Unix world, and was carefully designed so that all existing ASCII files are automatically valid UTF-8 files. While xlsfonts reports about 200 fonts in the ISO10646-1 encoding, most have little more than glyphs for the basic 256 of Latin-1, so even if you use them in X11 Window System applications, you may find many blank spots on your screen at characters where glyphs are simply unavailable.
What screen fonts are available?
The xlsfonts utility lists all of the fonts that are found in the X11 font path, typically a few thousand, so filtering the output with a screen pager is advisable:
% xlsfonts | less ... --courier-bold-o-normal--0-0-0-0-m-0-iso8859-1 --courier-bold-o-normal--0-0-0-0-m-0-iso8859-1 ... -adobe-courier-medium-r-normal--0-0-75-75-m-0-iso8859-1 -adobe-courier-medium-r-normal--10-100-75-75-m-60-iso8859-1 ... 10x20 12x24 ...
Some fonts have short names with the horizontal and vertical sizes in pixels, such as the 10x20 font in the sample output. Others have long names that record vendor, font name, style, size, and encoding. Here is how to decode one such long name:
-adobe-courier-medium-r-normal--10-100-75-75-m-60-iso8859-1 _____ _______ ______ _ ______ _ _ ___ __ __ _ __ _________ | | | | | | | | | | | | | | | | | | | | | | | | | | encoding = ISO8859-1 (Latin 1) | | | | | | | | | | | | average width = 6.0 pixels | | | | | | | | | | | monospaced (fixed width characters) | | | | | | | | | | 75dpi resolution vertically | | | | | | | | | 75dpi resolution horizontally | | | | | | | | 10.0pt fontsize | | | | | | | 10-pixel size | | | | | | empty means serif (otherwise, sans for sansserif) | | | | | normal width | | | | roman style (otherwise, o for oblique) | | | medium weight | | Courier family | Adobe foundry
Any of the fields can be replaced by an asterisk, which means match any value in that field, and omitted trailing fields default to asterisks. Thus, you could start a terminal window with
% xterm -fn '-*-courier-medium-r-*-*-17' &
to get a 17-pixel Courier medium roman font. In general, you need to quote fontnames on the command line to protect special characters from interpretation by the Unix shell.
How do I display the contents of a screen font?
The xfd (X11 Font Display) utility shows a window with an image of each font character:
% xfd -fn '-b&h-lucidatypewriter-medium-r-normal-sans-17-120-100-100-m-100-iso10646-1' &
If there are more than 256 characters in the font, as there are in this one, there are Next Page and Prev Page buttons to move forwards and backwards 256 characters at a time. Move the mouse cursor to any character box and press mouse button one (the left one on a right-handed mouse) to get a display of the character metrics.
The X11 Window System finds screen fonts in a font path that is set and displayed with the xset utility:
% xset q ... /usr/openwin/lib/X11/fonts/Type1/, \ /usr/openwin/lib/X11/fonts/Type1/sun/, \ /usr/openwin/lib/X11/fonts/F3bitmaps/, \ /usr/openwin/lib/X11/fonts/Speedo/, \ /usr/openwin/lib/X11/fonts/misc/, \ /usr/openwin/lib/X11/fonts/75dpi/, \ /usr/openwin/lib/X11/fonts/100dpi/, \ /usr/local/src/xterm/ucs-fonts-75dpi100dpi/100dpi, \ /usr/openwin/lib/X11/fonts/TrueType/, \ /usr/local/share/Amaya6/fonts/ ...
The path is displayed as a single long line of comma-separated directories, but we broke it between components here with a space, backslash, and newline for better readability.
You can add a font directory, or a comma-separated list of directories, to the start of the path with
% xset +fp /usr/local/share/emacs/fonts/Chinese-BIG
or the end of the path with
% xset fp+ /usr/local/share/emacs/fonts/TrueType
Options fp- and -fp remove directories from the path:
% xset fp- /usr/local/share/emacs/fonts/TrueType,/usr/local/share/emacs/fonts/Chinese-BIG
Fonts in the newly added directories are not available for use until you run the xset fp rehash command to request the X11 Window System to reread the contents of all of the directories in the font path and build a new list of fonts inside the X11 server. Once it completes, xlsfonts will show all of the available fonts, including the ones in the directories that you just added.
The xmbdfed font editor does the job. Start by making a copy of an existing font under a new name in one of your own directories:
% cp /usr/local/src/xterm/ucs-fonts-75dpi100dpi/100dpi/helvR18.bdf mod-helvR18.bdf % xmbdfed mod-helvR18.bdf &
This brings up a window, or series of windows, with up to 256 characters each. Double click on a character to bring up a character-editor window. Mouse button one blackens a selected pixel, and button two whitens it. When you finish editing the character, use the File -> Update menu path to record the changes for that character. The File -> Save menu path lets you save your work, overwriting the original file. Alternatively, use the File -> Save As menu to save it under a different name.
A much more powerful font editor, pfaedit, or its successor, fontforge, works similarly, but can handle outline font formats as well, and convert between formats.