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

Set font per page #7

Closed diatche closed 5 months ago

diatche commented 7 months ago

Thanks for writing this. This helps me to display Church Slavonic text correctly. The problem is that I only need the font loaded in those files which use Church Slavonic. So it would be great if there was a way to specify the font per file.

Using the font property seems like a great way to set the font per page, instead of setting the font globally.

pourmand1376 commented 7 months ago

This is easy.

First, Use Custom CSS style and define it like this:

.custom-font * {
font-family: YourFontName !important;
}

Then, you can set this custom-font CSS style in any file you want. For this, you need to set cssclasses in the frontmatter to custom-font. Something like this:

image

And this is the settings page: image

winged-voices commented 6 months ago

Just to check (because I know CSS, but not WELL) -- is it possible to create several different defined classes here for each different font, on the off chance I end up wanting to use a couple different fonts but only for certain things? (I can think of some use cases since I do writing/roleplaying/mood boards etc and could use handwriting fonts for example.)

If in the Custom CSS style, I also defined .custom-font2 and .customfont3, etc etc (or .whatevername) with an additional font-family, and labeled them in the css-class front matter, would it let me use multiple fonts on a page by page basis?

pourmand1376 commented 5 months ago

Yes, This should be okay in theory. But, currently my plugin only loads one external font. For this to work, I should work on #2.

winged-voices commented 5 months ago

That would be awesome and much appreciated!

pourmand1376 commented 5 months ago

This is now added. You can easily do what you want by using custom css classes.

winged-voices commented 5 months ago

Thank you so much!!

On Sat, Jan 20, 2024 at 8:14 AM Amir Pourmand @.***> wrote:

This is now added. You can easily do what you want by using custom css classes.

— Reply to this email directly, view it on GitHub https://github.com/pourmand1376/obsidian-custom-font/issues/7#issuecomment-1902110988, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYILT6LSX75QJIF2QPA5JSDYPPGODAVCNFSM6AAAAABAL7CJLWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBSGEYTAOJYHA . You are receiving this because you commented.Message ID: @.***>

diatche commented 5 months ago

It works great! Thank you

Rick1029 commented 3 months ago

Hi, using the multiple font options to try to set a bigger font size and different font for Arabic only notes, it all works an doesn't alter the font of my notes unless I have "custom-font" written.

image

However doing this makes Obsidian freak out as the plugin says it is "processing fonts" and it gets so slow you'd think it froze, but things just take 5-10 seconds to happen. It goes back to normal when you quit and restart and it works fine. It freezes again if you open the plugin settings menu and you have to slowly change fonts, quit, then restart. I notice in the background when you open the plugin settings your font scrolls through every single one you have installed (I have five for Arabic) then settles on the one you selected, and unfreezes, unless you try picking a new one where it freezes until you reopen Obsidian.