Kavita icon indicating copy to clipboard operation
Kavita copied to clipboard

Feature: Bring your own font

Open Fesaa opened this issue 1 week ago • 0 comments

Added

  • Added: user may provide their own fonts to be used in the epub reader

THIS IS A DRAFT

I'm not done with this yet, quite a bit to do. But feel like it is time to ask for feedback on a few things. Opening a draft pull request, just so it's here as well. Will cross post in the discord after.

Loading the fonts.

They're currently being loaded in the book-reader, this should ensure they're only being loaded when needed. I've also not noticed any higher loading times, but I've only had max 4 fonts loaded. We may want to try with a bunch more, at the very least the default ones, to see if it has any noticeable impact.

Design choices

Need some feedback / greenlight for design choices as to call what what, and place what where.

  • Fonts are called EpubFonts
  • Fonts are stored in ${pwd}/config/fonts

If these are fine, how do we want to differentiate between the default fonts, and user fonts? Can we store them in the same folder, should we not?

If these are not fine, suggestions as to changes to do.

Link with AppUserPreferences

Currently, the font preference for a user is saved, as the fonts name. It's still doing this currently, and should work fine. However, we could change this to the ID of the font. Having it be the fonts name, does make it easier to load and reset them. As simple as changing it to default.

Default font The dropdown menu in the UI, currently, isn't displaying the default font, as it's not an EpubFont. Where should I best inject this option? In the UI, or the controller; instinctively I would do it in the controller, such that the UI doesn't have too much extra logic it has no business of owning. But wanted to ask for opinions anyway, maybe there is a better place?

Notes

  • The controller currently has the wrong authorize annotations, still has to be changed.
  • The seed class doesn't have all default fonts in it yet. I only copied over one
  • I'll probably squash commits before merging and give them a better name

TODO's

Apart from "smaller" TODO's in the code. I think these are the big ones still to do

  • Add update task in Admin UI
  • Auto scan fonts
  • Scan update communication with UI

I may have missed some

Fesaa avatar Jun 26 '24 16:06 Fesaa