Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different font weights than unpatched font #1818

Open
3 tasks done
kocv59 opened this issue Mar 20, 2025 · 11 comments
Open
3 tasks done

Different font weights than unpatched font #1818

kocv59 opened this issue Mar 20, 2025 · 11 comments

Comments

@kocv59
Copy link

kocv59 commented Mar 20, 2025

Requirements

  • I have searched the issues for my issue and found nothing related or helpful
  • I have searched the FAQ for help
  • I have checked the Wiki for help

Experienced Behavior

Tried Ubuntu and Ubuntu Nerd Font for the same pages on the web.

Ubuntu displays 4 font-weights

  • first: 100, 200 and 300
  • second: 400 and 500
  • third: 600
  • fourth: 700, 800 and 900

Ubuntu Nerd Font displays 4 font-weights but they were changed

  • first: 100, 200 and 300
  • second: 400
  • third: 500
  • fourth: 600, 700, 800 and 900

Expected Behavior

Ubuntu Nerd Font should use the same weights as Ubuntu so things look same on the web and it can be a drop in replacement.

Example Symbols or Text

No response

Font Used

No response

Source of Font File

No response

Terminal Emulator (and the title of the terminal window)

No response

Operating System and Version

No response

Screenshots

No response

@Finii
Copy link
Collaborator

Finii commented Mar 25, 2025

The patching should not touch the weight.

Can you give more concrete information? Which of the Ubuntu fonts do you mean, and which files concretely?
How did you turn up with the weight numbers?

Ubuntu comes in 'new' and 'old', and if I remember correctly something with the weight changed there too (because the new font is originally a VF) 🤔

@kocv59
Copy link
Author

kocv59 commented Mar 25, 2025

/usr/share/fonts/ubuntu/UbuntuMono-R.ttf and /usr/share/fonts/TTF/UbuntuNerdFont-Regular.ttf. On archlinux it comes from ttf-ubuntu-font-family and ttf-ubuntu-nerd packages.

Try all font weights like this:

<div style='font-family: "Ubuntu"; font-weight: 100; '>100</div>
<div style='font-family: "Ubuntu Nerd Font"; font-weight: 100; '>100</div>

@Finii
Copy link
Collaborator

Finii commented Mar 26, 2025

Hmm,

/usr/share/fonts/ubuntu/UbuntuMono-R.ttf and /usr/share/fonts/TTF/UbuntuNerdFont-Regular.ttf

The left one is Ubuntu Mono while the right/patched one is Ubuntu (non Mono).

Lets look into the packages...

Image

Image

Okay, ttf-ubuntu-font-family contains the old Ubuntu font; to make this more clear at NerdFonts we put the new font as UbuntuSans*:

$ tree -P '*.ttf' src/unpatched-fonts/Ubuntu*
src/unpatched-fonts/Ubuntu
├── Bold
│   └── Ubuntu-B.ttf
├── Bold-Italic
│   └── Ubuntu-BI.ttf
├── Condensed
│   └── Ubuntu-C_modified.ttf
├── Light
│   └── Ubuntu-L.ttf
├── Light-Italic
│   └── Ubuntu-LI.ttf
├── Medium
│   └── Ubuntu-M.ttf
├── Medium-Italic
│   └── Ubuntu-MI.ttf
├── Regular
│   └── Ubuntu-R.ttf
└── Regular-Italic
    └── Ubuntu-RI.ttf
src/unpatched-fonts/UbuntuMono
├── Bold
│   └── UbuntuMono-B.ttf
├── Bold-Italic
│   └── UbuntuMono-BI.ttf
├── Regular
│   └── UbuntuMono-R.ttf
└── Regular-Italic
    └── UbuntuMono-RI.ttf
src/unpatched-fonts/UbuntuSans
├── Mono
│   ├── UbuntuSansMono-BoldItalic.ttf
│   ├── UbuntuSansMono-Bold.ttf
│   ├── UbuntuSansMono-Italic.ttf
│   ├── UbuntuSansMono-MediumItalic.ttf
│   ├── UbuntuSansMono-Medium.ttf
│   ├── UbuntuSansMono-Regular.ttf
│   ├── UbuntuSansMono-SemiBoldItalic.ttf
│   └── UbuntuSansMono-SemiBold.ttf
└── Sans
    ├── UbuntuSans-BoldItalic.ttf
    ├── UbuntuSans-Bold.ttf
    ├── UbuntuSans-Italic.ttf
    ├── UbuntuSans-MediumItalic.ttf
    ├── UbuntuSans-Medium.ttf
    ├── UbuntuSans-Regular.ttf
    ├── UbuntuSans-SemiBoldItalic.ttf
    └── UbuntuSans-SemiBold.ttf

Ok, lets examine the weights of the old Ubuntu fonts, unpatched:

Examining 13 font files

Ubuntu-C_modified.ttf      Weight approximations: OS2/PS/Name: 400/400/400 (from 400/'Book'/'')
Ubuntu-LI.ttf              Weight approximations: OS2/PS/Name: 300/300/300 (from 300/'Light'/'Light')
Ubuntu-L.ttf               Weight approximations: OS2/PS/Name: 300/300/300 (from 300/'Light'/'Light')
Ubuntu-RI.ttf              Weight approximations: OS2/PS/Name: 400/400/400 (from 400/'Book'/'')
Ubuntu-R.ttf               Weight approximations: OS2/PS/Name: 400/400/400 (from 400/'Book'/'')
Ubuntu-MI.ttf              Weight approximations: OS2/PS/Name: 500/500/500 (from 500/'Medium'/'Medium')
Ubuntu-M.ttf               Weight approximations: OS2/PS/Name: 500/500/500 (from 500/'Medium'/'Medium')
Ubuntu-BI.ttf              Weight approximations: OS2/PS/Name: 700/700/700 (from 700/'Bold'/'Bold')
Ubuntu-B.ttf               Weight approximations: OS2/PS/Name: 700/700/700 (from 700/'Bold'/'Bold')
UbuntuMono-RI.ttf          Weight approximations: OS2/PS/Name: 400/400/400 (from 400/'Book'/'')
UbuntuMono-R.ttf           Weight approximations: OS2/PS/Name: 400/400/400 (from 400/'Book'/'')
UbuntuMono-BI.ttf          Weight approximations: OS2/PS/Name: 700/700/700 (from 700/'Bold'/'Bold')
UbuntuMono-B.ttf           Weight approximations: OS2/PS/Name: 700/700/700 (from 700/'Bold'/'Bold')

Lets make that list more concise to match your list

Ubuntu-L.ttf               Weight approximations: OS2/PS/Name: 300/300/300 (from 300/'Light'/'Light')
Ubuntu-R.ttf               Weight approximations: OS2/PS/Name: 400/400/400 (from 400/'Book'/'')
Ubuntu-M.ttf               Weight approximations: OS2/PS/Name: 500/500/500 (from 500/'Medium'/'Medium')
Ubuntu-B.ttf               Weight approximations: OS2/PS/Name: 700/700/700 (from 700/'Bold'/'Bold')
Ubuntu displays 4 font-weights

    first: 100, 200 and 300
    second: 400 and 500
    third: 600
    fourth: 700, 800 and 900

Which is strange, Medium should be 500 [1] and it (you) claim the next font is only 600 🤔

And examine the patched fonts

======== UbuntuNerdFont-Light.ttf ========
Weight approximations: OS2/PS/Name: 300/300/300 (from 300/'Light'/'Light')

======== UbuntuNerdFont-Regular.ttf ========
Weight approximations: OS2/PS/Name: 400/400/400 (from 400/'Book'/'')

======== UbuntuNerdFont-Medium.ttf ========
Possible problem with the weight metadata detected
Weight approximations: OS2/PS/Name: 500/500/400 (from 500/'Medium'/'')

======== UbuntuNerdFont-Bold.ttf ========
Weight approximations: OS2/PS/Name: 700/700/700 (from 700/'Bold'/'Bold')

Ah!!

[1] https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#common_weight_name_mapping

Edit: Add link to name-number mapping

@Finii
Copy link
Collaborator

Finii commented Mar 26, 2025

This html thing seems to take the weights from the file name and not from the embedded metadata (o_O)

Why is the Medium font not detected as medium by my own code?
Examining the medium font

======== Ubuntu-M.ttf ========
SFNT Fullname      ID 4     Ubuntu Medium
SFNT Family        ID 1     Ubuntu Light
SFNT SubFamily     ID 2     Bold
SFNT Pref Family   ID 16    Ubuntu
SFNT Pref Styles   ID 17    Medium
SFNT PS Name       ID 6     Ubuntu-Medium
SFNT Compatible    ID 18    Ubuntu Medium
SFNT CID findfont  ID 20    -
SFNT WWS Family    ID 21    -
SFNT WWS SubFamily ID 22    -
PS fontname                 Ubuntu-Medium
PS fullname                 Ubuntu Medium
PS familyname               Ubuntu Light
fondname                    None
======== UbuntuNerdFont-Medium.ttf ========
SFNT Fullname      ID 4     Ubuntu Nerd Font Med
SFNT Family        ID 1     Ubuntu Nerd Font Med
SFNT SubFamily     ID 2     Regular
SFNT Pref Family   ID 16    Ubuntu Nerd Font
SFNT Pref Styles   ID 17    Medium
SFNT PS Name       ID 6     UbuntuNF-Med
SFNT Compatible    ID 18    -
SFNT CID findfont  ID 20    -
SFNT WWS Family    ID 21    -
SFNT WWS SubFamily ID 22    -
PS fontname                 UbuntuNF-Med
PS fullname                 Ubuntu Nerd Font Med
PS familyname               Ubuntu Nerd Font Med
fondname                    None

Ah, it abbreviates Medium to Med.

Well, still the behavior you describe is exactly what I would expect:

Ubuntu Nerd Font displays 4 font-weights but they were changed

    first: 100, 200 and 300
    second: 400
    third: 500
    fourth: 600, 700, 800 and 900

As we have fonts with 300, 400, 500, and 700.

@Finii
Copy link
Collaborator

Finii commented Mar 26, 2025

What is this?!? 😭

Image

Ah they introduce a new RIBBI group with Light-Medium next to Regular-Bold.

The font-patcher creates only one group of all fonts (which is what is usually expected).

Edit: Add explanation

@Finii
Copy link
Collaborator

Finii commented Mar 26, 2025

So, trying to reproduce, this is localinstalled font-family: 'Ubuntu Nerd Font';

$ fc-list | grep 'Ubuntu Nerd Font[^ ]' | grep -vi 'italic'
/home/fini/.local/share/fonts/UbuntuNerdFont-Regular.ttf: Ubuntu Nerd Font:style=Regular
/home/fini/.local/share/fonts/UbuntuNerdFont-Bold.ttf: Ubuntu Nerd Font:style=Bold
/home/fini/.local/share/fonts/UbuntuNerdFont-Condensed.ttf: Ubuntu Nerd Font,Ubuntu Nerd Font Cond:style=Condensed,Regular
/home/fini/.local/share/fonts/UbuntuNerdFont-Medium.ttf: Ubuntu Nerd Font,Ubuntu Nerd Font Med:style=Medium,Regular
/home/fini/.local/share/fonts/UbuntuNerdFont-Light.ttf: Ubuntu Nerd Font,Ubuntu Nerd Font Light:style=Light,Regular

Image

Which is all good and well, as expected.

Now trying to set up with the old Ubuntu font, which is a bit of a hassle because I have the new Ubuntu font system-installed...

$ fc-list | grep 'Ubuntu[^[NMS ]' | grep -vi 'italic'
/usr/share/fonts/truetype/ubuntu/Ubuntu-L.ttf: Ubuntu,Ubuntu Light:style=Light,Regular
/usr/share/fonts/truetype/ubuntu/Ubuntu-Th.ttf: Ubuntu,Ubuntu Thin:style=Thin,Regular
/usr/share/fonts/truetype/ubuntu/Ubuntu-B.ttf: Ubuntu:style=Bold
/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf: Ubuntu:style=Regular
/usr/share/fonts/truetype/ubuntu/Ubuntu-M.ttf: Ubuntu,Ubuntu Light:style=Medium,Bold
/usr/share/fonts/truetype/ubuntu/Ubuntu-C.ttf: Ubuntu Condensed:style=Regular

Image

So there is a new one at 200, but still 300, 400, 500, and 600.
And not the same weight at 400 and 500, and a new weight at 700.

So I must say I can not reproduce 🤔


Just documenting, this is how it's with the new Ubuntu font:

$ fc-list | grep 'Ubuntu[^[NMS ]' | grep -vi 'italic'
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Regular
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Medium
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Condensed Thin
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Light
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Condensed
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Condensed Medium
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Extra Bold
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Condensed Extra Bold
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Condensed Light
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Thin
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Bold
/usr/share/fonts/truetype/ubuntu/Ubuntu[wdth,wght].ttf: Ubuntu:style=Condensed Bold

Image

My "setup":

$cat ~/x.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="x.css">
<title>Page Title</title>
</head>
<body>
  <p class="w100">This is weight 100</p>
  <p class="w200">This is weight 200</p>
  <p class="w300">This is weight 300</p>
  <p class="w400">This is weight 400</p>
  <p class="w500">This is weight 500</p>
  <p class="w600">This is weight 600</p>
  <p class="w700">This is weight 700</p>
  <p class="w800">This is weight 800</p>
  <p class="w900">This is weight 900</p>

</body>
</html>
$ cat ~/x.css
body { font-family: 'Ubuntu'; }

.w100 { font-weight: 100; }
.w200 { font-weight: 200; }
.w300 { font-weight: 300; }
.w400 { font-weight: 400; }
.w500 { font-weight: 500; }
.w600 { font-weight: 600; }
.w700 { font-weight: 700; }
.w800 { font-weight: 800; }
.w900 { font-weight: 900; }

@kocv59
Copy link
Author

kocv59 commented Mar 26, 2025

In your last post I'm getting the same thing for the first screenshot for Ubuntu Nerd Font. Your last screenshot is different from what I get for Ubuntu. In firefox dev tools what do you see when you click on the Inspector Fonts what does it say for you?

First 3 are Ubuntu / Ubuntu Light
Next 2 are Ubuntu / Ubuntu
Next 1 is Ubuntu / Ubuntu Medium
Next 3 are Ubuntu / Ubuntu Bold

@Finii
Copy link
Collaborator

Finii commented Mar 26, 2025

This is with the 'old' Ubuntu font installed

Kooha-2025-03-26-21-49-01.mp4

100 - 200 Ubuntu Thin
300 Ubuntu Light
400 Ubuntu
500 Ubuntu Medium
600 - 700 - 800 - 900 Ubuntu Bold

Maybe you can upload your Medium font file in a comment here (put into a zip) and I check if it's the same as mine?

@Finii
Copy link
Collaborator

Finii commented Mar 26, 2025

Fonts used for the tests above (Ubuntu system package)

$ sha256sum /usr/share/fonts/truetype/ubuntu/Ubuntu-M.ttf
e801a0867295367000c6dd3c337622ae4aaff85786ddbfbdb985ce774fe3cd62  /usr/share/fonts/truetype/ubuntu/Ubuntu-M.ttf
$ ll /usr/share/fonts/truetype/ubuntu/Ubuntu-M.ttf
-rw-r--r-- 1 root root 341324 Jul 10  2015 /usr/share/fonts/truetype/ubuntu/Ubuntu-M.ttf
$ LC_ALL=C ll /usr/share/fonts/truetype/ubuntu
total 4308
-rw-r--r-- 1 root root 333612 Jul 10  2015 Ubuntu-B.ttf
-rw-r--r-- 1 root root 356980 Jul 10  2015 Ubuntu-BI.ttf
-rw-r--r-- 1 root root 350444 Jul 10  2015 Ubuntu-C.ttf
-rw-r--r-- 1 root root 415552 Jul 10  2015 Ubuntu-L.ttf
-rw-r--r-- 1 root root 409608 Jul 10  2015 Ubuntu-LI.ttf
-rw-r--r-- 1 root root 341324 Jul 10  2015 Ubuntu-M.ttf
-rw-r--r-- 1 root root 366992 Jul 10  2015 Ubuntu-MI.ttf
-rw-r--r-- 1 root root 353824 Jul 10  2015 Ubuntu-R.ttf
-rw-r--r-- 1 root root 386440 Jul 10  2015 Ubuntu-RI.ttf
-rw-r--r-- 1 root root 240020 Feb 18  2022 Ubuntu-Th.ttf
-rw-r--r-- 1 root root 191400 Sep 26  2011 UbuntuMono-B.ttf
-rw-r--r-- 1 root root 216208 Sep 26  2011 UbuntuMono-BI.ttf
-rw-r--r-- 1 root root 205748 Sep 26  2011 UbuntuMono-R.ttf
-rw-r--r-- 1 root root 210216 Sep 26  2011 UbuntuMono-RI.ttf

Ubuntu package name is fonts-ubuntu-classic

Fonts used by Nerd Font project

$ sha256sum src/unpatched-fonts/Ubuntu/Medium/Ubuntu-M.ttf
e801a0867295367000c6dd3c337622ae4aaff85786ddbfbdb985ce774fe3cd62  src/unpatched-fonts/Ubuntu/Medium/Ubuntu-M.ttf
$ LC_ALL=C ll src/unpatched-fonts/Ubuntu/**/*.ttf src/unpatched-fonts/UbuntuMono/**/*.ttf
-rw-rw-r-- 1 fini fini 356980 Jan  5 16:39 src/unpatched-fonts/Ubuntu/Bold-Italic/Ubuntu-BI.ttf
-rw-rw-r-- 1 fini fini 333612 Jan  5 16:39 src/unpatched-fonts/Ubuntu/Bold/Ubuntu-B.ttf
-rw-rw-r-- 1 fini fini 350444 Jan  5 16:39 src/unpatched-fonts/Ubuntu/Condensed/Ubuntu-C_modified.ttf
-rw-rw-r-- 1 fini fini 409608 Jan  5 16:39 src/unpatched-fonts/Ubuntu/Light-Italic/Ubuntu-LI.ttf
-rw-rw-r-- 1 fini fini 415552 Jan  5 16:39 src/unpatched-fonts/Ubuntu/Light/Ubuntu-L.ttf
-rw-rw-r-- 1 fini fini 366992 Jan  5 16:39 src/unpatched-fonts/Ubuntu/Medium-Italic/Ubuntu-MI.ttf
-rw-rw-r-- 1 fini fini 341324 Jan  5 16:39 src/unpatched-fonts/Ubuntu/Medium/Ubuntu-M.ttf
-rw-rw-r-- 1 fini fini 386440 Jan  5 16:39 src/unpatched-fonts/Ubuntu/Regular-Italic/Ubuntu-RI.ttf
-rw-rw-r-- 1 fini fini 353824 Jan  5 16:39 src/unpatched-fonts/Ubuntu/Regular/Ubuntu-R.ttf
-rw-rw-r-- 1 fini fini 216208 Jan  5 16:39 src/unpatched-fonts/UbuntuMono/Bold-Italic/UbuntuMono-BI.ttf
-rw-rw-r-- 1 fini fini 191400 Jan  5 16:39 src/unpatched-fonts/UbuntuMono/Bold/UbuntuMono-B.ttf
-rw-rw-r-- 1 fini fini 210216 Jan  5 16:39 src/unpatched-fonts/UbuntuMono/Regular-Italic/UbuntuMono-RI.ttf
-rw-rw-r-- 1 fini fini 205748 Jan  5 16:39 src/unpatched-fonts/UbuntuMono/Regular/UbuntuMono-R.ttf

Firefox used

Image

(This is the Debian package one, usually Ubuntu uses some snap crap.)

Edit: Use C locale for sane sort
Edit: Add Nerd Fonts used fonts
Edit: Add info on used browser

@Finii
Copy link
Collaborator

Finii commented Mar 26, 2025

Your last screenshot is different from what I get for Ubuntu

Well, in that comment (#1818 (comment)) I have three screenshots.

  1. Ubuntu Nerd Font
  2. old Ubuntu fonts
  3. new Ubuntu (Sans) Variable Font

So the last screenshot must be different, because you use the old Ubuntu fonts.
Also in the movie above etc I use the old Ubuntu fonts.

@kocv59
Copy link
Author

kocv59 commented Mar 26, 2025

Is the 3rd font in the archlinux repo like the other fonts (ttf-ubuntu-font-family and ttf-ubuntu-nerd)?

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

No branches or pull requests

2 participants