3.2.alpha
Ubuntu 18.04
When a .ttf-file is already loaded, loading it again from another location results in not being able to change the size. Changing the size in one of those locations makes the font become invisible. Only when the original size is put into the 'size'-field inside the font-settings, will the font become visible again. Loading the font again, and making it unique solves this problem.
This may be related to some DynamicFont font caching issues which I've noticed but haven't gotten to writing up yet. Here's a quick brain dump...
DynamicFont font cache issuesFrom memory, the issues are:
It's possible for a (cached?) font size to be set before the data is loaded which means the following code won't "reload" the cache because it thinks the font size is already cached:
I seem to recall that this "manual"/direct size-setting during initialization (via https://github.com/godotengine/godot/commit/c399c41dfb065efab8d3b168ef0a1c5a5cf609d5) is what causes the issue:
https://github.com/godotengine/godot/blob/1fed266bf5452b30376db62495f4985f6975f2c1/scene/resources/dynamic_font.cpp#L1022-L1026
There was an alternate patch which used the set_size() method AFAICT correctly (and also handled https://github.com/godotengine/godot/commit/f41dddf069ab3747e38f2236db17a46ea55200b0 correctly): #21165
From memory, the initialization issue fell out of the following change to calculation/handling of CacheID (which may be should have been setting size to -1 or 0 anyway?): https://github.com/godotengine/godot/commit/8daf5491ab6bc60434e4d952830bdd258eaf0e53#diff-17a3b965179a9e0883c412a8af15cff3L59
(Which--again from memory--worked because the previous comparison operator implementation didn't meet the transitivity requirement of a comparison sort i.e. it was (incorrectly) possible for items a & b to return true for both these tests: a < b & b < a.)
Inconsistent use of calls to: emit_changed(), _change_notify() & _reload_cache().
At a minimum it may be sufficient to replace these lines:
with a call to set_size(16)--I seem to recall that because the DynamicFont isn't valid when first created without data the incorrect cache handling issue won't occur after this change. (Or maybe it needs to be set_size(0).)
Hopefully this is a useful starting point for someone investigating this issue. Unfortunately my list of issues to write up "comprehensively" or "verbosely" :D (as I'm wont to do)--and ideally create a PR for--isn't getting shorter so I'm doing a brain-dump here in the hopes that imperfect & done is better than someone else having to repeat my troubleshooting efforts on the font caching side of things. :)
Edit: Possibly useful to keep in mind: https://github.com/godotengine/godot/commit/863dd9aa46aff502f7425ea6045de93bf09b76a3#diff-fce1ec7b33979481c1af96f2d6be6686
i can't reproduce this issue on windows 10
edit: 3.2.alpha1
Can't reproduce either, please comment if you can still reproduce in Godot 3.2.3 or newer. Also include a reproduction project.
Most helpful comment
This may be related to some
DynamicFontfont caching issues which I've noticed but haven't gotten to writing up yet. Here's a quick brain dump...Existing
DynamicFontfont cache issuesFrom memory, the issues are:
It's possible for a (cached?) font size to be set before the data is loaded which means the following code won't "reload" the cache because it thinks the font size is already cached:
https://github.com/godotengine/godot/blob/1fed266bf5452b30376db62495f4985f6975f2c1/scene/resources/dynamic_font.cpp#L698-L705
I seem to recall that this "manual"/direct size-setting during initialization (via https://github.com/godotengine/godot/commit/c399c41dfb065efab8d3b168ef0a1c5a5cf609d5) is what causes the issue:
https://github.com/godotengine/godot/blob/1fed266bf5452b30376db62495f4985f6975f2c1/scene/resources/dynamic_font.cpp#L1022-L1026
There was an alternate patch which used the
set_size()method AFAICT correctly (and also handled https://github.com/godotengine/godot/commit/f41dddf069ab3747e38f2236db17a46ea55200b0 correctly): #21165From memory, the initialization issue fell out of the following change to calculation/handling of CacheID (which may be should have been setting size to
-1or0anyway?): https://github.com/godotengine/godot/commit/8daf5491ab6bc60434e4d952830bdd258eaf0e53#diff-17a3b965179a9e0883c412a8af15cff3L59(Which--again from memory--worked because the previous comparison operator implementation didn't meet the transitivity requirement of a comparison sort i.e. it was (incorrectly) possible for items
a&bto return true for both these tests:a < b&b < a.)Inconsistent use of calls to:
emit_changed(),_change_notify()&_reload_cache().Possible solution
At a minimum it may be sufficient to replace these lines:
https://github.com/godotengine/godot/blob/1fed266bf5452b30376db62495f4985f6975f2c1/scene/resources/dynamic_font.cpp#L1025-L1026
with a call to
set_size(16)--I seem to recall that because theDynamicFontisn'tvalidwhen first created without data the incorrect cache handling issue won't occur after this change. (Or maybe it needs to beset_size(0).)Additional context
Hopefully this is a useful starting point for someone investigating this issue. Unfortunately my list of issues to write up "comprehensively" or "verbosely" :D (as I'm wont to do)--and ideally create a PR for--isn't getting shorter so I'm doing a brain-dump here in the hopes that imperfect & done is better than someone else having to repeat my troubleshooting efforts on the font caching side of things. :)
Edit: Possibly useful to keep in mind: https://github.com/godotengine/godot/commit/863dd9aa46aff502f7425ea6045de93bf09b76a3#diff-fce1ec7b33979481c1af96f2d6be6686