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

Ubuntu Nerd Font Regular showing up as Condensed. #1228

Closed
3 tasks done
ffernand opened this issue May 10, 2023 · 10 comments · Fixed by #1231
Closed
3 tasks done

Ubuntu Nerd Font Regular showing up as Condensed. #1228

ffernand opened this issue May 10, 2023 · 10 comments · Fixed by #1231

Comments

@ffernand
Copy link

🗹 Requirements

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

🎯 Subject of the issue

Experienced behavior:
The font Ubuntu Nerd Font which should compare against the regular Ubuntu font has the style Regular show up as Condensed.

The app I used to display the following is from the gtk font manager.

The following font belongs to the system and is what I expect.

20230510T160412_maim


The Ubuntu Nerd Font installed locally shows Regular as Condensed.

20230510T160523_maim

Incidentally, there is a Ubuntu Condensed specific font that isn't represented in the Nerd Font set. I have no need for this font, but I thought I'd point it out since this specific font has been rolled-up into a style in the base Ubuntu Nerd Font (which makes sense).

Expected behavior:
That the Regular style and the Condensed style should both be distinct. The Ubuntu Nerd Font Regular style should have the same style as Ubuntu Regular.

🔧 Your Setup

  • Which font are you using (e.g. Anonymice Powerline Nerd Font Complete.ttf)?
    • UbuntuNerdFont-Regular.ttf
  • Where did you get the file from (download link, self patched, source downloaded from link...)
  • Which terminal emulator are you using (e.g. iterm2, urxvt, gnome, konsole)?
    • This problem showed up in dunst notifications (not terminal). But is problematic in any other app that uses the font.
  • Are you using OS X, Linux or Windows? And which specific version or distribution?
    • Linux (ArchLinux)

★ Screenshots (Optional)

20230510T160729_maim

@Finii
Copy link
Collaborator

Finii commented May 11, 2023

Can reproduce

image

Naming looks like this

image

Lets see...

@Finii Finii added this to the v3.0.1 milestone May 11, 2023
@Finii
Copy link
Collaborator

Finii commented May 11, 2023

🤔 Why does it list 9 variations on your system and only 7 on my? I just copied all fonts over?

image

Light and Bold is missing??!

Even more strangeness in the Propo section

image

Correct in writer

image

When I switch from User to All it shows 9 instead of 7?
This thing has a bug.

image

image

And why do 'System' and 'User' not sum up to 'All'?

Anyhow, there is a problem with the Postscript Name it seems.


image


Should be detected as width variation 🤔
image

But wrong using width as weight?

image

This was also the with v2.3.3, the last change for v3.0.0 did not in principle change that.

image

Correct as Adobe spec, the example has condensed in it:

image


Well, the original Ubuntu font makes the Condensed font a width: Regular, which is of course questionable and which is corrected by the FontnameTools (because they create the naming from scratch). At least it contradicts the Adobe spec.

image

For example Noto also puts Condensed 'after the dash' (as Nerd Fonts does)

image

Unpatched Noto Sans ... the Condensed is listed with the main widths...

image

Ubuntu unpatched has a different (somehow non-conforming) approach here. Nerd Fonts strives to create conforming fonts.

Incidentally, there is a Ubuntu Condensed specific font that isn't represented in the Nerd Font set. I have no need for this font, but I thought I'd point it out since this specific font has been rolled-up into a style in the base Ubuntu Nerd Font (which makes sense).

So this is not a problem.

But still, there is a problem, the rendering is taking the wrong font.
(And 'User' misses some)

@Finii
Copy link
Collaborator

Finii commented May 11, 2023

Now comparing with Noto only for wrong rendering (and maybe missing in 'User'):

Naming is comparable to NotoSans

image

We do not add -Regular to the PS name. Is that correct?
We do not add Regular to the FullName, which is the recommended approach iirc.


A look at fontconfig:

image

$ fc-list | grep '(UbuntuNerdFont|NotoSans)-(Regular|Condensed)\.'
/home/fini/.local/share/fonts/NotoSans-Regular.ttf:         Noto Sans                              : style=Regular
/home/fini/.local/share/fonts/NotoSans-Condensed.ttf:       Noto Sans,Noto Sans Cond               : style=Condensed,Regular

/home/fini/.local/share/fonts/UbuntuNerdFont-Regular.ttf:   Ubuntu Nerd Font                       : style=Regular
/home/fini/.local/share/fonts/UbuntuNerdFont-Condensed.ttf: Ubuntu Nerd Font,Ubuntu Nerd Font Cond : style=Condensed,Regular

Looks the same.

Ah

image

Why is it not picking up the width specifier...

image

"Condensed" is also missing in the rendered example text on the right 🤔

Obviously not a problem of the abbreviation in the PS name

image


Very strange. Had a look at FontManager's source and it get all information from fontconfig, and THAT reports the correct style(s).

@Finii
Copy link
Collaborator

Finii commented May 11, 2023

Built from source (github HEAD), same problem

image

Stuffing sourcecode with debug things...

Ok, it comes out of fontconfig:

image

$ fc-list -f '%{file}: %{family} | %{style} -- %{weight}:%{width}\n' | grep UbuntuN
/home/fini/.local/share/fonts/UbuntuNerdFont-Condensed.ttf: Ubuntu Nerd Font,Ubuntu Nerd Font Cond | Condensed,Regular -- 80:100
/home/fini/.local/share/fonts/UbuntuNerdFont-Light.ttf: Ubuntu Nerd Font,Ubuntu Nerd Font Light | Light,Regular -- 50:100
/home/fini/.local/share/fonts/UbuntuNF-Regular.ttf: Ubuntu Nerd Font | Regular -- 80:100
/home/fini/.local/share/fonts/UbuntuNerdFont-LightItalic.ttf: Ubuntu Nerd Font,Ubuntu Nerd Font Light | Light Italic,Italic -- 50:100
/home/fini/.local/share/fonts/UbuntuNerdFont-Medium.ttf: Ubuntu Nerd Font,Ubuntu Nerd Font Med | Medium,Regular -- 100:100
/home/fini/.local/share/fonts/UbuntuNerdFont-Bold.ttf: Ubuntu Nerd Font | Bold -- 200:100
/home/fini/.local/share/fonts/UbuntuNerdFont-Italic.ttf: Ubuntu Nerd Font | Italic -- 80:100
/home/fini/.local/share/fonts/UbuntuNerdFont-MediumItalic.ttf: Ubuntu Nerd Font,Ubuntu Nerd Font Med | Medium Italic,Italic -- 100:100
/home/fini/.local/share/fonts/UbuntuNerdFont-BoldItalic.ttf: Ubuntu Nerd Font | Bold Italic -- 200:100

It should be

#define FC_WIDTH_CONDENSED	    75

Ah, Ubuntu forgot (?!) to set the width of the font to 'condensed' 🙄

image

@Finii
Copy link
Collaborator

Finii commented May 11, 2023

After fixing it shows correctly on my self-built FontManager, but not-at-all anymore on the Flatpak.
Maybe some caching problem ;-)

image

That the number of fonts, although installed in the user directory, differs between 'all' and 'user', is still a mystery for me. Any ideas?

Also '9' now in 'User'.

image

Creating some PR...

Thanks for reporting!

@ffernand
Copy link
Author

👀 Oh wow... I did not expect to wake up to some in-depth reporting on this PR! 🎉

Incidentally, I can't explain why you were able to get 7 vs. 9 variations depending on whether you filtered by All or User. I was able to see 9 variations from both filters. I'm using the stock Ubuntu Nerd Font from the zipfile downloaded from the github website and the version of font-manager I used is v0.8.8 on my ArchLinux box.

Much appreciated @Finii for all the hard work!

Finii added a commit that referenced this issue May 11, 2023
[why]
The Ubuntu Condensed font is special because it is designed to be not
part of the `Ubuntu` font family but a self standing `Ubuntu Condensed`
family with just one member.

We want the `Ubuntu Condensed` to be part of `Ubuntu`, as it is usual
for fonts with different widths.

The problem then arises that the width class in the font metadata is set
to 'Normal', while it has to be 'Condensed'. That fact does not become
apparent when the font is in its own one member family, but even there
it is wrong.

[how]
To keep all the other information in the font untouched we just directly
patch that one byte where the width-class is stored - and repair the
checksums afterwards. Nothing more.

The code to do this is the Font Tweaker code in font-patcher, just
copied here for one time use.

Fixes: #1228

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
@Finii
Copy link
Collaborator

Finii commented May 11, 2023

Oh wow... I did not expect to wake up to some in-depth reporting on this PR! tada

I just write down all I do in case I'm interrupted by kids or day work or ... ;-)

Incidentally, I can't explain why you were able to get 7 vs. 9 variations depending on whether you filtered by All

I guess it has something to do with being a Flatpak. They mention something one would have to adjust with Flatseal, which I of course did not :-D
Always self-build from source 👍 😁

Much appreciated @Finii for all the hard work!

Thank you :-)

@Finii Finii removed this from the v3.0.1 milestone May 11, 2023
Finii added a commit that referenced this issue May 11, 2023
[why]
The Ubuntu Condensed font is special because it is designed to be not
part of the `Ubuntu` font family but a self standing `Ubuntu Condensed`
family with just one member.

We want the `Ubuntu Condensed` to be part of `Ubuntu`, as it is usual
for fonts with different widths.

The problem then arises that the width class in the font metadata is set
to 'Normal', while it has to be 'Condensed'. That fact does not become
apparent when the font is in its own one member family, but even there
it is wrong.

[how]
To keep all the other information in the font untouched we just directly
patch that one byte where the width-class is stored - and repair the
checksums afterwards. Nothing more.

The code to do this is the Font Tweaker code in font-patcher, just
copied here for one time use.

Fixes: #1228

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
@Finii
Copy link
Collaborator

Finii commented May 11, 2023

We do not add -Regular to the PS name. Is that correct?
We do not add Regular to the FullName, which is the recommended approach iirc.

This has not been answered! 😠 Got sidetracked.

@Finii Finii reopened this May 11, 2023
@Finii
Copy link
Collaborator

Finii commented May 12, 2023

Ah, looking at Iosevka, they do the same (not add Regular in both places.

image

Adding Regular to the FullName is optional - it is not recommended to not add, I believe now. See [1].

image

When it is left off, it is also left off of the PS name.

Here our list which fonts do what:

    @staticmethod
    def is_keep_regular(basename):
        """This has been decided by the font designers, we need to mimic that (for comparison purposes)"""
        KEEP_REGULAR = [
            'Agave',
            'Arimo',
            'Aurulent',
            'Cascadia',
            'Cousine',
            'Fantasque',
            'Fira',
            'Overpass',
            'Lilex',
            'Inconsolata$', # not InconsolataGo
            'IAWriter',
            'Meslo',
            'Monoid',
            'Mononoki',
            'Hack',
            'JetBrains Mono',
            'Noto Sans',
            'Noto Serif',
            'Victor',
        ]
        for kr in KEEP_REGULAR:
            if (basename.rstrip() + '$').startswith(kr): return True
        return False

[1] https://learn.microsoft.com/en-us/typography/opentype/spec/recom#name-strings

@Finii Finii closed this as completed May 12, 2023
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a new issue, complete the issue template with all the details necessary to reproduce, and mention this issue as reference.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants