0
votes

I am using two different fonts in my website - "sans-serif" and "tradeGothicLTStd". Here is how these fonts are rendered in the browser.

sans-serif

trade-gothic-lt-std

You can notice that in the first screenshot there is some extra space above the font (If you see the uppercase text. Please open it in a new tab with black background to properly see the difference) and while using another font there is no extra space above the font (uppercase text).

Here is how they are rendered when used in a button.

sans-serif

trade-gothic-lt-std

Because of these inconsistencies the fonts go out of position vertically. i.e if I design my css with first font in mind the all uppercase fonts are centered vertically (inside a button or anchor tag etc) but when I change the font to the second font all text kind of moves little upwards since there is no extra space above the font in this case. Because of this my font is not perfectly vertically aligned in the center.

Is there any way to fix this or can someone even tell me why this is happening?

1
Set fix line-height to the element. I think it will help you. - Joykal Infotech
I have fixed line-height. I will center the font in the middle. The text will be perfectly in middle for sans-serif, but when I switch the font to trade-gothic-lt-std the font looks like it is moved vertically up a little bit since there is a lack extra space in the top of the font itself. - vishal

1 Answers

0
votes

On your second picture the font also appears to be stretched. You can scale the font with transform: scale(1, 0.9);. This will scale the font vertically on 90%.

Then, I would use line-height