When TTF fonts are installed on the device, they take precedence over Google fonts

I have successfully implemented the Ubuntu font from Google Fonts on my website:

<link href='http://fonts.googleapis.com/css?family=Ubuntu:300,400,300italic,400italic,500,500italic,700,700italic' rel='stylesheet' type='text/css' />

In my stylesheet, I have specified the font usage:

body {
    font-family: 'ubuntu',arial;
}

While this setup is functional, I encountered an issue where if a font with the same name (Ubuntu) is installed locally, it overrides the one from Google Fonts.

My question is whether there is a way to prioritize and force the browser to use the Ubuntu font from Google Fonts?

Answer №1

Perhaps the solution is not within your code, but rather in the realm of Google.

Below is a snippet of the CSS you need:

@font-face {
  font-family: 'Ubuntu';
  font-style: normal;
  font-weight: bold;
  src: local('Ubuntu Bold'), local('Ubuntu-Bold'), url('http://themes.googleusercontent.com/static/fonts/ubuntu/v4/0ihfXUL2emPh0ROJezvraLO3LdcAZYWl9Si6vvxL-qU.woff') format('woff');
}

The crucial line is local('Ubuntu Bold'), which triggers the loading of a local file if feasible. One straightforward approach could be to copy all the CSS from Google, paste it into your own stylesheet, and tweak the local descriptor to read something like

local('Ubuntu Bold NonExisting Name or Something Else')
. This fictitious font name will not replace the one loaded by the CSS.

Disclaimer: I have not personally verified this method. If the URL

0ihfXUL2emPh0ROJezvraLO3LdcAZYWl9Si6vvxL-qU.woff
expires, it might pose a challenge. Check the font's licensing terms and consider self-hosting the font if preventing local overrides is crucial.

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

Continuously replicate SVG horizontally without limit

In search of the perfect visual effect, I am eager to develop an infinite animation featuring a car moving horizontally with various landscape layers passing by in SVG format. Struggling to find a way to seamlessly repeat my SVG landscape layers along the ...

The width of Highcharts increases proportionally to the growth of the chart's width

I want to create a highcharts graph where the width increases as data points increase. Currently, I have: I am using vuejs with highcharts, but it should work similarly with jquery or other frameworks. <div class="col-md-6" style= ...

Floating elements overlapping fixed elements

I am currently in the process of developing a mobile application and encountering an issue with relative divs overlapping the top and bottom headers fixed with a z-index. Despite my attempt to resolve this by adding a z-index to the relative div, the probl ...

Image placed as background for registration form

In my Vue project, I am trying to create a login form with an image as the background. However, I am facing an issue where the image is not displaying on the page. Can someone guide me on how to add a picture behind the form? HTML: Below is the HTML code ...

Ways to solve the issue of the mobile dropdown menu in Bootstrap

Check Out the Expected Look Here (Image link) See How it Appears on Mobile Devices The dropdown menu causes an increase in the size of the navbar on the mobile version. Below is the code snippet: <div style=" background-image: url(https://i.imgu ...

Unusual body padding found in the mobile design

When visiting on a mobile device and inspecting the elements in Google Chrome, try disabling the style rule overflow-x: hidden from the body element and then resizing the window. You may notice a white vertical stripe (padding) appearing on the right side ...

Transparent static navbar displayed above header image

Scenario I managed to develop a transparent navbar that is superimposed on top of a header image with an SVG curve attached to it. To create the transparent navbar, I modified some classes associated with it by removing bg-light. By adding the class fix ...

Troubleshooting complications with Bootstrap V5 Navbar including Nested Dropdowns (Submenu, Multilevel, Megamenu)

I'm currently working on implementing a Nested Navbar Dropdown (Submenu, Multilevel, and Mega Menu). However, I am encountering some challenges related to sizing with max-width and min-width, as well as handling directions with dropstart and dropend b ...

Convert HTML form input into a JSON file for safekeeping

<div class="email"> <section class="subscribe"> <div class="subscribe-pitch"> </div> <form action="#" method="post" class="subscribe-form" id="emails_form"> <input type="email" class="subscribe-input" placeholder="Enter ema ...

Harnessing the Power of Material UI to Revolutionize Amplify Theming

I am currently developing a React application with Material-UI and Amplify UI Components. I am looking to customize the Amplify theming. By following the guidance provided on Amplify UI Components Customization, I have been able to override CSS variables ...

fa icons moving the elements aside

I'm attempting to design a navigation menu with tabs, but I'm facing an issue where the tabs containing "fa icons" are consuming too much space, causing other elements to be shifted to the right or below (if there were more lines). How can I pre ...

Customizing Sass Bootstrap Variables for Tailored Responsive Designs (Specifically for Mobile or Desktop)

Currently, I am in the process of working on a website that has opted for the adaptive approach, using separate mobile and desktop templates instead of responsive design. Despite this choice, Bootstrap is still being utilized on these templates, loading al ...

What causes the element with position: fixed and width 100% to exceed the viewport boundaries on iOS 8?

I'm facing an issue with an element that is fixed to the top of the page and scrolls horizontally along with the page. The CSS code for this element is quite straightforward: .thing { position: fixed; top: 0; width: 100%; height: 30px; back ...

Embedding a styled list item within a list

How can I customize the style of list items within a list? HTML code <span class=bbb> <ul> <li>Preparing archive inquiries about study periods or work experience at LLU: <ul> <li>Within seven days - 5 ...

Having issues with the CSS block in my Jekyll dropdown navbar

I have been exploring resources from both w3schools and another website to create a navigation bar in Jekyll using frontmatter. However, I am running into issues with the block property in CSS. Most of the navbar is functioning properly, except for the dro ...

Creating a List with Sublists that are displayed when hovering over the parent List is a key element of effective design

Hovering over 'View Rows' should open up both New Records and Old Records <div> <li>Add Rows</li> <li>DeleteRows</li> <li>View Rows <ul> <li>View New Records</li ...

The styles within a media query are not being successfully implemented

update: issue resolved. I discovered that there was a lingering media query in the css file that was meant to be removed. Also, I corrected some errors in the code. Thank you all for your help – it's now working perfectly. I have a set of html and ...

Troubleshoot: Unable to Change CSS on Click Using Javascript/jQuery

Having trouble creating three different buttons that toggle between various images using the CSS display property? Check out my code on https://jsfiddle.net/agt559e8/. function USradarChange1() { //document.getElementById("usradar1").src="weather/curr ...

Is there a way to eliminate the white background or border on my Font Awesome checkbox?

One issue I'm encountering with Font Awesome 5 is that, when I click on my checkbox, there is an unwanted white background or border that I can't seem to get rid of. /* Updating default snippet color for better visibility of the issue */ body ...

Tips for redesigning your Bootstrap slider

Looking to update the carousel design for the previous and next buttons with a new look. I've attempted the following code: .carousel-control-prev { content: 'prev'; font-size: 55px; color: red; } <a class="carousel-control-next" ...