From 3677e51e342236a7f87140cdf726e25fc88b45b5 Mon Sep 17 00:00:00 2001 From: "Dan O. Williams" <11464021+thisisdano@users.noreply.github.com> Date: Tue, 12 Mar 2019 06:13:23 -0700 Subject: [PATCH 1/4] Add system font metadata to typeface tokens --- src/stylesheets/core/_system-tokens.scss | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/stylesheets/core/_system-tokens.scss b/src/stylesheets/core/_system-tokens.scss index 3d2ee1b4b2..df2c74141c 100644 --- a/src/stylesheets/core/_system-tokens.scss +++ b/src/stylesheets/core/_system-tokens.scss @@ -177,16 +177,19 @@ $system-typeface-tokens: ( display-name: null, cap-height: 362px, stack: $font-stack-system, + system-font: true, ), 'georgia': ( display-name: 'Georgia', cap-height: 346px, stack: $font-stack-georgia, + system-font: true, ), 'helvetica': ( display-name: 'Helvetica', cap-height: 357px, stack: $font-stack-helvetica, + system-font: true, ), 'tahoma': ( display-name: 'Tahoma', From 7fc5516dfd17b8d2b873ed58bf27e2038889e52f Mon Sep 17 00:00:00 2001 From: "Dan O. Williams" <11464021+thisisdano@users.noreply.github.com> Date: Tue, 12 Mar 2019 06:15:01 -0700 Subject: [PATCH 2/4] Output display name in font stack conditionally [see details] - Output only is font has a display name - If font is a system font, output only if a custom stack is defined --- src/stylesheets/core/_functions.scss | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/stylesheets/core/_functions.scss b/src/stylesheets/core/_functions.scss index cadd2838c4..1c7c8d93a1 100644 --- a/src/stylesheets/core/_functions.scss +++ b/src/stylesheets/core/_functions.scss @@ -599,17 +599,19 @@ role-based font token. @function get-font-stack($token) { $type-token: convert-to-font-type($token); + $output-display-name: true; $this-stack: null; $this-font-map: map-get($project-font-type-tokens, $type-token); @if map-get($this-font-map, 'typeface-token') { $this-font-token: map-get($this-font-map, 'typeface-token'); - $this-name: map-deep-get( - $all-typeface-tokens, - $this-font-token, - 'display-name' - ); + $this-typeface-data: map-get($all-typeface-tokens, $this-font-token); + $this-name: map-get($this-typeface-data, 'display-name'); + @if map-has-key($this-typeface-data, 'system-font') { + $output-display-name: false; + } @if map-get($this-font-map, 'custom-stack') { $this-stack: map-get($this-font-map, 'custom-stack'); + $output-display-name: true; } @else { $this-stack: map-deep-get( @@ -618,6 +620,12 @@ role-based font token. 'stack' ); } + @if map-get($this-typeface-data, 'display-name') == null { + $output-display-name: false; + } + @if not $output-display-name { + @return #{$this-stack}; + } @return #{$this-name}, #{$this-stack}; } @return false; From 17fd81fbd50fb895a8fb025a020a431da6d1d8c0 Mon Sep 17 00:00:00 2001 From: "Dan O. Williams" <11464021+thisisdano@users.noreply.github.com> Date: Tue, 12 Mar 2019 06:22:36 -0700 Subject: [PATCH 3/4] Add function comments --- src/stylesheets/core/_functions.scss | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/stylesheets/core/_functions.scss b/src/stylesheets/core/_functions.scss index 1c7c8d93a1..b88419509a 100644 --- a/src/stylesheets/core/_functions.scss +++ b/src/stylesheets/core/_functions.scss @@ -598,21 +598,28 @@ role-based font token. */ @function get-font-stack($token) { + // Start by converting to a type token (sans, serif, etc) $type-token: convert-to-font-type($token); $output-display-name: true; $this-stack: null; + // Get the font type metadata $this-font-map: map-get($project-font-type-tokens, $type-token); + // Only output if the font type has an assigned typeface token @if map-get($this-font-map, 'typeface-token') { $this-font-token: map-get($this-font-map, 'typeface-token'); + // Get the typeface metadata $this-typeface-data: map-get($all-typeface-tokens, $this-font-token); $this-name: map-get($this-typeface-data, 'display-name'); + // If it's a system typeface, don't output the display name @if map-has-key($this-typeface-data, 'system-font') { $output-display-name: false; } + // If there's a custom stack, use it and output the display name @if map-get($this-font-map, 'custom-stack') { $this-stack: map-get($this-font-map, 'custom-stack'); $output-display-name: true; } + // Otherwise, just get the token's default stack @else { $this-stack: map-deep-get( $all-typeface-tokens, @@ -620,6 +627,7 @@ role-based font token. 'stack' ); } + // If the typeface has no display name (system fonts), don't output the display name @if map-get($this-typeface-data, 'display-name') == null { $output-display-name: false; } From e1e44d091fe01a256a58b4b672420adfede63a01 Mon Sep 17 00:00:00 2001 From: "Dan O. Williams" <11464021+thisisdano@users.noreply.github.com> Date: Tue, 12 Mar 2019 06:46:25 -0700 Subject: [PATCH 4/4] Use 'Helvetica Neue' as helvetica's display name --- src/stylesheets/core/_system-tokens.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stylesheets/core/_system-tokens.scss b/src/stylesheets/core/_system-tokens.scss index df2c74141c..d27953d7a2 100644 --- a/src/stylesheets/core/_system-tokens.scss +++ b/src/stylesheets/core/_system-tokens.scss @@ -186,7 +186,7 @@ $system-typeface-tokens: ( system-font: true, ), 'helvetica': ( - display-name: 'Helvetica', + display-name: 'Helvetica Neue', cap-height: 357px, stack: $font-stack-helvetica, system-font: true,