Question probably sounds confusing so let me clarify.

Let's say I have an object containing keys and values for my project's font sizes:

    small: '8px',
    medium: '11px',
    large: '14px',

This is fine, but it's not very flexible or scalable; it would not - for example, allow me to insert a new size between small and medium.

I can't think of any possible scale that would allow for this, let alone a sensible one.

The only thing I can think of is assigning unsemantic keys to the values, like john, dave and steve instead of small, medium and large. But this is not very transparent. How do I know if John is bigger or smaller than Steve unless I memorize it before hand?

  • 2
    Language is almost infinitely malleable. Font designers have had these problems for a long time, and they've usualy solved them by getting creative, with constructions like "semi-bold" or "ultra-large". The result is usually not pretty, but it does exist. Oct 9, 2018 at 6:40
  • I think you're looking for a binary tree.
    – Pieter B
    Oct 9, 2018 at 6:43

1 Answer 1


A literal solution to this is to name your font sizes like their size parameter:

    size8: '8px',
    size11: '11px',
    size14: '14px',

This gives you exactly what you asked for - an option for trivial insertions at any point of the scale.

One can ask if introducing such symbolic names, where the pixel size is just repeated in the name, is really meaningful. Well, that depends. At least, at gives you

  • a definition of the "allowed" font sizes for your project
  • a possibility to change the pixel sizes later, even if the names are kept.

Of course, a naming like

     size8: '9px',
     size11: '12px',
     size14: '16px',

has a certain potential of becoming confusing, and you should really ask what's your goal by using such symbolic constants. If you have a use case where the numbers in the name as "logical" sizes, and the pixel sizes themselves are "physical" sizes (maybe for a different output device), then this could be ok.

  • Interesting thoughts - I had initially dismissed such literal naming but didn't consider that it at least gives "a definition of the allowed font sizes for your project" which is actually still very useful.
    – ESR
    Oct 9, 2018 at 4:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.