pourmand1376 / obsidian-custom-font

A plugin to set custom font for obsidian
https://obsidian.md/plugins?id=custom-font-loader
Apache License 2.0
49 stars 1 forks source link

Feature Proposal: Support multiple fonts #2

Closed BoreasHe closed 2 months ago

BoreasHe commented 9 months ago

Platform

Android

Current Situation

In the recent release, we can only load one font at a time, and it will override all font settings (e.g., Settings Panel, Editor, etc.).

Suggestion

Turn font into an array or Record

Loading a font into a base64-encoded url will also add a record or array entry to the data.json; which may cause a breaking change to the current interface.

Activating loaded fonts

We can use a Record<string, boolean> type to store loaded fonts so that we can dynamically create toggle options for users to enable as well as disable individual fonts.

Multiple active font-family

Modify the CSS applied to root: Read data.json and find the loaded fonts that have been enabled in the plugin settings.

Use Case

My vault is utilizing bilingual font settings (Chinese and English). In my Obsidian settings, I first load the English font and then the Chinese font so that the Latin characters are using the English font and the Chinese characters are using the Chinese font.


I can draft a pull request, but it would impose a breaking change to the plugin, as mentioned.

pourmand1376 commented 9 months ago

Thank you for your feature suggestion.

I agree with your idea and believe we can add it to plugin without causing issues for current users.

To make it even more usable, I'm thinking of allowing users to add multiple fonts. For each font, they can pick a CSS style to apply it. This way, users have more control over how they use fonts in their designs, giving them more freedom.

I am also thinking about a scenario in which people do not want the font to be applied globally and this dynamic CSS style should cover it.

It would be great if you could submit a PR and we can work on it to see where it goes.

What do you think?

bilal-khan commented 8 months ago

I am also thinking about a scenario in which people do not want the font to be applied globally and this dynamic CSS style should cover it.

Yes this ability to selectively apply fonts would be fantastic. For example the ability to set an editor/viewer font without modifying the UI font in sidebars etc would be wonderful.

pourmand1376 commented 8 months ago

Hi, @bilal-khan

This is now supported in the plugin. You can use whatever CSS style you want for your font.

However, for now, only one font is supported. See:

I will consider adding support for multiple fonts if there is enough request for that.

Ratzikowski commented 5 months ago

Hi there,

the support for multiple fonts would be really appreciated from my side. In my case I use different fonts for headings (Source Serif) and text (Clear Sans by Intel). Adding that feature would guarantee a consistent look on all platforms (that is for me Android, Mac and Windows).

Thanks for the consideration!

EDIT: nevermind, I just found the setting "multiple fonts". Sorry for the oversight!

pourmand1376 commented 5 months ago

That's fine. I hope the documentations are good enough to understand how this thing works.