[Desktop]: Open writable font dir in FM, toggle between system+user and user fonts, fix openLink on mac...#5220
Conversation
|
Pinging @Frenzie @poire-z @robert00s @NiLuJe for suggestions. Thanks! |
|
(Not really using linux for UI stuff needing fonts, I only use the emulator.) |
Which it? The XDG folder? |
|
it = the user's ~/.local/share/fonts (I have no idea what The XDG folder is, and what xdg-open does - assuming its a generic opener that chose the right app, it will open the ~/.local/share/fonts in an external file browser, and then what the user could do there?) |
Copy fonts there or backup already copied fonts. This is the only place where the user has RW granted (because the fonts partition will be in /usr/lib/koreader on debian and inside the app bundle on the appimage). If an user wants to add a font but not all the fonts already present on the system then leave the use system fonts unchecked, click to open font dir and copy fonts on the opened folder. Not sure if it makes much sense. |
|
Also, if it is a kind of standard user dir for fonts that other apps may use too, couldn't backing it up make these other apps not function correctly anymore (apps launched before, apps launched while koreader is running)? |
|
Okay, I wouldn't touch the XDG folder ( A lot of stuff depends on it being the way it currently is (hi, fontconfig! :D), we should only ever treat it as RO on our end. Point the user to it, sure, why not, but do anything to it behind his back, nope. |
Yeah, my logic was flawed. Yours is way better and waaaay simpler. I will submit changes in a minute 😄 |
Frenzie
left a comment
There was a problem hiding this comment.
I don't know what it said before but indeed it should pretty much be RO.
|
Thinking about it, if we make a symlink to the system font dir in it, couldn't these other apps see multiple copies of the system fonts if they are made to look in both the user and the system dirs (like I guess they should logically do), with possible side effects? |
|
I'm not sure why you guys are all being so difficult. ;-) koreader/frontend/fontlist.lua Lines 97 to 100 in f56e9bc |
|
Thanks for the hints! I updated the PR and added support for openLink on macs too. |
|
I was going to suggest splitting on |
|
|
||
|
|
||
| if Device:isDesktop() then | ||
| common_info.font_settings = require ("ui/elements/font_settings"):getMenuTable() |
There was a problem hiding this comment.
Putting this in the common info menu and then disabling it in the file manager with the MenuSorter is pretty weird. ;-)
There was a problem hiding this comment.
I created it because there was a lot of duplication that was annoying to deal with.
Reader-specific stuff should simply go around/after here:
koreader/frontend/apps/reader/modules/readermenu.lua
Lines 144 to 152 in 33e4c36
There was a problem hiding this comment.
Wow, I just requested your review, you're fast.
Sorry, I'm not familiar with the menu sorter. Where should I put the menu?, somewhere inside the reading app?.
There was a problem hiding this comment.
Just a coincidence, I saw your latest commit before you did that.
| canRestart = yes, | ||
| canReboot = no, | ||
| canPowerOff = no, | ||
| isDesktop = no, |
There was a problem hiding this comment.
Not sure how much it matters, but by the xdg-open = desktop logic I believe this means Sailfish isDesktop() == true. Sailfish should probably be able to run on a regular x86 desktop, but, um, well… ;-)
There was a problem hiding this comment.
nah, Sailfish canOpenLink but is not isDesktop. In fact Sailfish isAndroid.
Desktop devices are sdl that run without a sandbox. Which means everything except Ubuntu Touch.
There was a problem hiding this comment.
Desktop devices are sdl that run without a sandbox. Which means everything except Ubuntu Touch.
Pretty sure Sailfish is more desktop than Ubuntu Touch then. ;-)
| return version ~= nil | ||
| end | ||
|
|
||
| -- open is the macOS counterpart |
There was a problem hiding this comment.
And start on Windows. Not relevant to the code, but I was curious and looked it up.
frontend/device/sdl/device.lua
Outdated
| local enabled, tool = getLinkOpener() | ||
| if not link or type(link) ~= "string" then return end | ||
| return os.execute("xdg-open '"..link.."'") == 0 | ||
| if not enabled or tool == nil then return end |
There was a problem hiding this comment.
Unless the distinction between false and nil is meaningful (which it could hardly said to be here; a boolean concatenates just as badly as nil) I'd personally just write or not tool.
There was a problem hiding this comment.
ok, will do
if not enabled or not tool or not link or type(link) ~= "string" then return end| text = _("Enable system fonts"), | ||
| checked_func = usesSystemFonts, | ||
| callback = function() | ||
| G_reader_settings:saveSetting("desktop_uses_system_fonts", not usesSystemFonts()) |
There was a problem hiding this comment.
Or just system_fonts? The setting name seems a bit verbose. Also it might make sense to have this toggle on Android as well.
| end, | ||
| }, | ||
| { | ||
| text = _("Open fonts dir"), |
There was a problem hiding this comment.
| text = _("Open fonts dir"), | |
| text = _("Open fonts folder"), |
Or directory, but I think we (and most filemanagers) use folder.
platform/appimage/AppRun
Outdated
| export EXT_FONT_DIR="${HOME}/.fonts" | ||
| # create user font directory if it does not exist. | ||
| USER_FONT_DIR="${HOME}/.local/share/fonts" | ||
| [ ! -d "${USER_FONT_DIR}" ] && mkdir -pv "${USER_FONT_DIR}" |
There was a problem hiding this comment.
Would this make more sense in Lua, in the fairly rare circumstance the user actually taps on the menu item?
There was a problem hiding this comment.
Right now the menu item is disabled if the folder don't exist (which could happen only on the emulator). Your idea seems better: item always enabled and mkdir on demand.
| "style_tweaks", | ||
| "font_settings", | ||
| "----------------------------", | ||
| "change_font", |
There was a problem hiding this comment.
Better be moved below the separator (that separates style stuff from font stuff)
There was a problem hiding this comment.
And moved again below change_font ? :)
(Because I'm so used to find it on the 3rd position, and easthetically, having the following longer items together should look better, instead of having the little "Font >" in between.
(Would it need an added separator=true for that Font settings>, that would appear only on isDesktop?)
There was a problem hiding this comment.
I'd be inclined to move it down one further in line with the general menu order, which would add an extra separator, Though in this case it's defensible that change font, hyphenation & hanging punctuation belong closer together.
There was a problem hiding this comment.
It's fine I guess, but like I said initially, I think it'd be best within the font menu itself.
There was a problem hiding this comment.
I'm fine with that screenshot.
There was a problem hiding this comment.
It's fine I guess, but like I said initially, I think it'd be best within the font menu itself.
Ok, that makes sense. I didn't understand.
4600812 to
170875d
Compare
| "style_tweaks", | ||
| "font_settings", | ||
| "----------------------------", | ||
| "change_font", |
There was a problem hiding this comment.
I'd be inclined to move it down one further in line with the general menu order, which would add an extra separator, Though in this case it's defensible that change font, hyphenation & hanging punctuation belong closer together.
…openLink on mac (koreader#5220) Fixes koreader#5093


I enabled it on the emulator just to test (I needed to export EXT_FONT_DIR =~/.local/share/fonts)The emulator should be removed since we cannot grant it is linux.The user has a menu to switch from its own set of fonts (~/.local/share/fonts) and system fonts (/usr/share/fonts). If the user chooses her/his own fonts she/he can open it on the file manager (via xdg-open).It seems a bit hacky but works really well.The user can toggle system fonts. The toggle just creates or deletes a symbolic link to /usr/share/fonts in a folder inside our EXT_FONT_DIR.Thanks to @poire-z and @Frenzie for the hints!
to-do:
place the new submenu somewhere.remove the emulator from isDesktopLinux.enable "open dir in fm" just if "xdg-open" exists.infomessage saying "changes will apply after a restart (not true, changes will apply on the next cr3 document loaded, but that is harder to explain 🤦♂️)more sanity checks ¿?Fixes #5093