Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

different font for different language #349

Closed
GXY2017 opened this issue Jan 12, 2023 · 2 comments
Closed

different font for different language #349

GXY2017 opened this issue Jan 12, 2023 · 2 comments
Labels
question 🙅 Not issue, just a question (should post to Marp discussion)

Comments

@GXY2017
Copy link

GXY2017 commented Jan 12, 2023

I am trying to set font for Chinese and English, but the following code does not work.

<style>
    :lang(zh) {
        font-family: "KaiTi";
    }
    :lang(en) {
        font-family: "Arial";
    }
    h1 {
        text-align: left;
        font-size: 40px;
    }
</style>

Please advice me. Thank you.

@yhatt yhatt added the question 🙅 Not issue, just a question (should post to Marp discussion) label Jan 12, 2023
@yhatt
Copy link
Member

yhatt commented Jan 12, 2023

If you want to use :lang pseudo-class selector, you have to mark parts of contents explicitly, by any HTML tags with lang attribute.
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang

<span lang="zh-cmn-Hans">欢迎</span>

But typically that is not realistic. Nobody wants to mark all different languages manually.

In common web sites, a global font-family has been set to use multiple fonts, and CJK fonts tends to set as a fallback of fonts that have only latin glyphs. You can follow this approach also in Marpit theme CSS.

section {
  /* Use Arial first, and fallback to KaiTi if there were no glyphs. */
  font-family: Arial, KaiTi;
}

@GXY2017
Copy link
Author

GXY2017 commented Jan 12, 2023

Thank you very much.
With <style scoped>, this has solved my problem.

@GXY2017 GXY2017 closed this as completed Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question 🙅 Not issue, just a question (should post to Marp discussion)
Projects
None yet
Development

No branches or pull requests

2 participants