How to resort font priority matches "Monospace"?

kde
font
terminal
fontconfig

#1

I have install and uninstall some fonts which leads to my monospace points to a fallback font not a mono font.

➜  ~ fc-match monospace
DroidSansFallbackFull.ttf: "Droid Sans Fallback" "Regular"

And then my terminal font shows not mono in reality. And the priority of font match monospace is:

➜  ~ fc-match -s monospace
DroidSansFallbackFull.ttf: "Droid Sans Fallback" "Regular"
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
DejaVuSansMono-Bold.ttf: "DejaVu Sans Mono" "Bold"
DejaVuSansMono-Oblique.ttf: "DejaVu Sans Mono" "Oblique"
NimbusMonoPS-Regular.otf: "Nimbus Mono PS" "Regular"
Hack-Regular.ttf: "Hack" "Regular"
DejaVuMathTeXGyre.ttf: "DejaVu Math TeX Gyre" "Regular"
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSerif.ttf: "DejaVu Serif" "Book"
NotoSansArmenian-Regular.ttf: "Noto Sans Armenian" "Regular"
NotoSansMono-Regular.ttf: "Noto Sans Mono" "Regular"
NotoSans-Regular.ttf: "Noto Sans" "Regular"
NotoSansChakma-Regular.ttf: "Noto Sans Chakma" "Regular"
NotoSansKhmer-Regular.ttf: "Noto Sans Khmer" "Regular"
NotoSansMyanmar-Regular.ttf: "Noto Sans Myanmar" "Regular"
NotoSerifAhom-Regular.ttf: "Noto Serif Ahom" "Regular"
NotoSerifKannada-Regular.ttf: "Noto Serif Kannada" "Regular"
NotoSerifSinhala-Regular.ttf: "Noto Serif Sinhala" "Regular"
Bitstream Vera Sans Mono Nerd Font Complete Mono Windows Compatible.ttf: "BitstreamVeraSansMono NF" "Roman"
LiberationMono-Regular.ttf: "Liberation Mono" "Regular"
Monaco_Linux.ttf: "Monaco" "Regular"
D050000L.otf: "D050000L" "Regular"
NotoMusic-Regular.ttf: "Noto Music" "Regular"
NotoNastaliqUrdu-Bold.ttf: "Noto Nastaliq Urdu" "Bold"
NotoSansAdlam-Regular.ttf: "Noto Sans Adlam" "Regular"
NotoSansAnatolianHieroglyphs-Regular.ttf: "Noto Sans Anatolian Hieroglyphs" "Regular"
NotoSansArabic-Regular.ttf: "Noto Sans Arabic" "Regular"
NotoSansAvestan-Regular.ttf: "Noto Sans Avestan" "Regular"
NotoSansBamum-Regular.ttf: "Noto Sans Bamum" "Regular"
NotoSansBassaVah-Regular.ttf: "Noto Sans Bassa Vah" "Regular"
NotoSansBatak-Regular.ttf: "Noto Sans Batak" "Regular"\
...

Then how to change mono point to like Hack-Regular.ttf?


#2

Honestly, don’t know what you try to do …
If you want to change the font in Konsole, just edit the Appearance of the Profile you are using.

image


#3

Hi, thanks for reply. But If I select Monospace font, the chars not aequilate in ternimal.

And Would you please run this command on your PC and show me the output? fc-match monospace.


#4

I don’t understand what you want to achieve either.
As @bogdancovaciu mentioned, you can select the font you want (Hack in this case) from the terminal settings, or from the settings of any other application that offers that option.

Anyway, to match the Hack font to monospace you can try adding the following content to the file ~/.config/fontconfig/fonts.conf (if the file does not exist, create it):

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
	<match target="pattern">
		<test name="family" qual="any">
   			<string>monospace</string>
  		</test>
  		<edit binding="strong" mode="prepend" name="family">
   			<string>Hack</string>
  		</edit>
	</match>
</fontconfig>

After that open Konsole and run the command fc-match monospace again to see if it returns the Hack font as a match (a logout/login might be needed before running the command).
If this didn’t make any difference, simply revert any changes you made.

The output of fc-match monospace before applying the changes was:

$ fc-match monospace
VeraMono.ttf: "Bitstream Vera Sans Mono" "Roman"

#5

Update file fonts.conf in $HOME/.config/fonts/ - you can define (or edit) alias for monospace here`:

  <alias>
    <family>monospace</family>
    <prefer><family>Input Mono Medium</family></prefer>
    <prefer><family>Ubuntu Mono</family></prefer>
    <prefer><family>Hack</family></prefer>
  </alias>

Order of "prefer"s is retained, name of family you can see in fc-match -s above
Hope this help I.


#6

Cause The application vnote which I use to write markdown and preview in-palce use .css to render and the font-family is Monospace.


closed #7

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.