choose-fonts.rst 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. Changing kitty fonts
  2. ========================
  3. .. only:: man
  4. Overview
  5. --------------
  6. Terminal aficionados spend all day staring at text, as such, getting text
  7. rendering just right is very important. kitty has extremely powerful facilities
  8. for fine-tuning text rendering. It supports `OpenType features
  9. <https://en.wikipedia.org/wiki/List_of_typographic_features>`__ to select
  10. alternate glyph shapes, and `Variable fonts
  11. <https://en.wikipedia.org/wiki/Variable_font>`__ to control the weight or
  12. spacing of a font precisely. You can also :opt:`select which font is used to
  13. render particular unicode codepoints <symbol_map>` and you can :opt:`modify
  14. font metrics <modify_font>` and even :opt:`adjust the gamma curves
  15. <text_composition_strategy>` used for rendering text onto the background color.
  16. The first step is to select the font faces kitty will use for rendering
  17. regular, bold and italic text. kitty comes with a convenient UI for choosing fonts,
  18. in the form of the *choose-fonts* kitten. Simply run::
  19. kitten choose-fonts
  20. and follow the on screen prompts.
  21. First, choose the family you want, the list of families can be easily filtered by
  22. typing a few letters from the family name you are looking for. The family
  23. selection screen shows you a preview of how the family looks.
  24. .. image:: ../screenshots/family-selection.png
  25. :alt: Choosing a family with the choose fonts kitten
  26. :width: 600
  27. Once you select a family by pressing the :kbd:`Enter` key, you
  28. are shown previews of what the regular, bold and italic faces look like
  29. for that family. You can choose to fine tune any of the faces. Start with
  30. fine-tuning the regular face by pressing the :kbd:`R` key. The other styles
  31. will be automatically adjusted based on what you select for the regular face.
  32. .. image:: ../screenshots/font-fine-tune.png
  33. :alt: Fine tune a font by choosing a precise weight and features
  34. :width: 600
  35. You can choose a specific style or font feature by clicking on it. A precise
  36. value for any variable axes can be selected using the slider, in the screenshot
  37. above, the font supports precise weight adjustment. If you are lucky the font
  38. designer has included descriptive names for font features, which will be
  39. displayed, if not, consult the documentation of the font to see what each feature does.
  40. .. _font_spec_syntax:
  41. The font specification syntax
  42. --------------------------------
  43. If you don't like the choose fonts kitten or simply want to understand and
  44. write font selection options into :file:`kitty.conf` yourself, read on.
  45. There are four font face selection keys: `font_family`, `bold_font`,
  46. `italic_font` and `bold_italic_font`. Each of these supports the syntax
  47. described below. Their values can be of three types, either a
  48. font family name, the keyword ``auto`` or an extended ``key=value`` syntax
  49. for specifying font selection precisely.
  50. If a font family name is specified kitty will use Operating System APIs to
  51. search for a matching font. The keyword ``auto`` means kitty will choose a font
  52. completely automatically, typically this is used for automatically selecting
  53. bold/italic variants once the :opt:`font_family` is set. The bold and italic
  54. variants will then automatically use the same set of features as the main face.
  55. To specify font face selection more precisely, a ``key=value`` syntax is used.
  56. First, let's look at a few examples::
  57. # Select by family only, actual face selection is automatic
  58. font_family family="Fira Code"
  59. # Select an exact face by Postscript name
  60. font_family postscript_name=FiraCode
  61. # Select an exact face by family with features and variable weight
  62. font_family family=SourceCodeVF variable_name=SourceCodeUpright features="+zero cv01=2" wght=380
  63. The following are the known keys, any other keys are names of *variable axes*,
  64. that is, they are used to set the variable value for some font characteristic.
  65. ``family``
  66. A font family name. A family typically has multiple actual font faces, such
  67. as bold and italic variants. One or more of the faces can even be variable,
  68. allowing fine tuning of font characteristics.
  69. ``style``
  70. A style name to choose a particular font from a given family. Useful only
  71. with the ``family`` key, when no more precise methods for face selection
  72. are specified. Can also be used to specify a named variable style for
  73. variable fonts.
  74. ``postscript_name``
  75. The actual postscript name for a font face. This allows selecting a
  76. particular variant within a font family. But note that postscript names
  77. are usually insufficient for selecting variable fonts.
  78. ``full_name``
  79. This can be used to select a particular font face in a family. However, it
  80. is less precise than ``postscript_name`` and should not generally be used.
  81. ``variable_name``
  82. Some families with variable fonts actually contain multiple font files. For
  83. example, a family could have variable weights with one font file containing
  84. upright variable weight faces and another containing italic variable weight
  85. faces. Well designed fonts use a *variable name* to distinguish between
  86. such files. Should be used in conjunction with ``family`` to select a
  87. particular variable font file.
  88. ``features``
  89. A space separated list of OpenType font features to enable/disable or
  90. select a value of, for this font. Consult the documentation for the font
  91. family to see what features it supports and their effects. The exact syntax
  92. for specifying features is `documented by HarfBuzz
  93. <https://harfbuzz.github.io/harfbuzz-hb-common.html#hb-feature-from-string>`__
  94. ``system``
  95. This can be used to pass an arbitrary string, usuall a family or full name
  96. to the OS font selection APIs. Should not be used in conjunction with any
  97. other keys. Is the same as specifying just the font name without any keys.
  98. In addition to these keys, any four letter key is treated as the name of a
  99. variable characteristic of the font. It's value is used to set the value for
  100. the name.