Skip to content

Discord Font Settings for CJK user by typas

Details

Authortypas

LicenseMIT

Categorydiscord.com

Created

Updated

Size4.6 kB

Statistics

Learn how we calculate statistics in the FAQ.

Failed to fetch stats.

Description

This is a general font setting for Discord pages (including developer) with default to sans-serif fonts.
This one is only for CJK users, since I have no idea how to add conditional statement in CSS.

inspired by GitHub Custom Fonts

Notes

If there's any bug you found, or some advices you want to give out, raise an issue on the Github repository.

ver 2.1.0 - variable is not usable as a parameter of :lang(), back to old method.
ver 2.2.2 - add code font fallbacks

Source code

/* ==UserStyle==
@name        Discord Fonts CJK
@namespace   https://github.com/Typas/usercss-stylus
@homepageURL https://github.com/Typas/usercss-stylus
@version     2.2.2
@license     MIT
@description Discord font settings, CJK users only
@author      Typas
@supportURL  https://github.com/Typas/usercss-stylus/issues
@preprocessor default
@var text primary-font-family "Primary font" "gg sans"
@var text display-font-family "Display font" "gg sans"
@var text headline-font-family "Headline font" "ABC Ginto Nord"
@var text default-font-fallbacks "Font fallbacks" ""Noto Sans", "Helvetica Neue", Helvetica, Arial"
@var text cjk-primary-font-family "CJK primary font" "Noto Sans CJK TC"
@var text cjk-display-font-family "CJK display font" "Noto Sans CJK TC"
@var text cjk-headline-font-family "CJK headline font" "Noto Sans CJK TC"
@var text cjk-font-fallbacks "CJK font fallbacks" "Meiryo, "Malgun Gothic", "Microsoft JhengHei", "Microsoft YaHei""
@var text code-font-family "Code font" "Fira Code"
@var text cjk-code-font-family "CJK code font" "Noto Sans Mono CJK TC"
@var text code-font-fallbacks "Code font fallbacks" ""JetBrainsMono", "Cascadia Code", "Victor Mono", Consolas"
@var text cjk-code-font-fallbacks "CJK code font fallbacks" "Meiryo, "Malgun Gothic", "Microsoft JhenHei", "Microsoft YaHei""
@var text code-font-feature-settings "Code font feature settings" ""ss01", "ss03", "ss05""
==/UserStyle== */

@-moz-document domain("discord.com") {
    :root {
        --font-primary: var(--primary-font-family), var(--default-font-fallbacks),
                        sans-serif !important;
        --font-display: var(--display-font-family), var(--default-font-fallbacks),
                        sans-serif !important;
        --font-headline: var(--headline-font-family), var(--default-font-fallbacks),
                         sans-serif !important;
        --font-code: var(--code-font-family), var(--code-font-fallbacks),
                     var(--cjk-code-font-family), var(--cjk-code-font-fallbacks),
                     monospace !important;
        font-feature-settings: var(--code-font-feature-settings) !important;
    }

    :lang(zh) {
        --font-primary: var(--primary-font-family), var(--default-font-fallbacks),
                        var(--cjk-primary-font-family), var(--cjk-font-fallbacks),
                        sans-serif !important;
        --font-display: var(--display-font-family), var(--default-font-fallbacks),
                        var(--cjk-display-font-family), var(--cjk-font-fallbacks),
                        sans-serif !important;
        --font-headline: var(--headline-font-family), var(--default-font-fallbacks),
                         var(--cjk-headline-font-family), var(--cjk-font-fallbacks),
                         sans-serif !important;
    }

    :lang(jp) {
        --font-primary: var(--primary-font-family), var(--default-font-fallbacks),
                        var(--cjk-primary-font-family), var(--cjk-font-fallbacks),
                        sans-serif !important;
        --font-display: var(--display-font-family), var(--default-font-fallbacks),
                        var(--cjk-display-font-family), var(--cjk-font-fallbacks),
                        sans-serif !important;
        --font-headline: var(--headline-font-family), var(--default-font-fallbacks),
                         var(--cjk-headline-font-family), var(--cjk-font-fallbacks),
                         sans-serif !important;
    }

    :lang(kr) {
        --font-primary: var(--primary-font-family), var(--default-font-fallbacks),
                        var(--cjk-primary-font-family), var(--cjk-font-fallbacks),
                        sans-serif !important;
        --font-display: var(--display-font-family), var(--default-font-fallbacks),
                        var(--cjk-display-font-family), var(--cjk-font-fallbacks),
                        sans-serif !important;
        --font-headline: var(--headline-font-family), var(--default-font-fallbacks),
                         var(--cjk-headline-font-family), var(--cjk-font-fallbacks),
                         sans-serif !important;
    }

    code, pre, tt, kbd:not(.badmono), samp {
        font-family: var(--code-font-family), var(--code-font-fallbacks),
                     var(--cjk-code-font-family), var(--cjk-code-font-fallbacks),
                     monospace !important;
        font-feature-settings: var(--code-font-feature-settings) !important;
    }
}

Reviews

No reviews yet.