mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-10 22:32:17 +02:00
Better cross platform font handling (#2104)
* fix: better handling of custom font Practically speaking, custom font seems to have only worked on Linux, because `net.fetch` would include the mime type in the response headers which could validate the payload. This doesn't appear to be the case on windows/macOS. Instead: 1. On Linux (or if some other system supports it), check the content type. If good, serve as normal 2. Otherwise, fetch the payload. Read the first four to five bytes and check for a valid magic number. Additionally, to prevent arbitrary requests fetching other paths via injected content, sync the custom font path to the main process, and then make _every_ request to `feishin:/` point to the same renderer path. When setting the font, first send the path to the main process. This will register `feishin:/` to point to the path provided. This is done via a promise-based set. Finally, provide a default value for the file input (a best effort approximation for the last part of the file path) on the file input component. * make the linter happy
This commit is contained in:
@@ -9,6 +9,13 @@ const set = (
|
||||
ipcRenderer.send('settings-set', { property, value });
|
||||
};
|
||||
|
||||
const setSync = async (
|
||||
property: string,
|
||||
value: boolean | null | Record<string, unknown> | string | string[],
|
||||
) => {
|
||||
return ipcRenderer.invoke('settings-set-sync', { property, value });
|
||||
};
|
||||
|
||||
const get = async (property: string) => {
|
||||
return ipcRenderer.invoke('settings-get', { property });
|
||||
};
|
||||
@@ -99,6 +106,7 @@ export const localSettings = {
|
||||
passwordSet,
|
||||
restart,
|
||||
set,
|
||||
setSync,
|
||||
setZoomFactor,
|
||||
themeSet,
|
||||
};
|
||||
|
||||
@@ -139,6 +139,7 @@ export const utils = {
|
||||
rendererToggleSidebar,
|
||||
rendererUpdateAvailable,
|
||||
saveCustomCss,
|
||||
separator: isWindows() ? '\\' : '/',
|
||||
setInputFocused,
|
||||
startPowerSaveBlocker,
|
||||
stopPowerSaveBlocker,
|
||||
|
||||
Reference in New Issue
Block a user