Page MenuHome

Better Default Directory for Windows Fonts

Authored by Harley Acheson (harley) on Apr 23 2019, 5:46 PM.



The current default for U.fontsdir is // (same directory as the blender executable). With this patch applied that folder will use an OS-supplied path for default instead.

This only changes it for Windows users, and does not have negative affect for other OSs. But does give a nice spot to add such OS-specific code in future if desired (a TODO comment is added there).

Obviously this does not do anything if users already have userprefs saved. So this only really applies to new users or when you "Load Factory Settings".

Diff Detail

rB Blender

Event Timeline

Brecht Van Lommel (brecht) requested changes to this revision.Apr 25 2019, 7:53 PM

This seems generally fine.

969 ↗(On Diff #14885)

This should be in BLO_update_defaults_userpref_blend(), without checking any flags.

This revision now requires changes to proceed.Apr 25 2019, 7:53 PM

@Brecht Van Lommel (brecht) - this should be in BLO_update_defaults_userpref_blend(), without checking any flags

I did try it there, but it had no effect - still comes out as "//'

In fact I don't see that function, BLO_update_defaults_userpref_blend(), ever being called, whether I have prefs saved or not. I just stuck a breakpoint on it and it is just not hit.

BLO_update_defaults_userpref_blend() is called if "read_userdef_from_memory" is true as passed to wm_init_userdef()

wm_init_userdef() is called from wm_homefile_read(). Inside that function "read_userdef_from_memory" does not accurately reflect if the userdef was read from memory. The flag I used there is properly set when filepath_userdef is read correctly, so does reflect the state correctly. But read_userdef_from_memory is not accurate. That function is bit more complicated for me to figure out and fix though.

Actually not sure if I should submit that kind of thing (BLO_update_defaults_userpref_blend() no longer called) as a bug report TBH. It is called when you "load factory settings" but not in the case of not having a userpref.blend, so not called for new installations.

@Brecht Van Lommel (brecht) - someone has fixed that issue with BLO_update_defaults_userpref_blend() in that it is being called when there is no userpref file, not just when you load defaults.

So this patch does as you said, sets this default in BLO_update_defaults_userpref_blend()

Campbell Barton (campbellbarton) requested changes to this revision.May 16 2019, 3:41 AM
Campbell Barton (campbellbarton) added inline comments.

Rather each category doesn't add a new prefix (even though tmpdir is currently an exception), we have

  • BKE_appdir_program_path
  • BKE_appdir_app_template_*
  • BKE_appdir_folder_default

This could be:

  • BKE_appdir_fonts_folder_default

Use BLI_string_utf8.h.

This revision now requires changes to proceed.May 16 2019, 3:41 AM

This revision makes changes requested by @Campbell Barton (campbellbarton):

  • Better name for new function: BKE_appdir_fonts_folder_default()
  • Includes "BLI_string_utf8.h" rather than "BLI_blenlib.h"

Thanks for the review!

This revision was not accepted when it landed; it landed in state Needs Review.May 19 2019, 1:55 AM
This revision was automatically updated to reflect the committed changes.