Let's first enumare all the metrics related to your particular font:
- Ascender: 1303
- Descender: 453
- lower case letter (ex): 460
- capital letter: 840
- content area: 1303 + 453 = 1756
If you set font-size:30px
then the content area will be 52.68px
$(document).ready(function() {
setTimeout(function() {
console.log($('div#font span').outerHeight());
},500)
});
span {
outline: 1px solid green;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Pacifico&display=swap" rel="stylesheet">
<div id="font" style="font-family: 'Pacifico'; font-size: 30px; outline: 1px solid red;">
<span>Some play</span>
</div>
As you can clearly see the p
and y
are already touching the bottom part. To get the top part we need to consider the Capital letter height (840) which is equal to 25.2px
for font-size:30px
. We add this to the descender and we get 38.79px
span {
display: inline-block;
transform: translateY(-7px);
}
<link href="https://fonts.googleapis.com/css2?family=Pacifico&display=swap" rel="stylesheet">
<div id="font" style="font-family: 'Pacifico'; font-size: 30px;line-height:39px; outline: 1px solid red;">
<span>Some play</span>
</div>
But you will notice that the l
is a bit high than the capital letter and if you add more letters it will get more tricky with all the different cases to consider:
span {
outline: 1px solid green;
}
<link href="https://fonts.googleapis.com/css2?family=Pacifico&display=swap" rel="stylesheet">
<div id="font" style="font-family: 'Pacifico'; font-size: 30px; outline: 1px solid red;">
<span>ÂÄÏÎÖË ABCMNOPQTSome play gj </span>
</div>
The conclusion from these tests is that you have the content area where all the character will be painted and you are sure they will never go outside. This area is the sum of Ascender + Descender but having a particular text, it would be tricky to identify the area for the characters you are using. You will not have the same result with and without Capital letter, with and without descender letter, with or without some special character, etc.
Related question: Can specific text character change the line height?