Skip to content

Commit

Permalink
Fonts: Handle disabling of src local()
Browse files Browse the repository at this point in the history
  • Loading branch information
regisphilibert committed Feb 10, 2022
1 parent fdddb2b commit 2bc7ba9
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions core/fonts/private/GetLocals.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,29 @@
*/}}
{{ $local := slice }}

{{ with .local }}
{{/* This safely append the value of .local (a string or a slice) to the $local slice */}}
{{ $local = $local | append . }}
{{ else }}
{{/* If local is not set, we'll build it ourselves based on the font family name */}}
{{ with .family }}
{{ $config := partialCached "huge/config/Get" "fonts" "fonts" }}

{{/* We add local */}}
{{/* 1. Font local setting is ommited */}}
{{ $add_local := not (isset . "local") }}
{{/* 2. OR font local setting is not `false` */}}
{{ $add_local = $add_local | or (ne .local false) }}
{{/* 2. AND fonts global setting `disable_local` is not true */}}
{{ $add_local = $add_local | and (not $config.disable_local) }}

{{ if $add_local }}
{{ with .local }}
{{/* This safely append the value of .local (a string or a slice) to the $local slice */}}
{{ $local = $local | append . }}
{{/* If a whitespace is in the family name, we can add a local with dash in place of ws */}}
{{ if in . " " }}
{{ $local = $local | append (replace . " " "-") }}
{{ else }}
{{/* If local is not set, we'll build it ourselves based on the font family name */}}
{{ with .family }}
{{ $local = $local | append . }}
{{/* If a whitespace is in the family name, we can add a local with dash in place of ws */}}
{{ if in . " " }}
{{ $local = $local | append (replace . " " "-") }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}

{{ return $local }}

0 comments on commit 2bc7ba9

Please sign in to comment.