Arch Linux

 

Configuração de fontes no Xorg

De Wiki do Arch Linux Brasil


Tabela de conteúdo

X.org Font Configuração e aparência

Veja o Xorg Font Documentation para mais detalhes.
Veja a Página do Projeto FreeType2 para detalhes no Módulo freetype X.org.
Veja Optimal Use of Fonts on Linux para mais informações sobre as fontes no Linux.

módulos xorg.conf

  • freetype - suporte para fontes True Type (ttf, ttc), Type1 (pfa, pfb), CID (cid), CFF, Open Type, bitmap (bdf, pcf, snf), Windows (fnt), PFR, e Type42
  • speedo - suporte para fontes Bitstream Speedo (spd)
  • xtt - suporte para fontes True Type (ttf, ttc) (conflita com freetype)
  • bitmap - suporte para fontes bitmap (bdf, pcf, snf)

Como você pode ver, freetype já oferece tudo fornecido por esses outros módulos. Lembrando que xtt irá conflitar com freetype.

X.org Font Path e /etc/fonts/

xorg.conf font path

O font path descrito no arquivo xorg.conf é usado para fontes não Xft. Ele é válido para especificar a maioria das fontes aqui. Aplicações que não suportem Xft irão voltar ao font path do X. Eu prefiro manter o mínimo de fontes aqui - for use with xterm and its ilk.

Diretório de fontes /etc/fonts/

Os arquivos conf em /etc/fonts (fonts.conf e local.conf) são usados para fontconfig (fontes Xft). fonts.conf nunca deve ser modificado, todas as mudanças devem ser feitas no local.conf (para mudanças a nivel de sistema) ou ~/.fonts.conf (para mudanças em nível de usuário). Arquivos em /etc/fonts/conf.d são adicionados quando começam com um número e terminam com .conf.

Os diretórios listados em fonts.conf são adicionados pelo fc-cache para uso com fontconfig (/usr/share/fonts e ~/.fonts). Todas as fontes devem ser colocadas nesses diretórios. Se instalar novas fontes, execute o fc-cache -fv para detectar as alterações.

Adicionando novas fontes

Quando novas fontes são adicionadas, elas são apenas arquivos em seu sitema. Alguns utilitários precisam ser rodados para dizer ao sistema que novas fontes foram adicionadas.

/usr/bin/fc-cache

Isso irá atualizar o cache so fontconfig, partindo do ponto que as novas fontes podem ser localizadas pelo fontconfig (veja o item acima sobre /etc/fonts)

/usr/bin/mkfontscale
/usr/bin/mkfontdir
ln -s /usr/X11R6/lib/X11/fonts/encodings/encodings.dir encodings.dir

Esses utilitários precisam ser rodados de dentro do diretório das novas fontes. mkfontscale cria o arquivo fonts.scale e mkfontdir cria o arquivo fonts.dir. Estes arquivos são usados pelo X, e só precisam ser criados se as fontes são servidas pelo FontPath do X.org. As codificações soft link autorizam o X a utilizar essas novas fontes abaixo das codificações suportadas. Depois disso, você deverá ter 3 arquivos novos no diretório: fonts.scale, fonts.dir, e encodings.dir.

Utilitários fc-list e xlsfont

Esses utilitários irão listar, pela linha de comando, todas as fontes disponiveis para cada fonte do subsystem. fc-list irá listar todas as fontes do fontconfig, enquanto xlsfont irá listar todas as fontes do X. Isso é útil se combinado com grep, ou seja "xlsfonts || grep -i bitstream" para ver todas as fontes bitstream disponíveis.

Alguns Downloads de Fontes

Extras

LCD filter Patches

-lcd

-cleartype

Minhas fontes parecem lixo - Eu configurei tudo corretamente mas parece que eu simplesmente tenho fontes ruins.

Eu iria sugerir os pacotes do pacman para corrigir isso:

pacman -S ttf-ms-fonts ttf-cheapskate artwiz-fonts

Uma alternativa seria remover os pacotes de 75/100dpi e instalar o pacote Bitstream Vera que oferece boas fontes para o terminal e podem fazer o navegador de internet (ao menos no Firefox) parecer melhor:

pacman -Rns xorg-fonts-75dpi xorg-fonts-100dpi
pacman -S ttf-bitstream-vera

Eu tenho alguns aplicativos compilados no Gtk+ 2.2 e inferior e as fontes continuam parecendo lixo.

Sim, isso acontece. Aplicativos GTK modernos habilitam Xft por padrão, no entanto, antes do 2.2 isso não era o caso. Talvez esses aplicativos devam ser atualizados para um GTK mais novo. Se isso não é uma opção, então adicionar a linha export GDK_USE_XFT=1 ao arquivo de configurações globais (/etc/profile, /etc/profile.d/gnome.sh, ~/.xinitrc, etc) irá habilitar o Xft para aplicativos mais antigos.

Eu tenho um problema semelhante ao anterior com aplicativos antigos baseados em Qt.

Solução semelhante, adicione export QT_XFT=true em algum lugar.

Fontes nos aplicativos Gtk são muito pequenas quando estou usando KDE

Instale gtk-qt-engine:

pacman -Sy gtk-qt-engine
  • Mude o tamanho da fonte para aplicativos Gtk no 'KDE Control Center' (kcontrol, in package kdebase) -> `Appearance & Themes' -> `GTK Styles and Fonts'.

The bytecode interpreter makes my fonts look crappy, and it's compiled in, do I need to recompile?

Nope, not at all. Freetype's internal auto-hinting is just shut off. In some distros, the bytecode interpreter is compiled in and enabled by default. As a result, the bytecode interpreter overrides the freetype autohinter (which the developers are very proud of). To force the autohinter to be on, add the following to /etc/fonts/local.conf or ~/.fonts.conf

     <match target="pattern">
        <edit name="autohint" mode="assign">
           <bool>true</bool>
        </edit>
     </match>

Or change to the /etc/fonts/conf.d directory, and link the 10-autohint.conf file from the conf.avail directory into the conf.d directory. The following commands should work (the second command must be run with superuser privileges).

cd /etc/fonts/conf.d
ln -s ../conf.avail/10-autohint.conf

Question: I don't understand this... The bytecode interpreter is supposed to beat the autohinter by a long shot so i don't see why anyone would want the autohinter.
Reply: It appears that the bytecode interpreter in the 2.3 branch is quite poor. There's a forum post about it here: http://bbs.archlinux.org/viewtopic.php?id=29976. The above code made fonts much better for me. Although they didn't come into effect until after I rebooted - no idea why.

Autohint works great but not for my bold fonts. How can I turn it off only for bold fonts?

Autohinter can give you nice fonts but often makes fonts too wide. This is especially annoying with bold fonts. Fortunately you can turn off autohinter for bold fonts while leaving it on for the rest.

  • First turn on autohinter (see above) and add the following to ~/.fonts.conf
     <match target="font">
         <test name="weight" compare="more">
             <const>medium</const>
         </test>
         <edit name="autohint" mode="assign">
             <bool>false</bool>
         </edit>
     </match>

I have a TFT/DFP/LCD display uses a DVI cable and fonts look odd and fuzzy

This is due to rendering differences between CRTs and non-CRTs. To fix this problem, you need to enable sub-pixel rendering. Edit the ~/.fonts.conf file. Add the following section to enable this feature. NOTE that this will do nothing but a minor amount of extra work on CRTs and does not improve the display quality. Possible values for the const section include - rgb, bgr, vrgb, bgrv, and none.

< !-- Enable sub-pixel rendering -->
<match target="font" >
 <edit mode="assign" name="rgba" >
  <const>rgb</const>
 </edit>
</match>

I don't want my fonts Antialiased under a certain point size.

A sample of this is in the /etc/fonts/local.conf file. It is commented, just like the subpixel rendering section. Changes, if anything, should be made to the compare="less_eq" portion, and the <int>12</int> portion - these are the comparison operation and point size to compare, respectively.

     <match target="pattern">
        <test qual="any" name="size" compare="less_eq">
           <int>12</int>
        </test>
        <edit name="antialias" mode="assign"><bool>false</bool></edit>
     </match>

Estou usando fontes MS TrueType (verdana) e gostaria de habilitar o anti-aliasing, mas apenas para fontes maiores que parecem muito serrilhadas.

     <?xml version="1.0"?>
     <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
     <fontconfig>
     <match target="font" >
     <test compare"more" name"size" qual="any" >
     <double>12</double>
     </test>
     <edit mode"assign" name"antialias" >
     <bool>true</bool>
     </edit>
     </match>
     <match target="font" >
     <test compare"more" name"pixelsize" qual="any" >
     <double>17</double>
     </test>
     <edit mode"assign" name"antialias" >
     <bool>true</bool>
     </edit>
     </match>
     </fontconfig>

Eu quero adicionar mais fontes.

Salve suas fontes em um diretório e o adicione no ~/.fonts.conf

    < !-- Additional font directories -->
    <dir>/path/to/dir</dir>

I want my font sizes to match my DPI settings

Edit ~/.fonts.conf with the following. This setting should match your dpi settings in either xorg.conf or your startx command. Use xdpyinfo to get your current dpi setting. Most people recommend/use a value of 96 or 100. Changing and setting the dpi of X is beyond the scope of this document (see Xorg DisplaySize/DPI).

     <match target="pattern">
        <edit name="dpi" mode="assign"><double>100</double></edit>
     </match>

Eu não gosto da fonte <escolha o nome aqui> e gostaria de usar a <outro nome de fonte> no lugar

A forma mais segura de fazer isso, é adicionar um fragmento XML similar ao abaixo no ~/.fonts.conf. Isso fará com que o Bitstream Vera Sansseja usado no lugar do Helvetica:

<match target="pattern" name="family" >
 <test name="family" qual="any" >
  <string>Helvetica</string>
 </test>
 <edit mode="assign" name="family" >
  <string>Bitstream Vera Sans</string>
 </edit>
</match>


Uma abordagem alternativa, é adicionar a fonte "preferida", mas mas isso só funciona se a fonte original não estiver no sistema. Nesse caso, a fonte eespecificou será substituida:

     < !-- Replace Helvetica with Bitstream Vera Sans Mono -->
     < !-- Note, an alias for Helvetica should already exist in default conf files -->
     <alias>
        <family>Helvetica</family>
        <prefer><family>Bitstream Vera Sans Mono</family></prefer>
        <default><family>fixed</family></default>
     </alias>

I have tons of disgusting pixel fonts that I don't want

The only two fonts that you absolutely have to have in order to start X are 'cursor' and 'fixed', both of which are in the fonts/misc directory. If you want to get rid of all the pixel fonts besides these two, you can delete all the files in the misc directory besides cursor.pcf.gz and all the fonts that are similar to either 9x18.pcf.gz or 9x18-ISO8859-1.pcf.gz. When I deleted all the fonts besides those from the misc directory, I had about 337 files still in it, so if you have a lot less than that you should probably put them back before restarting X.

Something or someone disabled all my non-scalable (bitmap) fonts, I want them back

By default, fontconfig 2.3.2-4 and higher will disable the use of bitmap fonts. This setting is managed in /etc/fonts/conf.d/10-no-bitmaps.conf, or in higher versions, /etc/fonts/conf.d/10-bitmaps.conf. To enable bitmap fonts and keep them enabled after upgrades of fontconfig, place a symlink from yes-bitmaps.conf to 10-bitmaps.conf, overwriting the symlink to no-bitmaps.conf.

Simular os estilos negrito e italico para fontes incompletas

O Freetype já teve essa capacidade por algum tempo, mas apenas se o aplicativo requisitar (o que nunca acontece) - de qualquer forma, ele não vai adicionar os estilos negrito ou itálico para aquelas fontes regulares. Para faze-las, você precisa editar /usr/share/fonts/fonts.cache-1 manulmente (e manter sua modificação em algum lugar, pois a atualizações de fontes (fc-cache) o subistitui. Suponha que você tenha uma fonte Dupree:

     "dupree.ttf" 0 "Dupree:style=Regular:slant=0:weight=80:width=100:foundry=unknown:index=0:outline=True:....

Duplique a linha e mude style=Regular para style=Bold ou outros estilos que você queira. Também modifique slant=0 para slant=100 para italico, weight=80 para weight=200 para negrito (combine para negrito itálico):

     "dupree.ttf" 0 "Dupree:style=Bold Italic:slant=100:weight=200:width=100:foundry=unknown:index=0:outline=True:....

Agora adicione as modificações necessárias para ~/.fonts.conf:

     <match target="font">
        <test name="family" qual="any">
           <string>Dupree</string>
           <!-- other fonts here .... -->
        </test>
        <test compare="more_eq" name="weight"><int>140</int></test>
        <edit mode="assign" name="embolden"><bool>true</bool></edit>
     </match>
     <match target="font">
        <test name="family" qual="any">
           <string>Dupree</string>
           <!-- other fonts here .... -->
        </test>
        <test compare="more_eq" name="slant"><int>80</int></test>
        <edit mode="assign" name="matrix">
           <times>
              <name>matrix</name>
              <matrix>
                 <double>1</double><double>0.2</double>
                 <double>0</double><double>1</double>
              </matrix>
           </times>
        </edit>
     </match>

(Note que você pode usar o negrito para fontes em negrito - para que o negrito pareça ainda mais forte)

Exemplo ~/.fonts.conf

Um ~/.fonts.conf de um desenvolvedor web retirado dos foruns. Faça back up da sua fonte atual e e dê uma chance a esse.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">

<!-- the cathectic LCD tweaks, from linuxquestions.org,
 http://www.linuxquestions.org/questions/showthread.php?postid=1361098#post1361098 -->

<fontconfig>

<!-- Disable sub-pixel rendering.
 X detects it anyway, and if you set this as well, it just looks really horrible  -->
<match target="font" >
	<edit mode="assign" name="rgba" >
	 <const>none</const>
	</edit>
 </match>
 <match target="font" >
	<edit mode="assign" name="hinting">
	 <bool>true</bool>
	</edit>
 </match>
 <match target="font" >
	<edit mode="assign" name="hintstyle">
	 <const>hintfull</const>
	</edit>
 </match>

<!-- The first part of the 'magic.'
 This makes the fonts start to look nice,
 but some of the shapes will be distorted, so hinting is needed still -->
 <match target="font" >
	<edit mode="assign" name="antialias">
	 <bool>true</bool>
	</edit>
 </match>

<!-- Autohinter is not turned on automatically.
 Only disable this if you have recompiled Freetype with the bytecode interpreter,
 which is run automatically.<br />  -->
 <match target="pattern" >
	<edit mode="assign" name="autohint">
	 <bool>true</bool>
	</edit>
 </match>
 <match target="font">
		 <test name="weight" compare="more">
				 <const>medium</const>
		 </test>
		 <edit name="autohint" mode="assign">
				 <bool>false</bool>
		 </edit>
 </match>
<!-- Helvetica is a non true type font, and will look bad.
 This replaces it with whatever is the default sans-serif font -->
 <match target="pattern" name="family" >
	<test name="family" qual="any" >
	 <string>Helvetica</string>
	</test>
	<edit mode="assign" name="family" >
	 <string>sans-serif</string>
	</edit>
 </match>
 <dir>~/.fonts</dir>
</fontconfig>
Ferramentas pessoais
TOOLBOX
LANGUAGES