How to change code block's font

As the title.

I’ve changed a theme’s font successfully by changing the .css file, but I can’t change the code block’s font, it seems relate to syntax highlight and I do not know how to change the highlight font, does anybody know how to solve this problem?

1 Like

This snippet was shared in the discord by @MartinKeigher


/*****************************/
/* Code-blocks: Font & style */
/*****************************/

.theme-dark {
  --background-primary-alt: #40444d;
}

/* Edit mode */
.cm-s-obsidian pre.HyperMD-codeblock {     
  font-family: Cascadia Code;
  font-size: 13px;
  font-weight: 350;
}

/* Preview mode */
.markdown-preview-view code {
  font-family: Cascadia Code;  
  font-size: 13px;
  font-weight: 375;
}
1 Like

Thanks @DEV_Scribbles for the awesome tip!

Sorry to be OCD edit, I just added codeblocks to your code.

I just added this line to make it look better. That works great on this forum and also on Discord.

At the start of the code

image


And at the end of the code

image

1 Like

Thanks for the edit! I didn’t think to add it (just straight up copy pasted) (ᗒ ᗨᗕ)

1 Like

:grinning_face_with_smiling_eyes: no worries! thanks for the code!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.