angstsmurf / spatterlight

Updated fork of Spatterlight
GNU General Public License v3.0
105 stars 5 forks source link

Custom theme with custom fonts sometimes not working #69

Closed Nephar closed 1 year ago

Nephar commented 1 year ago

I was recently fixing some of my custom font files with FontForge to make them work with Gargoyle (basically I declared Fontin's smallcaps variant as bold-italic instead so I can use it in subheadings in Gargoyle). So I was removing and replacing font files as a result. Somehow that made my Spatterlight custom theme(Lectrote Slate) locked for custom font changes. I can no longer change the fonts in that theme to ANY of the user installed fonts in my system(even those that are not touched for years in my system.)

I had to create a new custom theme and copy all settings from the locked one to the new one, then setting the custom fonts as well.

Current situation: I have 2 custom themes, Lectrote Slate(old one) and Lectrote Slate2(new one). I can set the fonts to whatever I want in the new one, but the old one reverts to Helvetica when I try to set any font to a user installed font(fonts that come with the system works fine).

angstsmurf commented 1 year ago

That is a very strange bug which I haven't seen before. Is it possible to reproduce?

By the way, you shouldn't have to copy any settings manually when creating a new theme. When you create a new theme, all the settings from the current one are supposed be copied automatically. Doesn't that work either?

Nephar commented 1 year ago

No copying does not work either, new copy become locked to custom fonts as well. Sorry I have forgotten to mention that. As for reproducing it, I will try removing and adding fonts again. But I think this might not be enough, font properties might need to change for the bug to appear, like when I did when I changed the smallcaps font in FontForge.

Btw, is there a config or cache file for Spatterlight that I can post here? The locked one should be stored in some place, right?

angstsmurf commented 1 year ago

Themes are stored in the Core Data files which should be in ~/Library/Group Containers/6U7YY3724Y.group.net.ccxvii.spatterlight/. There are three files: Spatterlight.storedata-shm, Spatterlight.storedata-wal, and Spatterlight.storedata. I have never tried reading a database created by a another user, though, so I don't know if they are protected somehow.

Nephar commented 1 year ago

I managed to reproduce it.

  1. Create custom theme, set proportional font to a user installed font, making sure that it works.
  2. Close Spatterlight.
  3. Remove that font from system using Font Book app.
  4. Open Spatterlight and try changing that theme's prop font to some other user installed font. It won't take effect, font will revert to Helvetica.
  5. Even if you reinstall the same font again, the theme stays locked to user fonts.

All this with Mojave of course, the bug might not appear in a newer OS.

angstsmurf commented 1 year ago

Thanks!

I can't seem to reproduce it here on Ventura. The font just changes to "System Font Regular", and can be changed without problems. I'll have to check later in my Mojave VM.

Nephar commented 1 year ago

Here is what is happening when I am using the font picker for prop font:

The working theme

Screen Shot 2023-02-24 at 02 28 34

Non-working theme

Screen Shot 2023-02-24 at 02 29 52

Also, I have tried to check Spatterlight.storedata with an online sql lite database viewer, couldn't gain any insight about the non-working theme with respect to the working one. I couldn't check the other 2 files you have mentioned, they don't seem to be sql lite files.

angstsmurf commented 1 year ago

I tried to reproduce the bug in Mojave now, but still can't trigger it. Deleting a font only makes it switch to "System Font" of the same size, which then can be changed into any other font. It may be something specific to your custom Fontin.

shm and wal are apparently shared memory and write-ahead log files, by the way.

EDIT: I have a hunch that this may be another sandboxing problem, and that Spatterlight for some reason can't access your ~/Library/Fonts folder. I don't suppose you are using some kind of font manager that puts them in a different folder?

Nephar commented 1 year ago

The only font manager I am using is Apple's Font Book app that came with Mojave. And I am installing fonts into ~/Library/Fonts directory, not to the system wide /Library/Fonts one.

I have downloaded two fonts that I have never used on this machine before from Google fonts, Crimson Text and Gelasio, then installed them both with Font Book, closed Font Book. Then I have opened Spatterlight, copied Lectrote Dark theme and just set the prop font to Crimson Text Regular 20, closed Spatterlight, opened Font Book app again and removed Crimson Text from the system, closed Font Book. After that I have opened Spatterlight, the font have changed to some system font, tried setting the prop font to Gelasio this time and it reverted to Helvetica again. I guess it is not about the Fontin font.

I have thought about that Spatterlight not being able to access my ~/Library/Fonts, but the weird thing is it is just those specific themes that have the problem. If I make a new theme or use one of the other ones, I can change their fonts just fine.

But if you have not been able to reproduce it, I don't know what to think, other than that something is wrong with my system. Thanks for trying to pin it down. Since it can be worked around by creating a new theme, it is not like a show-stopping problem anyway.

angstsmurf commented 1 year ago

Never mind, I managed to reproduce it. I'll see if I can work out what is going on.

angstsmurf commented 1 year ago

I think I fixed it. Try this: Spatterlight.zip

Nephar commented 1 year ago

My MacBook is in repair right now. I will try it when I get it back. Thanks for the fix.

Nephar commented 1 year ago

The fix is working perfectly, thank you.

Edit: Feel free to close this. Or I can do it later.

angstsmurf commented 1 year ago

Happy to hear that. Thanks for reporting this.