Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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