Custom fonts by vednoc

Imported and mirrored from https://raw.githubusercontent.com/vednoc/custom-fonts/main/fonts.user.styl

Custom fonts screenshot
Homepage Install Get Stylus Write a review

Details

Authorvednoc

LicenseMIT

Created

Updated

Categoryglobal

Statistics

Learn how we calculate statistics in the FAQ.

Total views

Total installs

Weekly installs

Description

Apply custom base font globally.

Notes

Inspired by openstyles/stylus/#1236. If you find bugs and/or have suggestions, feel free to open an issue on GitHub.

Source code

/* ==UserStyle==
@name         Custom fonts
@namespace    github.com/vednoc/custom-fonts
@description  Apply your favorite custom fonts with ease.
@author       vednoc <vednoc@pm.me> (https://github.com/vednoc)
@homepageURL  https://github.com/vednoc/custom-fonts
@supportURL   https://github.com/vednoc/custom-fonts/issues
@updateURL    https://userstyles.world/api/style/85.user.css
@preprocessor stylus
@version      0.5.0
@license      MIT

@var text base 'Set your favorite Base font' 'null'
@var select baseStyle 'Base font style' {
    'Default*': 'null',
    'Normal  ': 'normal',
    'Italic  ': 'italic',
    'Oblique ': 'oblique',
}
@var select baseWeight 'Base font weight' {
    'Default     *': 'null',
    '100          ': '100',
    '200          ': '200',
    '300          ': '300',
    '400 (Normal) ': '400',
    '500          ': '500',
    '600          ': '600',
    '700 (Bold)   ': '700',
    '800          ': '800',
    '900          ': '900',
}

@var text mono 'Set your favorite Mono font' 'null'
@var select monoStyle 'Mono font style' {
    'Default*': 'null',
    'Normal  ': 'normal',
    'Italic  ': 'italic',
    'Oblique ': 'oblique',
}
@var select monoWeight 'Mono font weight' {
    'Default     *': 'null',
    '100          ': '100',
    '200          ': '200',
    '300          ': '300',
    '400 (Normal) ': '400',
    '500          ': '500',
    '600          ': '600',
    '700 (Bold)   ': '700',
    '800          ': '800',
    '900          ': '900',
}

@var checkbox inputs 'Use Mono font in input areas' 0
==/UserStyle== */

@-moz-document regexp("https?://.*") {
    i = !important

    // Exclude default code areas.
    n ?= ':not(code):not(pre):not(pre > span):not(code > span)'

    // Exclude icon fonts.
    n += ':not(.i):not(.icon)'
    n += ':not(.fa):not(.fab):not(.fad):not(.fal):not(.far):not(.fas)'
    n += ':not(.fa-solid):not(.fa-regular):not(.fa-light):not(.fa-duotone):not(.fa-thin):not(.fa-sharp):not(.fa-brands)'
    n += ':not([class*="octicon-"])' // github
    n += ':not(.glyphicon)' // searx
    n += ':not([aria-hidden=true])' // google meet
    n += ':not([class*=material-icons])' // material icons
    n += ':not([class*=icofont])' // icofont icons
    n += ':not([class*=selector__glyph][data-bind])' // fontello icons

    // Exclude icons on DuckDuckGo.
    n += ':not(input[id^="search"][type=submit][value=S])' // search bar
    n += ':not([class*="js-side-menu-"])' // navbar menu
    n += ':not(.ddgsi):not(.btn--icon)' // misc icons

    // Exclude code areas on GitHub.
    n += ':not([class^="blob-"]):not([class^="blob-"] span)'

    // Exclude code areas on GitLab.
    n += ':not(.diff-line-num):not(pre > code > span span)'
    n += ':not(.diff-viewer *)' // commit diff

    // Exclude various text editors.
    n += ':not(.ace_editor):not(.ace_editor *)' // #2
    n += ':not(.CodeMirror):not(.CodeMirror *)'
    n += ':not(.monaco-editor *)'
    n += ':not(#squire *)' // protonmail

    // Exclude Gmail composer and font menu. #3
    n += ':not(div[jsaction][jslog] *)'
    n += ':not([id][style*="font-family"]):not([id][style*="font-family"] *)'

    // Exclude utility classes for fonts.
    n += ':not(.monospace):not(.text-mono)'

    // Feat: use mono font in input areas.
    if inputs {
        // Exclude inputs of button type. #6
        n += ':not(input:not([type=button])):not(textarea)'

        // Use mono input font on Discord.
        n += ':not([data-slate-editor=true] *)'
        n += ':not([class*="channelTextArea-"] *)'

        // Workaround for specificity issues.
        :not(#x):not(#y):not(#z) {
            // Discord.
            [class*="channelTextArea-"],

            // Gmail. #3
            [contenteditable=true]:not([g_editable]) *,
            input:not([name="subjectbox"]):not([type=button]),

            textarea {
                // Feat: set font options if values are not null.
                font-family: mono       i if mono
                font-style:  monoStyle  i if monoStyle
                font-weight: monoWeight i if monoWeight
            }
        }
    }

    // Feat: set font options if values are not null.
    { n } {
        font-family: base       i if base
        font-style:  baseStyle  i if baseStyle
        font-weight: baseWeight i if baseWeight
    }
}

Reviews

No reviews yet.