Assign shield icons based on ref length #1086
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #86
This PR changes the behavior of shield icon selection. Instead of measuring the aspect ratio of the displayed text, it simply chooses by matching string length to the length specified at the end of the icon's filename (e.g.
shield_us_i_2
,shield_us_i_3
).Certain narrow characters (currently
) are considered to be two-thirds of a width of all other characters. This ensures that
1
,I
,i
,l
and111
, for example, is assigned a 2-digit variant icon if available.Background
When I was working on #1083, it looked great on my computer screen (Firefox/Linux). Once it deployed, I checked it out on my phone (Firefox/Android), and to my disappointment, every Utah shield displayed the 3-digit variant icon. Alas, even #965 didn't fix the inconsistent text metrics across different platforms. Americana needs to choose the icon based on platform-independent factors.