marp-team / marp-cli

A CLI interface for Marp and Marpit based converters
MIT License
1.91k stars 107 forks source link

Cannot change serif font in pdf output and vscode preview #161

Closed Dothion closed 5 years ago

Dothion commented 5 years ago

Serif Chinese font isn't a good choice in slides, so I tried this, but font didn't change.

---
marp: true
theme: gaia
---
<style>
.slide {
  font-family: 'Microsoft YaHei', 'SimHei', sans-serif !important;
}
</style>

<!-- class: lead gaia -->
# 标题
## Title

I didn't try it with html output because html version without <style> worked well with a sans serif font. So is there any way to change font without editing theme files?

btw Microsoft YaHei might not be a good default font because it is not a free font. Sarasa Gothic may be a good alternative. screenshot

yhatt commented 5 years ago

.slide selector is only for outdated Marp app. Instead, Marp Next must use section selector.

<style>
section {
  font-family: 'Microsoft YaHei', 'SimHei', sans-serif;
}
</style>

See also the document of theme CSS in Marpit framework.

Incidentally, Gaia has already defined sans-serif font in theme CSS so I think rendering with serif font is unexpected behavior. I was going to consider CJK rendering well because I'm Japanese, but the result in Chinese fonts is interesting for me.

Dothion commented 5 years ago

It's working well. Thanks a lot.