[Possible bug] Not all installed fonts recognized on macOS

Hi all,

I was playing around with fonts in the CSS. I have noticed that for some reason darktable will just refuse to use some fonts that, to my unexperienced eye, look just like the other ones.

The OS comes preinstalled with a bunch of fonts, including

  • DIN Condensed

Additionally, I downloaded the following fonts from fonts.google.com:

  • Ubuntu
  • Ubuntu Condensed
  • Cabin Condensed
  • Barlow Condensed
  • Saira ExtraCondensed

After installing the new fonts I ran

$ /opt/homebrew/bin/fc-cache -frv

to refresh the font cache, and restarted the application to make sure that it would see the new fonts.

I am using the following stanza in user.css to change the font used for panel headings:

#iop-panel-label,
#lib-panel-label
{
  font-family: "Ubuntu Condensed";
}

Of the fonts listed above, the only ones that work are Ubuntu and Ubuntu Condensed. If I use any of the other font, it just falls back on whatever is the default for those elements.

I thought that maybe I was misspelling the name of the fonts, but I am using the same name returned by fontconfig, e.g, Saira ExtraCondensed in the following case:

$ /opt/homebrew/bin/fc-match "Saira ExtraCondensed"
SairaExtraCondensed-Regular.ttf: "Saira ExtraCondensed" "Regular"

I also ran darktable with GTK_DEBUG=interactive, and verified in the Visual tab that the fonts are listed, so they should definitely be available to the application.

I then thought that maybe the issue was with some of the fonts not having a ā€œregularā€ variant, as maybe darktable would filter them for some reason. But this cannot be the case, as of all the fonts listed above only ā€œDIN Condensedā€ does not have a regular variant.

And by the way, I tried all the following and they do not work either:

#iop-panel-label,
#lib-panel-label
{
  font-family: "DIN Condensed";
  font-weight: bold
}
#iop-panel-label,
#lib-panel-label
{
  font-family: "DIN Condensed Bold";
  font-weight: bold;
}

I would exclude that the weight is an issue, as if I specify

#iop-panel-label,
#lib-panel-label
{
  font-family: "Ubuntu Condensed";
  font-weight: bold;
}

the correct font is used (albeit not in bold, as that font does not have a bold variant).

Am I overlooking something, is it a known limitation or is it an actual bug?

Thanks,

I’d ask, what kind of fonts did you download from google?

Reading is hard… Masterpiga literally wrote…

being polite also…

2 Likes

The ones listed in the OP. They are all standard TTF, and they are all correctly recognized by fontconfig.

Note that also Ubuntu and Ubuntu Condensed, which work, have been downloaded and installed in the same way.

Thanks, that’s what I wanted to know, since it was not specified in the original post.

Since we are all obviously so smart and reading is so hard for me, I’ll assume you lot will have it solved in no time. Best of luck.

Yo, man, I haven’t done anything to you and I believe in combining smartnesses :slight_smile:

Not cool, dude, no snarkiness under my post, please.

@Masterpiga Did you try your CSS code on some generic HTML with these font names to see if they are recognized correctly by a web browser?

I can get ā€œDIN Condensedā€ to works without any weight/stretch if instead of using coretext (the default for gtk) I use fontconfig

$ export FC_DEBUG=1 # to see the matches
$ export PANGOCAIRO_BACKEND=fc
$ /Applications/darktable.app/Contents/MacOS/darktable

There is a small difference on how pango list this particular font on each engine:

$ PANGOCAIRO_BACKEND=fc pango-list|grep 'DIN Condensed'
DIN Condensed
  *Bold Italic: DIN Condensed, Bold Italic
  Bold:         DIN Condensed, Bold Condensed

$ PANGOCAIRO_BACKEND=coretext pango-list|grep 'DIN Condensed'
DIN Condensed
  Bold:             DIN Condensed, Bold Condensed
  *Bold Small-Caps: DIN Condensed, Bold Condensed Small-Caps
  *Bold Oblique:    DIN Condensed, Bold Italic Condensed

I can get ā€˜DIN Condensed’ to works with coretext using the following, but I can’t explain the difference between how coretext and fc do the font matching:

#iop-panel-label,
#lib-panel-label
{
  font-family: "DIN Condensed";
  font-stretch: condensed;
}
1 Like

Thanks, @Kazuo, this is very interesting.

Also thanks for pointing out that Pango uses coretext by default on mac, which I had overlooked.

I will try explicitly setting the stretch also for the other fonts and then teport back, I am AFK at the moment

Armed with @Kazuo’s insightful observations, it seems to be the case that fonts that list Condensed among their attributes can only be selected if font-stretch: condensed is explicitly specified.

With the exception of Ubuntu Condensed, all the fonts that I tried have the Condensed attribute explicitly set in pango-list, e.g.:

$ pango-list | grep Barlow
Barlow Condensed 
  Black Italic:                  Barlow Condensed, Heavy Italic Condensed
  Black:                         Barlow Condensed, Heavy Condensed
  ExtraBold Italic:              Barlow Condensed, Ultra-Bold Italic Condensed
  ExtraBold:                     Barlow Condensed, Ultra-Bold Condensed
  Bold Italic:                   Barlow Condensed, Bold Italic Condensed
$ pango-list | grep "DIN Condensed"
DIN Condensed 
  Bold:             DIN Condensed, Bold Condensed
  *Bold Small-Caps: DIN Condensed, Bold Condensed Small-Caps
  *Bold Oblique:    DIN Condensed, Bold Italic Condensed

Ubuntu Condensed works without explicitly setting the font-stretch, because the attribute Condensed is not reported:

$ pango-list | grep "Ubuntu Condensed"
Ubuntu Condensed 
  Regular:     Ubuntu Condensed,
  *Small-Caps: Ubuntu Condensed, Small-Caps
  *Oblique:    Ubuntu Condensed, Italic

That said, I still find that this should not happen. If I understand it well, the font-stretch directive is only an indication to the renderer. It should not prevent a font from being selected if the specified stretch/width is not available:

Can this be an upstream bug in the way that GTK implements the CSS spec?

I also noticed something that seems to be a darktable/GTK/pango integration issue.

If you select certain combinations, such as this:

#iop-panel-label,
#lib-panel-label
{ font-family: "Ubuntu Condensed"; font-stretch: condensed; }

darktable will output this warning:

(org.darktable.darktable:18333): Pango-WARNING **: 11:09:33.697: couldn't load font "Ubuntu Condensed, Condensed Not-Rotated 13.2", modified variant/weight/stretch as fallback, expect ugly output.

From now on, darktable will just ignore whatever changes you make to the fonts for the selected elements until it’s restarted.