Fonts (Українська)

From ArchWiki

Цю стаття чи розділ ще не перекладено. Дивіться також Команда перекладу ArchWiki українською.

Причина: Partial translation (Обговорення в Talk:Fonts (Українська)#)

З Вікіпедії: Комп'ю́терні шрифти́ — це сукупність графічних символів, що зберігаються в пам'яті комп'ютера у вигляді растрових точок чи векторних зображень.

Майте на увазі, що деякі шрифти можуть бути захищені авторським прввом, а їх використання — обмеженим законом.

Види шрифтів

Зараз, більшість комп'ютерних шрифтів це або растрові, або векторні шрифти.

Растрові шрифти
Зберігаються в пам'яті комп'ютера як масив з точок. Таким чином зберігається кожнен розмір кожного гліфа. Кількість можливих розмірів шрифта обмежена.
Векторні шрифти
Всі гліфи задаються як набір кривих Безьє та математичних формул. Таким чином шрифт можна розтягувати до будь-якого розміру.

Формати файлів растрових шрифтів

These formats can also be gzipped. See #Растрові for the available bitmap fonts.

Формати файлів растрових шрифтів

  • PostScript fonts від Adobe: буває в різних варіянтах, як от Printer Font ASCII (PFA) або Printer Font Binary (PFB)
  • TrueType від Apple та Microsoft (розширення: ttf)
  • OpenType від Microsoft, створений на основі TrueType (розширення: otf, ttf)

В більшості випадків різницею між TrueType та OpenType можна знехтувати.

Інші формати

Так повелося, що TeX та його супутня програма Metafont, вакористовують власний спосіб відображення тексту. Серед ферматів, які використовують ці дві програми є: *pk, *gf, mf та vf. Сучасні версії можуть працювати й з TrueType та OpenType.

FontForge (fontforge) — це програма для створення шрифтів. Вона може зберігати їх у своєму внутрішньому форматі — sfd, spline font database.

SVG зображення мають спеціальний формат опису шрифтів.

Встановлення

There are various methods for installing fonts. Встановлювати шрифти можна різними способами.

Pacman

Через pacman можна встановлювати як шрифти, так і цілі шрифтові набори.

Знайти наявні шрифти можна якщо надіслати запит до бази даних (шукати слова font або ttf).

Створення пакунків

Ви можете керувати шрифтами за допомогою pacman. Для цього потрібно створити пакунок Arch Linux. Потім ним можна поділитися із загалом в AUR. Щоби дізнатися, як правильно оформити пакунок зі шрифтами, прочитайте поради щодо створення пакунків шрифтів..

Дізнатися назву сімейства шрифту, можна за допомогою команди fc-query. Наприклад: fc-query -f '%{family[0]}\n' /шлях/до/файлу. Інструкцію до її використання можна почитати в FcPatternFormat(3).

Встановлення вручну

Найкращий спосіб керування сторонніми шрифтами описаний в розділі #Створення пакунків. Таким чином ви матимете змогу прибирати чи оновлювати їх через pacman.

Або ж, ви можете встановлювати шрифти власноруч:

  • Щоби встановити лише для себе, помістіть їх у теку ~/.local/share/fonts/.
    • Здебільшого, цього буде достатньо. Хіба що ви будете запускати графічні програми від імені інших користувачів.
    • Раніше використовувалась тека ~/.fonts/ — більше ні.
  • Щоб установити шрифт для всіх користувачів, помістіть його у теку /usr/local/share/fonts/.
    • Якщо теки немає, створіть її; mkdir -p /usr/local/share/fonts.
    • У теці /usr/share/fonts/ знаходяться шрифти, встановлені через pacman. Краще туди не лізти.

Ви можете впорядковувати теку так, як вам заманеться. Наприклад, можна тримати кожен шрифт в окремій теці. Теки зі шрифтами переглядаються рекурсивно, тому вкладені файли не будуть пропущені.

Ось приклад того, як можна впорядкувати теку зі шрифтами:

/usr/local/share/fonts/
├── otf
│   └── SourceCodeVariable
│       ├── SourceCodeVariable-Italic.otf
│       └── SourceCodeVariable-Roman.otf
└── ttf
    ├── AnonymousPro
    │   ├── Anonymous-Pro-B.ttf
    │   ├── Anonymous-Pro-I.ttf
    │   └── Anonymous-Pro.ttf
    └── CascadiaCode
        ├── CascadiaCode-Bold.ttf
        ├── CascadiaCode-Light.ttf
        └── CascadiaCode-Regular.ttf

Також, необхідно, щоб усі користувачі мали доступ до читання цих файлів. Файли повинні мати принаймні chmod 444 а теки — 555.


Якщо ви хочете, щоб Xserver завантажував шрифти напряму (а не з допомогою font server), новостворені теки зі шрифтами потрібно додати до списку FontPath. Цей список знаходиться у розділі Files вашого файлу налаштувань Xorg (/etc/X11/xorg.conf або /etc/xorg.conf). Дізнайтеся більше в розділі #Застарілі програми.

Зрештою, потрібно оновити кеш fontconfig-у (зазвичай цього робити не потрібно адже програми, що використовують бібліотеку fontconfig роблять це самі):

$ fc-cache

Застарілі програми

Якщо ваша програма не використовує fontconfig (як от програми GTK 1.x та xfontsel), то вам потрібно створити покажчик тек зі шрифтами:

$ mkfontscale
$ mkfontdir

Щоби включити до списку більше однієї теки водночас:

$ for dir in /тека/перша/ /тека/друга/; do xset +fp $dir; done && xset fp rehash

Якщо ж шрифти були встановлені в інші теки всередині, наприклад, /usr/share/fonts, то:

$ for dir in * ; do if [  -d  "$dir"  ]; then cd "$dir";xset +fp "$PWD" ;mkfontscale; mkfontdir;cd .. ;fi; done && xset fp rehash

Якщо, раптом, X сервер не зміг завантажити всіх шрифтів, то вам потрібно пересканувати всі файли з fonts.dir:

# xset +fp /usr/share/fonts/misc # Повідомити серверу X про нові теки
# xset fp rehash                # Перепросканувати їх

Щоб перевірити, чи певний шрифт був включений до списку:

$ xlsfonts | grep назва-шрифту
Примітка: Більшість пакунків самі переналаштують Xorg при встановленні. В такому разі, цей крок можна пропустити.

Все це можна зробити на загально-системному рівні у файлах /etc/X11/xorg.conf або /etc/X11/xorg.conf.d.

Нижче наведений приклад розділу з файлу /etc/X11/xorg.conf. Можете скласти власний список шляхів.

# Цим, ви повідомите X.Org про теки зі шрифтами
Section "Files"
    FontPath    "/usr/share/fonts/100dpi"
    FontPath    "/usr/share/fonts/75dpi"
    FontPath    "/usr/share/fonts/cantarell"
    FontPath    "/usr/share/fonts/cyrillic"
    FontPath    "/usr/share/fonts/encodings"
    FontPath    "/usr/share/fonts/misc"
    FontPath    "/usr/share/fonts/truetype"
    FontPath    "/usr/share/fonts/TTF"
    FontPath    "/usr/share/fonts/util"
EndSection

Попередження від Pango

Якщо ваша системи використовує Pango то вона спробує читати з fontconfig щоб зрозуміти, звідки брати файли шрифтів.

(process:5741): Pango-WARNING **: failed to choose a font, expect ugly output. engine-type='PangoRenderFc', script='common'
(process:5741): Pango-WARNING **: failed to choose a font, expect ugly output. engine-type='PangoRenderFc', script='latin'

Якщо ви отримали схожу помилку та/або бачите прямокутнички замість символів у програмах то значить, вам потрібно оновити кеш шрифтів. У наведеному прикладі використовується шрифт ttf-liberation, для наочності. Його потрібно установити як пакунок та запустити команду як root:

# fc-cache
/usr/share/fonts: caching, new cache contents: 0 fonts, 3 dirs
/usr/share/fonts/TTF: caching, new cache contents: 16 fonts, 0 dirs
/usr/share/fonts/encodings: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/encodings/large: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/util: caching, new cache contents: 0 fonts, 0 dirs
/var/cache/fontconfig: cleaning cache directory
fc-cache: succeeded

Щоб перевірити, чи шрифт встановлений:

$ fc-match
LiberationMono-Regular.ttf: "Liberation Mono" "Regular"

Пакунки шрифтів

У цьому списку наведені пакунки як із офіційних сховищ, так і з AUR. Шрифти, які підтримують Unicode мають позначку „Unicode“.

Порада: Archfonts — це Python скрипт, за допомогою якого можна отримати огляд всіх TTF шрифтів з AUR та офіційних сховищ.

Растрові

Примітка: pango 1.44 відмовився від підтримки FreeType на користь HarfBuzz у такий спосіб втративши підтримку BDF/PCF растрових шрифтів. Через це, деякі програми (як от gnome-terminal) більше не працюють з цими шрифтами. Замість них показуються прямокутнички. Див. FS#63297, Pango issue #386 та HarfBuzz issue #1897.

Ті, що працюють з Pango 1.44:

Латинка

Набори шрифтів

Пакунки, із базовим набором шрифтів:

  • Bitstream Vera (ttf-bitstream-vera) – містить моноширинні шрифти а також шрифти з та без зарубок. Шрифт Bitstream Vera Sans може заміняти Verdana.
  • Croscore fonts (ttf-croscore) – шрифти-замінники для Helvetica, Times, і Courier. Використовуються в Chrome OS
  • DejaVu fonts (ttf-dejavu) – Bitstream Vera зі збільшеним покриттям Unicode
  • Droid (ttf-droid) – стандартний шрифт у старих версіях Android. Містить багато символів Unicode. В тому числі азійські ієрогліфи. Проте не містить емоджі та графічні символи
  • GNU FreeFont (gnu-free-fonts) – містить моноширинні шрифти а також шрифти з та без зарубок. більшість символів латинки знаходяться в шрифтах URW (серед них: Nimbus Roman, Nimbus Sans), має непогане покриття Unicode але без азійських ієрогліфів
  • IBM Plex (ttf-ibm-plex) – з засічками, без засічок, стиснуті, та моноширинні із курсивом
  • Liberation fonts (ttf-liberation) – шрифти-замінники для Helvetica, Times, і Courier
  • Linux Libertine (ttf-linux-libertine) – шрифти з засічками (Libertine) та без них (Biolinum) що мають велике покриття Unicode
  • Microsoft fonts (ttf-ms-win11AUR) – шрифти з Windows 11 (потрібен інсталятор Windows 11)
  • Noto fonts (noto-fonts) – шрифти від Google з повним покриттям Unicode. (Якщо встановити ще й окремі залежні пакунки з емоджі та азійськими ієрогліфами)

Пакунки без базового набору:

Старі пакунки зі шрифтами від Microsoft:

  • Microsoft fonts (ttf-ms-fontsAUR) – Andalé Mono, Courier New, Arial, Arial Black, Comic Sans, Impact, Lucida Sans, Microsoft Sans Serif, Trebuchet, Verdana, Georgia, Times New Roman
  • Vista fonts (ttf-vista-fontsAUR) – Consolas, Calibri, Candara, Corbel, Cambria, Constantia

Моноширинні

Шрифти з лігатурами для програмування позначені символом ⟶ . Інші моноширинні шрифти можна знайти в розділах #Растрові і #Набори шрифтів.

Корисні сайти:

Sans-serif

Serif

Unsorted

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

Reason: This section should be absorbed into the Monospace/Serif/Sans-Serif structure (Discuss in Talk:Fonts (Українська))

Non-latin scripts

Ancient Scripts

  • ttf-ancient-fontsAUR – Font containing Unicode symbols for Aegean, Egyptian, Cuneiform, Anatolian, Maya, and Analecta scripts

Arabic

Bengali

Read Localization/Bengali#Fonts for details.

Braille

  • ttf-ubrailleAUR – Font containing Unicode symbols for braille

Chinese, Japanese, Korean, Vietnamese

Pan-CJK
Chinese

See Localization/Chinese#Fonts.

Japanese

See Localization/Japanese#Fonts.

Korean

See Localization/Korean#Fonts.

Vietnamese
  • ttf-hannom – Vietnamese TrueType font for chữ Nôm characters

Cyrillic

See also #Латинка.

  • ttf-paratypeAUR – Font family by ParaType: sans, serif, mono, extended cyrillic and latin, OFL license
  • otf-russkopisAUR – A free OpenType cursive font for Cyrillic script

Greek

Almost all Unicode fonts contain the Greek character set (polytonic included). Some additional font packages, which might not contain the complete Unicode set but utilize high quality Greek (and Latin, of course) typefaces are:

  • otf-gfsAUR – Selection of OpenType fonts from the Greek Font Society
  • ttf-mgopenAUR – Professional TrueType fonts from Magenta

Hebrew

  • opensiddur-hebrew-fontsAUR – Large collection of Open-source licensed Hebrew fonts. There are also few Latin, Greek, Cyrillic, Arabic, and Amharic.
  • culmusAUR – Nice collection of free Hebrew fonts.
  • alefbetAUR – 2 Hebrew fonts (at the moment): the commonly used "David Libre", and the handwriting font "Gveret Levin".
  • ttf-ms-fontsAUR – contains Arial and other fonts.

Indic

See Localization/Indic#Fonts.

Khmer

Mongolic and Tungusic

  • ttf-abkaiAUR – Fonts for Sibe, Manchu and Daur scripts (incomplete, currently in development)

Persian

Tai–Kadai

  • fonts-tlwgAUR – Collection of scalable Thai fonts
  • ttf-laoAUR – Lao TTF font (Phetsarath_OT)

Tibeto-Burman

Emoji and symbols

A section of the Unicode standard is designated for pictographic characters called "emoji".

Emoji fonts come in different formats: CBDT/CBLC (Google), SBIX (Apple), COLR/CPAL (Microsoft), SVG (Mozilla/Adobe).

Emojis should work without any configuration once you have at least one emoji font installed of supported format. Emoji font fallback according to the standard requires extra code to handle emoji.

For the discovery and input of Emoji see List of applications/Utilities#Text input.

Software CBDT/CBLC SBIX COLR/CPAL SVG Emoji font fallback
Freetype Yes Yes Yes No
Pango Freetype Yes
WebKitGTK Freetype Yes
Qt Freetype No [3] [4] [5]
Chromium Freetype Yes
Firefox Freetype Yes No, see Firefox#Font troubleshooting for workaround.
Note: Qt can only use first 255 fonts at a time [6]. Make sure you have an emoji font in your list of preferred fallback fonts.

CBDT/CBLC:

SVG:

  • otf-openmojiAUR – German University of Design in Schwäbisch Gmünd open-source Emoji 13.0.
  • ttf-twemoji-colorAUR – Twitter's open-source Emoji 13.0.

Outline only:

  • ttf-symbolaAUR – provides many Unicode symbols, including emoji.

Kaomoji are sometimes referred to as "Japanese emoticons" and are composed of characters from various character sets, including CJK and Indic fonts. For example, the following set of packages covers most of existing kaomoji: gnu-free-fonts, ttf-arphic-uming, and ttf-indic-otf.

Math

Additionally, texlive-core[пакет відсутній: replaced by texlive-basic] and texlive-fontsextra contain many math fonts such as Latin Modern Math and STIX fonts. See TeX Live#Making fonts available to Fontconfig for configuration.

Other operating system fonts

Fallback font order

Fontconfig automatically chooses a font that matches the current requirement. That is to say, if one is looking at a window containing English and Chinese for example, it will switch to another font for the Chinese text if the default one does not support it.

Fontconfig lets every user configure the order they want via $XDG_CONFIG_HOME/fontconfig/fonts.conf. If you want a particular Chinese font to be selected after your favorite Serif font, your file would look like this:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
   <family>serif</family>
   <prefer>
     <family>Your favorite Latin Serif font name</family>
     <family>Your Chinese font name</family>
   </prefer>
 </alias>
</fontconfig>
Tip:
  • If you use a Chinese locale, set LC_LANG to und to make this work. Otherwise both English and Chinese text will be rendered in the Chinese font.
  • After changing the configuration run fc-match -a monospace | head to verify your fallback font is set correctly.

You can add a section for sans-serif and monospace as well. For more information, have a look at the fontconfig manual.

See also Font configuration#Set default or fallback fonts.

Font alias

There are several font aliases which represent other fonts in order that applications may use similar fonts. The most common aliases are: serif for a font of the serif type (e.g. DejaVu Serif); sans-serif for a font of the sans-serif type (e.g. DejaVu Sans); and monospace for a monospaced font (e.g. DejaVu Sans Mono). However, the fonts which these aliases represent may vary and the relationship is often not shown in font management tools, such as those found in KDE and other desktop environments.

To reverse an alias and find which font it is representing, run:

$ fc-match monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

In this case, DejaVuSansMono.ttf is the font represented by the monospace alias.

Tips and tricks

List all installed fonts

You can use the following command to list all installed Fontconfig fonts that are available on your system.

$ fc-list

List installed fonts for a particular language

Applications and browsers select and display fonts depending upon fontconfig preferences and available font glyph for Unicode text. To list installed fonts for a particular language, issue a command fc-list :lang="two letter language code". For instance, to list installed Arabic fonts or fonts supporting Arabic glyph:

$ fc-list -f '%{file}\n' :lang=ar
/usr/share/fonts/TTF/FreeMono.ttf
/usr/share/fonts/TTF/DejaVuSansCondensed.ttf
/usr/share/fonts/truetype/custom/DroidKufi-Bold.ttf
/usr/share/fonts/TTF/DejaVuSansMono.ttf
/usr/share/fonts/TTF/FreeSerif.ttf

List installed fonts for a particular Unicode character

To search for monospace fonts supporting a particular Unicode codepoint:

$ fc-match -s monospace:charset=1F4A9

Set terminal font on-the-fly

This article or section needs expansion.

Reason: Where is the documentation for the escape codes? (Discuss in Talk:Fonts (Українська))

For terminal emulators that use X resources, e.g. xterm or rxvt-unicode, fonts can be set by using escape sequences. Specifically, echo -e "\033]710;$font\007" to change the normal font (*font in ~/.Xresources), and replace 710 with 711, 712, and 713 to change the *boldFont, *italicFont, and *boldItalicFont, respectively.

$font uses the same syntax as in ~/.Xresources and can be anything the terminal emulator will support. (Example: xft:dejavu sans mono:size=9)

Application-specific font cache

Matplotlib (python-matplotlib) uses its own font cache, so after updating fonts, be sure to remove ~/.matplotlib/fontList.cache, ~/.cache/matplotlib/fontList.cache, ~/.sage/matplotlib-1.2.1/fontList.cache, etc. so it will regenerate its cache and find the new fonts [8].

BiDirectional text in terminal

Run BiCon (bicon-gitAUR) in order to display correctly Arabic and Hebrew text inside the terminal.

See also