[SOLVED] Linux system and Firefox font name are different

Discussion of general topics about Mozilla Firefox
Post Reply
User avatar
ineuw
Posts: 743
Joined: March 19th, 2006, 4:17 pm
Location: Québec, Canada

[SOLVED] Linux system and Firefox font name are different

Post by ineuw »

Firefox and Linux Mint System DejaVu font names are different. Linux uses the free font version(?) which appends the word "Book" to the name
Using it in user.js fails. I am curious how Firefox manages this internally when the font is set in Settings, but not from the user.js?

This fails:

Code: Select all

user_pref("font.name.monospace.x-western", "DejaVu Mono Book");
user_pref("font.name.sans-serif.x-western", "DejaVu Sans Book");
user_pref("font.name.serif.x-western", "DejaVu Serif Book");
Last edited by ineuw on April 3rd, 2022, 12:41 pm, edited 2 times in total.
Firefox 115.0.2 (default install) in Linux Mint 21.2 Cinnamon 64 bit, updated on 2023-07-31 00:05
morat
Posts: 6427
Joined: February 3rd, 2009, 6:29 pm

Re: System and Firefox font name are different

Post by morat »

Honestly, I'm sure what you are asking. Firefox likely gets a list of the system fonts in the C++ code.

There is a difference between the internal font name and the font filename.

Font Naming
http://silnrsi.github.io/FDBP/en-US/Font_Naming.html

Here is how to create a list of all DejaVu fonts in the system clipboard.

Code: Select all

(function () {
  var fontEnumerator = Components.classes["@mozilla.org/gfx/fontenumerator;1"].
    getService(Components.interfaces.nsIFontEnumerator);
  var allFonts = fontEnumerator.EnumerateAllFonts({});
  var dejaVuFonts = [];
  for (var i = 0; i < allFonts.length; i++) {
    if (/DejaVu/i.test(allFonts[i])) dejaVuFonts.push(allFonts[i]);
  }
  var clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].
    getService(Components.interfaces.nsIClipboardHelper);
  clipboardHelper.copyString(dejaVuFonts.join(", "));
})();
You can evaluate the code snippet in the browser console.

My output: DejaVu Math TeX Gyre, DejaVu Sans, DejaVu Sans Mono, DejaVu Serif

I used a similar code snippet to troubleshoot Thunderbird fonts.

Other thread: http://forums.mozillazine.org/viewtopic ... #p14796116
User avatar
ineuw
Posts: 743
Joined: March 19th, 2006, 4:17 pm
Location: Québec, Canada

Re: System and Firefox font name are different

Post by ineuw »

morat wrote:Honestly, I'm sure what you are asking. Firefox likely gets a list of the system fonts in the C++ code.
Thanks for the reply. You are right because my post was poorly composed. The issue is a Linux Mint issue and not Firefox. But since I noticed the name differences between the system and Firefox font names, I wondered how Firefox handles fonts. Are they referring to System fonts or an internal list? This, you clearly answered.

I brought this up, less so for myself because I resolved it by not using the Linux Mint font names, but look up in Firefox before specifying them in users.js.

I am attempting to use a single font family in Linux Mint System and all apps. The process is slow because previously selected font families mono font didn't show the text properly when editing. So thanks again.
Firefox 115.0.2 (default install) in Linux Mint 21.2 Cinnamon 64 bit, updated on 2023-07-31 00:05
User avatar
ElTxolo
Posts: 2811
Joined: July 30th, 2007, 9:35 am
Location: Localhost

Re: Linux system and Firefox font name are different

Post by ElTxolo »

ineuw wrote:Firefox and Linux Mint System DejaVu font names are different. Linux uses the free font version(?) which appends the word "Book" to the name

[....]
  • Image If you want to know, the real name of each font, use:

    Code: Select all

    fc-list | grep -i ['font name']
    
    In your example, with the font DejaVu:
    
    fc-list | grep -i dejavu
    


    Graphic example:

    Image











    Cheers!! Image
How to Ask Questions The Smart Way - How to Report Bugs Effectively ;)
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20240318 SeaMonkey/2.53.18.2
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20240416 SeaMonkey/2.53.19 :lildevil:

~
User avatar
ineuw
Posts: 743
Joined: March 19th, 2006, 4:17 pm
Location: Québec, Canada

Re: Linux system and Firefox font name are different

Post by ineuw »

ElTxolo wrote:

Code: Select all

fc-list | grep -i ['font name']
Thanks for the snippet. This is what I found. the font-style for standard font of DejaVu is "Book" and Linux Mint appends this in their font name.

Code: Select all

/usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf: DejaVu Serif:style=Bold
/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf: DejaVu Sans Mono:style=Book
/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf: DejaVu Sans:style=Book
/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf: DejaVu Sans:style=Bold
/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf: DejaVu Sans Mono:style=Bold
/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf: DejaVu Serif:style=Book
Firefox 115.0.2 (default install) in Linux Mint 21.2 Cinnamon 64 bit, updated on 2023-07-31 00:05
User avatar
ElTxolo
Posts: 2811
Joined: July 30th, 2007, 9:35 am
Location: Localhost

Re: Linux system and Firefox font name are different

Post by ElTxolo »

ineuw wrote: [....] Thanks for the snippet.
  • You're welcome!! ;)









    Cheers!! 8-)
How to Ask Questions The Smart Way - How to Report Bugs Effectively ;)
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20240318 SeaMonkey/2.53.18.2
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20240416 SeaMonkey/2.53.19 :lildevil:

~
Post Reply