Make WordPress Core


Ignore:
Timestamp:
01/18/2019 06:37:26 PM (6 years ago)
Author:
laurelfulford
Message:

Twenty Nineteen: Use a less aggressive approach for non-latin font fallbacks.

The theme's original approach to its non-latin font fallbacks required !important, which overrode fonts that shouldn't have been changed, like the icon fonts used for editor buttons.

Props kjellr, mako09, allancole.
Fixes #45731.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentynineteen/sass/mixins/_mixins-master.scss

    r44149 r44650  
    8888}
    8989
    90 /* Fallback for non-latin fonts */
    91 
    92 @mixin non-latin-fonts( $wrapper_classname: '.site' ) {
    93 
    94     /* Arabic */
    95     html[lang="ar"] #{$wrapper_classname} *,
    96     html[lang="ary"] #{$wrapper_classname} *,
    97     html[lang="azb"] #{$wrapper_classname} *,
    98     html[lang="ckb"] #{$wrapper_classname} *,
    99     html[lang="fa-IR"] #{$wrapper_classname} *,
    100     html[lang="haz"] #{$wrapper_classname} *,
    101     html[lang="ps"] #{$wrapper_classname} * {
    102       font-family: Tahoma, Arial, sans-serif !important;
    103     }
    104 
    105     /* Cyrillic */
    106     html[lang="be"] #{$wrapper_classname} *,
    107     html[lang="bg-BG"] #{$wrapper_classname} *,
    108     html[lang="kk"] #{$wrapper_classname} *,
    109     html[lang="mk-MK"] #{$wrapper_classname} *,
    110     html[lang="mn"] #{$wrapper_classname} *,
    111     html[lang="ru-RU"] #{$wrapper_classname} *,
    112     html[lang="sah"] #{$wrapper_classname} *,
    113     html[lang="sr-RS"] #{$wrapper_classname} *,
    114     html[lang="tt-RU"] #{$wrapper_classname} *,
    115     html[lang="uk"] #{$wrapper_classname} * {
    116       font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, sans-serif !important;
    117     }
    118 
    119     /* Chinese (Hong Kong) */
    120     html[lang="zh-HK"] #{$wrapper_classname} * {
    121         font-family: -apple-system, BlinkMacSystemFont, 'PingFang HK', 'Helvetica Neue', "Microsoft YaHei New", STHeiti Light, sans-serif !important;
    122     }
    123 
    124     /* Chinese (Taiwan) */
    125     html[lang="zh-TW"] #{$wrapper_classname} * {
    126         font-family: -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Helvetica Neue', "Microsoft YaHei New", STHeiti Light, sans-serif !important;
    127     }
    128 
    129     /* Chinese (China) */
    130     html[lang="zh-CN"] #{$wrapper_classname} * {
    131         font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', "Microsoft YaHei New", STHeiti Light, sans-serif !important;
    132     }
    133 
    134     /* Devanagari */
    135     html[lang="bn-BD"] #{$wrapper_classname} *,
    136     html[lang="hi-IN"] #{$wrapper_classname} *,
    137     html[lang="mr"] #{$wrapper_classname} *,
    138     html[lang="ne-NP"] #{$wrapper_classname} * {
    139       font-family: Arial, sans-serif !important;
    140     }
    141 
    142     /* Greek */
    143     html[lang="el"] #{$wrapper_classname} * {
    144       font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    145     }
    146 
    147     /* Gujarati */
    148     html[lang="gu"] #{$wrapper_classname} * {
    149       font-family: Arial, sans-serif !important;
    150     }
    151 
    152     /* Hebrew */
    153     html[lang="he-IL"] #{$wrapper_classname} * {
    154       font-family: 'Arial Hebrew', Arial, sans-serif !important;
    155     }
    156 
    157     /* Japanese */
    158     html[lang="ja"] #{$wrapper_classname} * {
    159       font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", Meiryo, "Helvetica Neue", sans-serif !important;
    160     }
    161 
    162     /* Korean */
    163     html[lang="ko-KR"] #{$wrapper_classname} * {
    164       font-family: 'Apple SD Gothic Neo', 'Malgun Gothic', 'Nanum Gothic', Dotum, sans-serif !important;
    165     }
    166 
    167     /* Thai */
    168     html[lang="th"] #{$wrapper_classname} * {
    169       font-family: 'Sukhumvit Set', 'Helvetica Neue', helvetica, arial, sans-serif !important;
    170     }
    171 
    172     /* Vietnamese */
    173     html[lang="vi"] #{$wrapper_classname} * {
    174       font-family: 'Libre Franklin', sans-serif !important;
    175     }
    176 }
    177 
    17890/* Calculates maximum width for post content */
    17991@mixin postContentMaxWidth() {
     
    203115}
    204116
     117/* Ensure all font family declarations come with non-latin fallbacks */
     118@mixin font-family( $font_family: $font__body ) {
     119    font-family: $font_family;
     120    @extend %non-latin-fonts;
     121}
     122
     123/* Build our non-latin font styles */
     124%non-latin-fonts {
     125    @each $lang, $font__fallback in $font__fallbacks {
     126        &:lang(#{$lang}) {
     127            font-family: unquote( $font__fallback );
     128        }
     129    }
     130}
     131
    205132@import "utilities";
Note: See TracChangeset for help on using the changeset viewer.