Telegram Persian font changed after upgrade to 18.10!

I encountered the exact same problem after upgrading Kubuntu 18.04 to 18.10 !

Trying to figure out what is this weird font, I browsed and found out that Telegram is using KacstArt font (probably because this is the first font in the list when it fetches all system fonts).

I solved my problem by limiting telegram font search-paths into a single isolated folder that contains only my desired font. The procedure goes like this:

  1. There is a font configuration file ~/.local/share/TelegramDesktop/tdata/fc-custom-1.conf open it up.
  2. Comment out all <dir> and <cachedir> entries there (simply wrap them between <!-- and -->).
  3. Add a <dir>[your desired folder]</dir> just after <fontconfig> at the beginning of the file with [your desired folder] being the path pointing to a custom folder containing only your desired font.
    (e.g. I created a folder in ~/.local/share/TelegramDesktop/tdata/myfonts then added tahoma.ttf and tahomab.ttf there)
  4. Restart telegram and enjoy.

Here is how I fixed this issue for Persian:

  • Close Telegram
  • Create directory: ~/.fonts
  • Add a font with its different weights [I used Vazir]
  • Create file: ~/.fonts.conf and add these lines to it:
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
    <match target="pattern">
        <test name="family" qual="any">
            <string>sans serif</string>
        </test>
        <edit mode="assign" binding="same" name="family">
            <string>Vazir</string>
        </edit>
    </match>
    <dir>~/.fonts</dir>
</fontconfig>

  • Clear font caches:

fc-cache -f -v

rm -r ~/.cache/fontconfig_11

  • Now open Telegram :)

Just remove it and install from Ubuntu archive.

sudo apt install snapd

sudo snap install telegram-desktop

Update: Since telegram 1.8.4 there is no fc-custom-1.conf file, so here is another solution (assuming that the telegram binary is in /opt/Telegram/Telegram):

  1. Create a config file for telegram font (path is optional):

    touch /opt/Telegram/fonts.conf
    

    and add these lines to it:

    <?xml version='1.0'?>
    <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
    <fontconfig>
    
     <match>
      <edit mode="prepend" name="family">
       <string>Vazir</string>
      </edit>
     </match>
    
     <dir>~/.local/share/fonts</dir>
     <dir>/usr/share/fonts/</dir>
    
    </fontconfig>
    

    I used Vazir font, if you want to use another font(e.g. Tahoma) you must change the <string>Vazir</string> to <string>Tahoma</string>.

  2. Modify the telegram .desktop file, which is located at ~/.local/share/applications/telegramdesktop.desktop, to:

    [Desktop Entry]
    Version=1.0
    Name=Telegram Desktop
    Comment=Official desktop application for the Telegram messaging service
    TryExec=/opt/Telegram/Telegram
    Exec=env FONTCONFIG_FILE=/opt/Telegram/fonts.conf /opt/Telegram/Telegram -- %u
    Icon=telegram
    Terminal=false
    StartupWMClass=TelegramDesktop
    Type=Application
    Categories=Network;InstantMessaging;Qt;
    MimeType=x-scheme-handler/tg;
    Keywords=tg;chat;im;messaging;messenger;sms;tdesktop;
    X-GNOME-UsesNotifications=true
    X-Desktop-File-Install-Version=0.23
    
  3. Place your font in ~/.local/share/fonts.


Just simply remove this file by typing this command in your terminal :

killall Telegram && rm -rf ~/.local/share/TelegramDesktop/tdata/fc-custom-1.conf