1

How can I get the name of the default font (and default monospace font), in the format:

Ubuntu Mono:size=12:antialias=false

I'm aware of fc-list which gives me a list of all the fonts, but how can I know which one is the default font?

Use: I'm trying to launch xterm like this: xterm -fa Ubuntu Mono:size=12:antialias=false and auto-detect the default monospace font.

1

Use this, substituing monospace-font-name with font-name if you want the normal font instead:

# for normal font:
# font="$(gsettings get org.gnome.desktop.interface font-name)"

# for monospace font:
font="$(gsettings get org.gnome.desktop.interface monospace-font-name)"

font="${font//\'}"
font_name="${font% *}"
font_size="${font##* }"

echo "The font is:"
echo "$font_name:size=$font_size:antialias=false"
1
  • gsettings get org.gnome.desktop.interface + tab
    – qwr
    Oct 5 '19 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.