Suunto app Forum Suunto Community Forum
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Precise alignment of text and numbers

    Scheduled Pinned Locked Moved Suunto Plus Development
    1 Posts 1 Posters 51 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      matram
      last edited by

      I was struggling with getting good alignment when combining font sizes and using text drawn on the canvas. I did this small experiment to understand better.

      2c8dc331-432a-459a-8433-c62a5e10cb19-Pasted Graphic 3.png 
      This screen has two elements positioned like this

      <div class="f-d-m f-num" style="top:calc(50%);left:calc(30% - 50%e);">
      <div class="f-d-xs f-num" style="top:calc(50%);left:calc(70% - 50%e);">
      

      The green line is at 233px (50%), the red line is 78px below, which is the font size for the ‘f-d-m’ font.

      The height of the numbers is smaller than the font size, not surprising as such, but the effect with differents size fonts is that they do not align on the top.

      With this setup …

       <div class="f-d-m f-num" style="top:calc(50% - 50%e);left:calc(30% - 50%e);">
       <div class="f-d-xs f-num" style="top:calc(50% - 50%e);left:calc(70% - 50%e);">
      

      We get this …
      8476b69d-2115-4f97-afc1-fe7f2926dd98-Pasted Graphic 1.png 
      Not precisely centered vertically but maybe good enough.

      Best seems to be to align at the bottom, i.e. -100%e.
      a790bca7-6c68-4491-82b4-63600e72d7fe-Pasted Graphic 2.png 
      It could be useful with more information about font metrics if we want to achieve perfect alignment.

      1 Reply Last reply Reply Quote 2
      • First post
        Last post

      Suunto Terms | Privacy Policy