My custom fonts in CSS are being truncated at the bottom, specifically the descenders like "g" and "y"

I am struggling to understand why certain letters, like 'g' and 'y', are being cut off when they drop below the line in my paragraph. I have tried adjusting the line height, experimenting with different font sizes in pixels, points, and ems, but nothing seems to work. Interestingly, when I increase the font size significantly (e.g., 3.0em), the issue disappears, but that's not the ideal font size I need.

To see the problem for yourself, please visit this link:

In order to truly grasp the issue, you may need to view the .ttf font I am using from the provided link.

<html>
<head>
<style>
@font-face {
font-family: lib-font;
src: url('css/LiberationSansNarrow-Regular.ttf');
}
@font-face {
font-family: lib-bold;
src: url('css/LiberationSansNarrow-Bold.ttf');
}   
</style>
</head>
<body>

<span style='font-family: lib-font;color: #232322;font-size: 1.0em;'>   
The quick brown foxy was jumping over the green doggy.<br/>
The quick brown foxy was jumping over the green doggy.<br/>
The quick brown foxy was jumping over the green doggy.<br/>
The quick brown foxy was jumping over the green doggy.<br/>
The quick brown foxy was jumping over the green doggy. 
</span>

Answer №1

Experiment with

line-height: standard;

Appeared to resolve issues for many users.

Answer №2

Consider adjusting the line-height to a value such as line-height: 1.2;

If you increase the font size to 1.1em, it won't be truncated.

One recommendation is to incorporate a CSS reset like Normalize.

Answer №3

My experience with this issue has been limited to reproducing it only at exactly 16px (equivalent to 1em on my browser). This leads me to believe that there may be a font-related problem similar to the one explained in detail here and here.

To address this issue, options include using the font as-is without setting it to 16px, adjusting the font metrics yourself following the guidance provided in the aforementioned links, reaching out to the font creator for assistance, or selecting an entirely different font. Fortunately, there are numerous high-quality free font alternatives available for consideration. Best of luck in finding a suitable solution!

Answer №4

In my experience, the best solution for resolving this issue is adjusting the font size. It appears that there are some issues with specific custom fonts, particularly in Chrome.

I encountered a similar problem and resolved it by modifying the font size from 30px to 32px, which solved the issue :)

Answer №5

The reason for this issue is the inadequate descender value in the font file. Descenders refer to letters like p, g, q, or y which extend below the baseline. For the font file to display correctly, it needs to have a descender value greater than the lowest letter descender. The browser treats ascenders and descenders as the font "container," cutting off any elements that exceed these values. Unfortunately, CSS cannot resolve this problem since it originates from the font file itself.

To rectify this issue, one must modify the font file by adjusting these values. It is best to contact the original designer for assistance with this task.

It's worth noting that issues like this are common when using free fonts...

Answer №6

For me personally:

letter-spacing: regular;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to rotate a symbol around its center without the need to specify its position on two separate occasions

I am working on placing tile symbols on a grid and aiming to achieve the following: Utilize tile coordinates for symbol placement (e.g. 4,2 instead of 85,43) Define the vertices of symbols using pixel coordinates (not tile coordinates) Rotate symbols arou ...

a novel approach within angular2

Just starting out with Angular 2. Could someone shed some light on the difference between html directives and attribute directives? And why are they both necessary? For instance: <rating [rate]="rate" (rate-change)="onUpdate($event)"></rating&g ...

Perform a bash command using PHP when an HTML button is clicked

Today, my brain seems to be on vacation. Currently, I have set up a Raspberry Pi with vlc running and connected to a mounted screen on the wall. There is a web page with simple controls to manage the pi, switch between different vlc streams, or stop stream ...

Discovering multiple IDs using xpath or cssSelector can be achieved when they have the same classname

Attempting to retrieve an ID resulted in a no element found exception for the code snippets below: System.out.println(driver.findElement(By.xpath("//a[@class='activity'][contains(.,'First Testing')]")).getAttribute("id");) System.out.p ...

Utilizing Jcrop to Crop an Image that has been Uploaded

Currently, I am working on cropping an uploaded image using Jcrop. My goal is to enable the user to crop the image upon uploading it without storing the original image on the server. Instead, only the cropped part selected by the user via Jcrop will be sav ...

Ways to determine if a list is empty with thymeleaf?

<div th:if="${tblUserList != null}"> --content-- </div> I'm having some trouble with the thymeleaf code provided above. The variable tblUserList is a list, and I need to check if it is empty instead of just checking if it is null. How ca ...

Django raised a ValueError stating that the view usermanager.views.group_perm did not provide an HttpResponse object, but instead returned None

I'm currently in the process of developing a News Website. However, I've run into an issue when attempting to delete permissions from a group - I keep getting the same error. Oddly enough, the codes above this particular function are nearly ident ...

What is the best way to trigger a function following a user's selection from a form-control on a webpage?

I am looking for a way to automatically execute a function when a year is selected without needing a button. I am using HTML, JavaScript, and bootstrap 5. Any suggestions on how to achieve this? Thank you. function onSelect() { console.log('Hel ...

Transfer an image to the top of a cell

I'm trying to position the image at the top of the cell, but I've hit a roadblock. Here's a preview of the web photo: https://i.sstatic.net/U3XK9.png Here is my CSS code: #animes { width: 130px; height: 100px; display: block; padd ...

Using JQuery to cycle a class with a timer

My list has the following structure <div id="slider"> <ul> <li class='active'> a </li> <li> b </li> <li> c </li> <li> d </li> <li> e </li> </u ...

The behavior of Elementor lightbox buttons upon being clicked

When using Android, I've noticed that the lightbox briefly displays a semitransparent cyan bar on the left and right buttons when they are pressed. Is there a way to control or prevent this behavior? Any suggestions would be appreciated! Thanks in adv ...

Having difficulty retrieving the Area and Range information in ChartJS

I am new to working with HTML5 and ChartJS. I have noticed two different types of declarations when attaching JS Chart Versions 1.0.1 and 2.1.1. Can you please provide some insight into this? Additionally, I am facing an issue where the stripes behind the ...

Steps for eliminating the thick border around <thead> and <tfoot> elements in Bootstrap

Is there a way to remove the thick border on the <thead> and <tfoot> elements in Bootstrap 4 that seems a bit unnecessary? I found a forum post addressing this issue for Bootstrap 5, but unfortunately, the fix didn't work for me since I a ...

Navigating to a new page by clicking a button

I am trying to redirect to a different web page when a button is clicked. Below is the code snippet I am working with: JavaScript code snippet: app.controller('myCtrl', ['$scope', '$location', function($scope, $location) { ...

When an error message is displayed in the textField, the Material UI button shifts downward

I have incorporated the material UI error message display into my text field. When I click on the button without entering any text in the field, an error message pops up which pushes down the button. I am looking for a way to prevent this behavior but have ...

Showing local storage on a webpage using Jquery

I have encountered an issue where I can successfully add and remove items from local storage, but the added item does not display on my HTML page. The expected behavior is that when an item is added to local storage, it should be visible on a favorites pag ...

Alter Text Using Typewriter

Recently, I have been experimenting with code on my glitch website, trying to create typewriter text. Thanks to help from a user on StackOverflow, I was able to achieve this effect successfully. However, I am now facing a new challenge. My goal is to make ...

Issue with deploying responsive background image on Github platform

My responsive background image isn't displaying properly on mobile devices after I deployed my project to Github. Although it appears correctly under the Google Chrome inspect mobile tool, when accessed live on a mobile device, the image covers the ba ...

Implementing *ngFor in Angular 2 to render a clickable email address within a table row

I am working in TypeScript with an array of objects: array: [ { prop1: 'string1', prop2: this.createEmailLink('<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cfaaa2aea6a38faaa2aea6a3e1aca0a2">[email ...

Display additional javascript code for expanding a marquee

Currently, I am working on a stock ticker project using JavaScript. It's progressing well, and now I am focusing on adding a "show more" button to style the ticker. The button should be placed outside of the marquee. When clicked, it will expand the m ...