Font-face rendering issue with specific font

Is it possible to display text with different fonts in the same HTML file without needing to install them on the device?

For example:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../../fonts/stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body >
<div>
  <div class="e_content ">
    <div class="e_number">1.</div>
   <div class="e_text"> <a href="../../chapters/english/v/v1/v1_1.html"> Bh¤µ¤Ô¤Â×Ô¤ßuȤÌÚÙ ¤´a¢¿¤ÔßuÂÂÛ ÏÚ´¤ÔÚ ÔÛÖá. </a> </div>
  </div>
  <div class="e_content1">
    <div class="e_number1">2.</div>
    <div class="e_text1"> <a href="../../chapters/english/v/v1/v1_2.html">  »ÜU¢ïùãæ Ï¢ãéS²¢æ Ðí…¢²ï² </a> </div>
  </div>
</div>
</body>
</html>

In this example, the first div uses Trans.ttf font and the second div uses AnamikaTwo.ttf font as defined in StyleSheet.css. However, when viewed, the second div is displayed correctly while the first one is not.

The font-face definitions in Stylesheet.css are:

@font-face
    {
        font-family: "AnamikaTwo";
        src: url('AnamikaTwo.ttf'); format("truetype");
    }
@font-face
    {
        font-family: "Trans";
        src: url('Trans.ttf'); format("truetype");
    }
.e_number { float:left; background:url(index-number-bg.png) no-repeat left top; width:45px; height:50px; line-height:30px; text-align:center; color:#6a2525; font-family:"Trans"; margin:0px 10px 0px 10px;}
.e_content {float:left; width:100%; margin:1px 0px 0px 0px; padding:8px 0; background:#fdeec5;text-align:left;border-bottom: 1px solid #E4D4AA; opacity:0.6;}   
.e_text a {color:#6a2525; text-decoration:none; font-family:'Trans';}
.e_number1 { float:left; background:url(index-number-bg.png) no-repeat left top; width:45px; height:50px; line-height:30px; text-align:center; color:#6a2525; font-family:"AnamikaTwo"; margin:0px 10px 0px 10px;}
.e_content1 {float:left; width:100%; margin:1px 0px 0px 0px; padding:8px 0; background:#fdeec5;text-align:left;border-bottom: 1px solid #E4D4AA; opacity:0.6;}  
.e_text1 a {color:#6a2525; text-decoration:none; font-family:'AnamikaTwo';}

Download fonts from the link for reference: click here

Answer №1

If your fonts are legally embeddable for web use, you can visit and upload your .tff font files.

Choose 'optimal' or explore the 'expert' settings for specific embedding options, especially if you only require certain type variations to reduce load time.

After processing all glyphs, click on the 'download your kit' button to access a zip archive with an example of how to embed your fonts using @font-face.

In the stylesheet.css file, you will find something like this:

@font-face {
font-family: 'yourfont';
src: url('yourfont-webfont.eot');
src: url('yourfont-webfont.eot?#iefix') format('embedded-opentype'),
     url('yourfont-webfont.woff') format('woff'),
     url('yourfont-webfont.ttf') format('truetype'),
     url('yourfont-webfont.svg#yourfont') format('svg');
font-weight: normal;
font-style: normal;
}

Remember that if you upload your fonts to a /fonts directory, you must correctly reference the files in your CSS (e.g., ../fonts/yourfont-webfont.eot).

Hope this information proves useful.

An alternative option is Adobe TypeKit: , which simplifies the process of font embedding.

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

ErrorMessage: Found an unexpected character '{' while parsing the jQuery DataTables code

I've been attempting to incorporate the datatable library into my code, but I'm consistently encountering a SyntaxError: Unexpected token '{' in the javascript console. Even after searching for a solution online, it appears that my jav ...

Transferring data from a table to another window

Currently, I am retrieving values from a database and displaying them in a table. I would like to add a button to each row that will allow users to view more details about that specific row. At the moment, only ThesisID, AuthorID, and Title are visible. ...

How to harness the power of loops in JavaScript

Having trouble getting this code to repeat a CSS transition properly. for (var i=0 ; i<4 ; i++){ setTimeout(function() { $('#top-left').css('margin', '45px 0 0 45px'); $('#top-mid' ...

Every time a new message is sent or received, I am automatically brought back to the top of the screen on the

I'm currently working on integrating a chat feature into my Angular Firestore and Firebase app. Everything seems to be functioning well, except for one issue - whenever a new message is sent or received, the screen automatically scrolls up and gets st ...

Adding vibrant color to buttons and eliminating underlines from anchor elements inside

Need help creating a button with the entire area in red color, and the href text should only display "OCR" without hyperlink formatting. Button images have been included as well. .block0 { display: block; width: 100%; border: none; background-co ...

Show the price of the item with a click of a button

There are three buttons where I can select values and input them into the button. Once all three values are selected in the buttons, I would like the product of these values to be displayed in a fourth button. Here is my HTML code: <label>S *</l ...

The Bootstrap carousel comes with a brilliant feature! Conceal those 'previous' and 'next' buttons when you reach the first and last slide. However, it seems like the 'slide' event is not functioning as

I have implemented a standard Bootstrap carousel on my website: <div id="myCarousel" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#myCarousel" data- ...

Set the side columns in CSS to have a fixed width, while the center content column should have

Check out this fiddle I created for everyone to view: http://jsfiddle.net/defaye/DhaHP/4/ For the full-screen result, click here: http://jsfiddle.net/defaye/DhaHP/4/embedded/result/ I'm encountering an issue where, after resizing the window past a ce ...

Issue with Javascript functionality not persisting after page reload initiated with a href = '#'

I am facing an issue with a button on my webpage that is meant to redirect and reload the home page. However, after redirection to '#', my JavaScript seems to stop functioning correctly. Currently, my JavaScript code is enclosed within window.on ...

Fixing a menu hover appearance

I recently encountered a small issue with the menu on my website. When hovering over a menu item, a sub-menu should appear. However, there seems to be a slight misalignment where the submenu appears a few pixels below the actual menu item. Check out the w ...

How can I replicate the Firefox style in IE8 using Bootstrap and CSS?

My webpage is styled with Bootstrap v2 and looks great in Firefox. However, I'm struggling to apply the same CSS color style in IE8: .navbar-inverse .navbar-inner { background-color: #1b1b1b; background-image: -moz-linear-gradient(top, #fab ...

Understanding the functionality of sessions in CodeIgniter when using AJAX

I am experiencing an issue with the Session in my code. It only works when the page is refreshed. I have a controller called ravi and the view named myview. Here is the code snippet: <?php class Ravi extends CI_Controller { public funct ...

Angular Material autocomplete options are obscured by browser autofill suggestions

I am facing a challenge in Angular Material where the material autocomplete feature is functioning properly, however, the browser's autofill options are causing an overlap with the material autocomplete popup. Is there a way to disable autocomplete fo ...

Using PHP, JavaScript is unable to hide <div> elements

I'm encountering an issue where the div I want to show when an error occurs is not hiding and showing properly using JavaScript. Here is a snippet of my code: <script> function hideerror() { var catdiv = document.getElementById(error); ...

Blazor Control in Razor Component Library (CSS Protection)

I recently created a new component named MyComponent.razor and included a corresponding CSS file called MyComponent.razor.css. The CSS file is nested under the component file in Visual Studio, so I am confident there are no spelling errors in the file path ...

The Chocolat.js Lightbox plugin is experiencing issues with jQuery as it is unable to detect the

I am in the process of integrating chocolat.js into a basic website. An issue I encountered was that the thumbnail was directly processing the anchor link, which resulted in the image opening in a new window instead of launching it in a modal on the screen ...

Steps for saving the ajax response in a jQuery variable and displaying it in an HTML textbox

Here is a link to my code snippet on GitHub: https://gist.github.com/anuragk098/3e11673136325b5e5b1859bde11f2117 And here is a link to my webpage: The first text box in my project retrieves all the cities using a jQuery function: var months = [<?=$cit ...

In Safari, there seems to be an issue where multiple URLs are not opening when clicked on from an anchor

Is there a way to open multiple URLs in Safari with just one click using window.open? I tried it, but only one URL opens in a new tab while the others do not. The version of Safari I am using is 11.0.1. onclick="window.open('URL1','_blank& ...

adjust the transparency level of the background color for a div element that is compatible with Internet Explorer

Looking for a way to adjust the opacity of a div's background? This is easily done in modern browsers such as Chrome and Firefox using rgba. However, I'm facing difficulties with IE7. The "filter: alpha(opacity=50);" property doesn't work f ...

JavaScript function that allows jQuery .val() to replace trailing decimal points

Currently, I am working on restricting the input allowed in a numeric text field. My approach involves checking the length of the input field's value, and if it is greater than or equal to the specified maxlength attribute, no further input is accepte ...