Skip to content

Instantly share code, notes, and snippets.

@mfdj
Last active August 17, 2016 03:51
Show Gist options
  • Save mfdj/8e7fdd79d02d1d63f719cdfa845658bf to your computer and use it in GitHub Desktop.
Save mfdj/8e7fdd79d02d1d63f719cdfa845658bf to your computer and use it in GitHub Desktop.
/*
When measuring type in comps using a cross-hair tool you may not
always have a descender to check the font-size in pixels, meaning in most cases
(especially for all-caps titles) you only have the ability to measure from
baseline to cap-height.
This algorithm will help you convert that cap-height measurement into the correct
font-size within about pixel (often it's less than half a pixel off).
Adjust for optics and browser-rendering on case-by-case basis.
@return scaled unit (more than likely this will be px but it's not enforced)
*/
@function cap-height-to-font-size($cap-height, $unit-tweak: 0) {
@return ((16 / 13) * $cap-height) + $unit-tweak;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment