You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Disallow expressions for text-font, or require fontstacks to be listed up front #9939
One of the components of an offline region download is the complete set of glyph range PBFs for all the font stacks used by that region's style. We currently determine the set of font stacks via this method:
This will fail for text-font properties that use an expression. We need to either disallows the use of expressions for text-font, or introduce a new top-level style spec property that explicitly declares all the font stacks that the style uses (or at least the font stacks that should be available offline).
@jfirebaugh as an in-between compromise, we could allow expressions of some tightly constrained form for text-font, such that we could implement the equivalent of the above code to collect the possible values from literals in the expression.
we could allow expressions of some tightly constrained form for text-font
Could expressions that only include literal values be allowed? I think the most common use cases for expressions for text-font would mainly just involve literal values (e.g. in match expressions and/or zoom curves).
Yeah, along the lines of @nickidlugash's point, one way to formulate this restriction that seems pretty reasonable both to implement and communicate:
text-font expressions must have a finite number of output values. I.e., varying expressions like [zoom], [get, property_name], [id] may not be used to construct the output value for a text-font expression.
So [ "concat", "Wingdings", ["match", ["get", "font-weight"], "regular", "", "bold", " Bold"]] would fail validation with the above error message, but [ "match", ["get", "font-weight"], "regular", "Wingdings", "bold", "Wingdings Bold"] would pass.
update: Hmm, actually the stated restriction doesn't quite capture it, since it technically would describe both of the examples above.
That also sounds more restrictive than what @nickidlugash wants. E.g., it disallows things like ["curve", ["step"], ["zoom"], "Stack A", 4, "Stack B"].
So long as text-font allows only feature-constant expressions, static analysis can determine the bounded set of possible output values. If we allow text-font to have feature-varying expressions, then some expressions will be ok (e.g. ["match", ["get", "foo"], "a", "Stack A", "Stack B"]), while others will not (["get", "stack"]). Still, static analysis should be able to tell when the set of possible output values is unbounded, and we can disallow those cases.
Activity
anandthakker commentedon Sep 8, 2017
@jfirebaugh as an in-between compromise, we could allow expressions of some tightly constrained form for
text-font, such that we could implement the equivalent of the above code to collect the possible values from literals in the expression.nickidlugash commentedon Sep 9, 2017
Could expressions that only include literal values be allowed? I think the most common use cases for expressions for
text-fontwould mainly just involve literal values (e.g. inmatchexpressions and/orzoomcurves).anandthakker commentedon Sep 11, 2017
Yeah, along the lines of @nickidlugash's point, one way to formulate this restriction that seems pretty reasonable both to implement and communicate:
text-fontexpressions must have a finite number of output values. I.e., varying expressions like[zoom],[get, property_name],[id]may not be used to construct the output value for atext-fontexpression.So
[ "concat", "Wingdings", ["match", ["get", "font-weight"], "regular", "", "bold", " Bold"]]would fail validation with the above error message, but[ "match", ["get", "font-weight"], "regular", "Wingdings", "bold", "Wingdings Bold"]would pass.update: Hmm, actually the stated restriction doesn't quite capture it, since it technically would describe both of the examples above.
jfirebaugh commentedon Sep 12, 2017
That also sounds more restrictive than what @nickidlugash wants. E.g., it disallows things like
["curve", ["step"], ["zoom"], "Stack A", 4, "Stack B"].jfirebaugh commentedon Oct 11, 2017
So long as
text-fontallows only feature-constant expressions, static analysis can determine the bounded set of possible output values. If we allowtext-fontto have feature-varying expressions, then some expressions will be ok (e.g.["match", ["get", "foo"], "a", "Stack A", "Stack B"]), while others will not (["get", "stack"]). Still, static analysis should be able to tell when the set of possible output values is unbounded, and we can disallow those cases.