Page MenuHome

UI: Default Fonts Folder for Mac and Linux
ClosedPublic

Authored by Harley Acheson (harley) on Oct 8 2021, 11:06 PM.

Details

Summary

Initial defaults for userdef->fontdir for Mac and Linux.


The following report - https://developer.blender.org/T91919 - shows a Linux user clicking a "browse" button to select a font but is shown their root drive. This is quite confusing for new users who have not set a custom Fonts path (Preferences / File Paths).

Once we know that users at least start with some default path we can then start opening the "select font" browser there in thumbnail view.

Note this is only used for new installations and never overwrites a user-set value. A good way to test this is just to "Load Factory Preferences".

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Oct 8 2021, 11:06 PM
Harley Acheson (harley) created this revision.
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/blenkernel/intern/appdir.c
235

No need for the "else", since there's a return in the "if"

@Hans Goudey (HooglyBoogly) - No need for the "else", since there's a return in the "if"

Yikes, you're right of course. Fixed.

On Mac, the default system fonts are in /System/Library/Fonts/.

User-installed fonts in:

const char *home = BLI_getenv("HOME");
BLI_snprintf(dir, FILE_MAXDIR, "%s/Library/Fonts/", home);

At least on my Mac. But "/Library/Fonts/" also exists.

UPD: there is a preferences to install fonts for User or All Users.
So it's ~/Library/Fonts/ or /Library/Fonts/ respectively.

@Yevgeny Makarov (jenkm) wrote:- On Mac, the default system fonts are in /System/Library/Fonts/

So if you had to pick a single folder to be the default that would be it?

I realize that we can have multiple folders in the File Browser system list, but this is to make sure users don't start with an empty entry at Preferences / File Paths.

It can be any path you prefer but should probably be where the most are and is most likely to exist.

/System/Library/Fonts/ - will definitely have standard fonts.
~/Library/Fonts/ - is initially empty, but by default custom fonts will be added here.
/Library/Fonts/ - the least likely scenario.

Probably the second one. It may be empty, but... uh...
and the system looks like this:

@Yevgeny Makarov (jenkm) - Ah... so the system folder is meant just for fonts used by the system itself and user fonts go into ~/Library/Fonts/

I updated the patch for this path instead. And added you as a reviewer so you can be the official tester on Mac. ;-)

and the system looks like this:

Hmm... I'm a little curious about how https://developer.blender.org/D12032 looks with that folder. I think some like Arabic, Braille, Emoji will show better with that patch installed.

It should be this way:

const char *home = BLI_getenv("HOME");
BLI_snprintf(dir, FILE_MAXDIR, "%s/Library/Fonts/", home);

And for linux, too, probably, look in fsmenu.c / fsmenu_read_system.

Campbell Barton (campbellbarton) added inline comments.
source/blender/blenkernel/intern/appdir.c
275–280

Success should only be returned if the directory exists.

Campbell Barton (campbellbarton) requested changes to this revision.Oct 28 2021, 4:08 AM
Campbell Barton (campbellbarton) added inline comments.
source/blender/blenkernel/intern/appdir.c
276

Using ~ only works in the file selector (where it's expanded to HOME), this function shouldn't rely on the caller expanding the value and use HOME literal instead.

This revision now requires changes to proceed.Oct 28 2021, 4:08 AM

@Campbell Barton (campbellbarton)

  • returning success only if the directory exists
  • using HOME environment string

Note that I am not able to compile for either Mac or Linux.

source/blender/blenkernel/intern/appdir.c
281–282

This check should only run if dir is initialized. It may not be for WIN32.

Returning result better on Win32.

This revision is now accepted and ready to land.Oct 29 2021, 6:07 AM
source/blender/blenkernel/intern/appdir.c
263–264

This comment can be removed.

Removal of unnecessary comment.

Don't agree with making this environment dependent on Mac. Alternatives:

Case where HOME is empty/ unset is not checked either. Caller will attempt to write to system directory which needs root password.

@Ankit Meel (ankitm) - Don't agree with making this environment dependent on Mac. Alternatives…

It would be awesome to improve this on Mac. But this patch is committed and I don’t develop on Mac. So just submit a new patch that makes your proposed changes.

Case where HOME is empty/ unset is not checked either. Caller will attempt to write to system directory which needs root password.

This is an exceptional situation, checked over the code and other crashes existed here too.

Committed: