Skip to content

Instantly share code, notes, and snippets.

@Silica163
Last active May 30, 2025 20:57
Show Gist options
  • Select an option

  • Save Silica163/192d5603ff2e8d19d767a7576782b5f5 to your computer and use it in GitHub Desktop.

Select an option

Save Silica163/192d5603ff2e8d19d767a7576782b5f5 to your computer and use it in GitHub Desktop.
install thai font in linux

How to install Thai font on linux

Download font files

Go to fonts.google.com then search for Thai font family, select the one you like or many as you want. Click Download, you will got a zip file contains that font.

I don't know about other distro, but don't use aur/ttf-google-thai because it doesn't contain any glyph of Thai font.

You can also use noto-fonts but it is 108MiB large, to large if you only want thai font.

Install the downloaded font

Unzip it to ~/.local/share/fonts/ or /usr/share/fonts/ (also read your system configuration to see which path to extract to).

Edit fontconfig file for your font, then update fonts information cache files.


วิธีลง font ภาษาไทยบน linux

โหลด font

ไปที่ fonts.google.com แล้วก็หาฟ้อนต์ที่อยากโหลด จากนั้นก็กด Download มันจะให้มาเป็น zip

ถ้าใช้ Arch แนะนำว่าอย่าใช้ aur/ttf-google-thai เพราะมันไม่มี glyph ภาษาไทย

หรือจะใช้ noto-fonts ก็ได้ แต่มันขนาดใหญ่ไปถ้าจะใช้แค่ฟ้อนภาษาไทยอย่างเดียว

ติดตั้ง

แตกไฟล์ zip ที่โหลดมาที่ ~/.local/share/fonts/ ไม่ก็ /usr/share/fonts/ (ขึ้นอยู่กับแต่ละเครื่อง ต้องลองหาเอาตามคู่มือ)

แก้ fontconfig แล้วก็ update cache ข้อมลฟ้อนต์


Command

example file 99-thai-font.conf

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
    <match target="font">
        <test compare="contains" name="lang">
            <string>th</string>
        </test>
        <edit mode="assign" name="family">
            <string>Sarabun</string> <!-- replace with your font family -->
        </edit>
    </match>
    
    <!-- fallback font -->
    <!-- ถ้ามีหลายฟ้อนต์อยู่ในเครื่องแล้ว fontconfig ดันเลือกอันรองมาใช้แทนอันหลัก ก็เอาส่วนนี้ไปบังคับมันได้ -->
    <alias>
        <family>sans-serif</family>
        <prefer>
            <family>DejaVu Sans</family>
            <family>Sarabun</family>
        </prefer>
    </alias>
    <alias>
        <family>serif</family>
        <prefer>
            <family>DejaVu Sans</family>
            <family>Sarabun</family>
        </prefer>
    </alias>
</fontconfig>
cd <path/to/font/directory>
unzip <path/to/zip/file>      # extract file
mkfontdir -r
mkfontscale
# edit config file
fc-cache -fv                  # update cahce
@yxkhkhiw
Copy link

yxkhkhiw commented Mar 5, 2025

มีปัญหากับ line height แก้ยังไงครับ font K2D
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment