Why are my custom fonts not working on mobile devices? - html

Why won't my custom font work for mobile but it works fine on desktop?
This is the code I put at the top of my css file:
#font-face {
font-family: 'NewYork';
src: url('fonts/NewYork.eot');
src: url('fonts/NewYork.eot?#iefix') format('embedded-opentype'),
url('fonts/NewYork.woff2') format('woff2'),
url('fonts/NewYork.woff') format('woff'),
url('fonts/NewYork.ttf') format('truetype'),
url('fonts/NewYork.svg#NewYork') format('svg');
font-weight: normal;
font-style: normal;
font-display: swap;
}
#font-face {
font-family: 'Montserrat Alternates';
src: url('fonts/MontserratAlternates-Regular.eot');
src: url('fonts/MontserratAlternates-Regular.eot?#iefix') format('embedded-opentype'),
url('fonts/MontserratAlternates-Regular.woff2') format('woff2'),
url('fonts/MontserratAlternates-Regular.woff') format('woff'),
url('fonts/MontserratAlternates-Regular.ttf') format('truetype'),
url('fonts/MontserratAlternates-Regular.svg#MontserratAlternates-Regular') format('svg');
font-weight: normal;
font-style: normal;
font-display: swap;
}
#font-face {
font-family: 'Montserrat Alternates';
src: url('fonts/MontserratAlternates-Light.eot');
src: url('fonts/MontserratAlternates-Light.eot?#iefix') format('embedded-opentype'),
url('fonts/MontserratAlternates-Light.woff2') format('woff2'),
url('fonts/MontserratAlternates-Light.woff') format('woff'),
url('fonts/MontserratAlternates-Light.ttf') format('truetype'),
url('fonts/MontserratAlternates-Light.svg#MontserratAlternates-Light') format('svg');
font-weight: 300;
font-style: normal;
font-display: swap;
}
And this is how I style it:
*{
font-family: 'Montserrat Alternates', serif;
color: rgba(40, 40, 43, 1);
font-size: clamp(12px, 30vw, 18px);
font-weight: normal;
font-style: normal;
font-display: swap;
line-height: 1.7em;
padding: 0;
max-width: 100%;
margin: 0;
box-sizing: border-box;
}
h1 {
font-size: clamp(15px, 9vw, 170px);
color: rgba(0, 142, 83, 1);
font-family: 'NewYork', serif;
font-weight: normal;
font-style: normal;
font-display: swap;
letter-spacing: 0.04em;
line-height: 7rem;
text-align: center;
}
link to site and what it should look like: https://robynloudang.github.io/Portfolio/index.html
[screenshot of the font on mobile][1]
[1]: https://i.stack.imgur.com/dWxsj.jpgstrong text

Your fonts aren't loaded at all(also in desktop view), as the path to your font directory isn't correct.
https://robynloudang.github.io/Portfolio/fonts/MontserratAlternates-Regular.woff2
works!
https://robynloudang.github.io/Portfolio/styles/fonts/MontserratAlternates-Regular.woff2
nope!404
You will also see a debug message in dev tools.
Just move your "fonts" folder in your "styles" folder or edit your #font-face declaration:
#font-face {
font-family: 'Montserrat Alternates';
src: url('../fonts/MontserratAlternates-Regular.woff2') format('woff2'),
url('../fonts/MontserratAlternates-Regular.woff') format('woff'),
url('../fonts/MontserratAlternates-Regular.ttf') format('truetype'),
font-weight: normal;
font-style: normal;
font-display: swap;
}

Related

including font face for bold not working

I've added the 'circular' font family to my site shown in the first code snippet below, but it doesn't add any bold, so I tried to include the bold .ttf and .woff for the bold 'circular' font but neither of my two approaches worked, the first approach made all the text bold and the second approach didn't do anything at all!
Here is how I added 'circular' to my asp.net mvc site's site.css file and it makes all the text circular, but not the bold
#font-face {
font-family: 'Circular';
src: url('../fonts/circular-book.ttf') format('truetype');
src: url('../fonts/circular-book.woff') format('woff');
}
body {
font-family: Circular,"Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 16px !important;
-webkit-font-smoothing: antialiased !important;
color: #484848 !important;
}
Here I tried adding the bold but it makes everything bold
#font-face {
font-family: 'Circular';
src: url('../fonts/circular-book.ttf') format('truetype');
src: url('../fonts/circular-book.woff') format('woff');
src: url('../fonts/circular-bold.ttf') format('truetype');
src: url('../fonts/circular-bold.woff') format('woff');
}
body {
font-family: Circular,"Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 16px !important;
-webkit-font-smoothing: antialiased !important;
color: #484848 !important;
}
The last thing I tried was adding a new 'font-face' and including it in the body like this but it doesn't change any of my 'font-weight: bold' css to bold
#font-face {
font-family: 'Circular';
src: url('../fonts/circular-book.ttf') format('truetype');
src: url('../fonts/circular-book.woff') format('woff');
}
#font-face {
font-family: 'Circular-bold';
src: url('../fonts/circular-bold.ttf') format('truetype');
src: url('../fonts/circular-bold.woff') format('woff');
}
body {
font-family: Circular, Circular-bold,"Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 16px !important;
-webkit-font-smoothing: antialiased !important;
color: #484848 !important;
}
#font-face {
font-family: 'Circular';
src: url('../fonts/circular-book.ttf') format('truetype');
src: url('../fonts/circular-book.woff') format('woff');
}
#font-face {
font-family: 'Circular'; /*same name, yes*/
font-weight: bold; /*config its weight*/
src: url('../fonts/circular-bold.ttf') format('truetype');
src: url('../fonts/circular-bold.woff') format('woff');
}
body {
font-family: Circular; /*select font family normally*/
font-weight: bold; /*select family's bold font face*/
}
Or ask engine to generate (ugly) bold font face for us by font-synthesis:weight.
Here is an example showing how googlefonts configs font face.
#font-face {
font-family: 'Spectral SC';
font-style: normal;
font-weight: 400;
src: local('Spectral SC Regular'), local('SpectralSC-Regular'), url(https://fonts.gstatic.com/s/spectralsc/v2/yJ95fCBFs0v33GTJdYTk_zUj_cnvWIuuBMVgbX098Mw.woff2) format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
#font-face {
font-family: 'Spectral SC';
font-style: normal;
font-weight: 700;
src: local('Spectral SC Bold'), local('SpectralSC-Bold'), url(https://fonts.gstatic.com/s/spectralsc/v2/J7mO0YbtyrIkp56FY15FDS_vZmeiCMnoWNN9rHBYaTc.woff2) format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
below code'll work
#font-face {
font-family: 'Circular';
src: url('../fonts/circular-bold.ttf') format('truetype');
src: url('../fonts/circular-bold.woff') format('woff');
}
body {
font-family: Circular;
font-weight: bold;
}

Imported font doesn't work

I've been trying for hours to use the Titillium Web custom font but haven't succeeded. Here's what I tried:
Adding the following line in the head part of the overall template
`<link href="https://fonts.googleapis.com/css?family=Titillium+Web:300,400,400i,600,600i,700" rel="stylesheet">`
Adding the following in CSS
#font-face {
font-family: 'Titillium Web Bold';
src: url('data/fonts/TWeb/titilliumweb-bold-webfont.woff2') format('woff2'),
url('data/fonts/TWeb/titilliumweb-bold-webfont.woff') format('woff');
url("data/fonts/TWeb/titilliumweb-bold-webfont.ttf") format("truetype"),
url("data/fonts/TWeb/titilliumweb-bold-webfont.svg") format("svg");
font-weight: normal;
font-style: normal; }
#font-face {
font-family: 'Titillium Web BoldItalic';
src: url('data/fonts/TWeb/titilliumweb-bolditalic-webfont.woff2') format('woff2'),
url('data/fonts/TWeb/titilliumweb-bolditalic-webfont.woff') format('woff');
url("data/fonts/TWeb/titilliumweb-bolditalic-webfont.ttf") format("truetype"),
url("data/fonts/TWeb/titilliumweb-bolditalic-webfont.svg") format("svg");
font-weight: normal;
font-style: normal; }
#font-face {
font-family: 'Titillium Web Italic';
src: url('data/fonts/TWeb/titilliumweb-italic-webfont.woff2') format('woff2'),
url('data/fonts/TWeb/titilliumweb-italic-webfont.woff') format('woff');
url("data/fonts/TWeb/titilliumweb-italic-webfont.ttf") format("truetype"),
url("data/fonts/TWeb/titilliumweb-italic-webfont.svg") format("svg");
font-weight: normal;
font-style: normal; }
#font-face {
font-family: 'Titillium Web Light';
src: url('data/fonts/TWeb/titilliumweb-light-webfont.woff2') format('woff2'),
url('data/fonts/TWeb/titilliumweb-light-webfont.woff') format('woff');
url("data/fonts/TWeb/titilliumweb-light-webfont.ttf") format("truetype"),
url("data/fonts/TWeb/titilliumweb-light-webfont.svg") format("svg");
font-weight: normal;
font-style: normal; }
#font-face {
font-family: 'Titillium Web';
src: url('data/fonts/TWeb/titilliumweb-regular-webfont.woff2') format('woff2'),
url('data/fonts/TWeb/titilliumweb-regular-webfont.woff') format('woff');
url("data/fonts/TWeb/titilliumweb-regular-webfont.ttf") format("truetype"),
url("data/fonts/TWeb/titilliumweb-regular-webfont.svg") format("svg");
font-weight: normal;
font-style: normal; }
#font-face {
font-family: 'Titillium Web Semibold';
src: url('data/fonts/TWeb/titilliumweb-semibold-webfont.woff2') format('woff2'),
url('data/fonts/TWeb/titilliumweb-semibold-webfont.woff') format('woff');
url("data/fonts/TWeb/titilliumweb-semibold-webfont.ttf") format("truetype"),
url("data/fonts/TWeb/titilliumweb-semibold-webfont.svg") format("svg");
font-weight: normal;
font-style: normal; }
Using the font on an html element
a.random {font-family: 'Titillium Web';} or a.random {font-family: 'Titillium Web', sans-serif;}
None worked.
Any idea ?
Thanks
#import url('https://fonts.googleapis.com/css family=Titillium+Web:300,400,400i,600,600i,700');
#f{
font-family: 'Titillium Web', sans-serif;
}
#s{
font-family: 'Titillium Web', sans-serif;
font-weight: 700;
}
#t{
font-family: 'Titillium Web', sans-serif;
font-style:italic;
font-weight: 700;
}
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p id="f">Sample</p>
<p id="s">Another Sample</p>
<p id="t">Last Sample</p>
</body>
</html>

Can't figure out why the font for my logo isn't working

I'm trying to figure out why the font for my logo isn't downloading for other people. The font is called Aerokids.
The code in my CSS works fine for the other font type I have on my site. It's just the logo that's not working, even though it's done the same way. Does anyone have any ideas what might be wrong? Here is a screenshot of the fonts I have in the subfolder for my site:
Here is the GitHub URL for the site I'm working on.
#font-face {
font-family: 'Aerokids';
src: url('fonts/Aerokids.otf');
font-weight: normal;
font-style: normal;
font-family: 'odudo-semibold';
src: url('../fonts/odudo-semi-bold.eot');
src: url('../fonts/odudo-semi-bold.eot?#iefix') format('embedded-
opentype'),
url('../fonts/odudo-semi-bold.woff2') format('woff2'),
url('../fonts/odudo-semi-bold.woff') format('woff'),
url('../fonts/odudo-semi-bold.ttf') format('truetype'),
url('../fonts/odudo-semi-bold.svg#youworkforthem') format('svg');
font-weight: normal;
font-style: normal;
}
.logo {
font-family: 'Aerokids';
font-weight: normal;
color: #00E8FF;
font-size: 2.5em;
float: left;
width: 30%;
display: inline-block;
max-width: 100%;
height: auto;
vertical-align: middle;
margin: 0 auto;
}
You need to separate the two #font-face rules.
#font-face {
font-family: 'Aerokids';
src: url('fonts/Aerokids.otf');
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: 'odudo-semibold';
src: url('../fonts/odudo-semi-bold.eot');
src: url('../fonts/odudo-semi-bold.eot?#iefix') format('embedded-
opentype'),
url('../fonts/odudo-semi-bold.woff2') format('woff2'),
url('../fonts/odudo-semi-bold.woff') format('woff'),
url('../fonts/odudo-semi-bold.ttf') format('truetype'),
url('../fonts/odudo-semi-bold.svg#youworkforthem') format('svg');
font-weight: normal;
font-style: normal;
}

Failed to decode downloaded font and OTS parsing error: invalid version tag

I'm receiving the errors:
Failed to decode downloaded font and OTS parsing error: invalid
version tag
My code is inside my CSS file:
#import url("../fonts/roboto/roboto.css");
Then, inside the roboto.css file, I have the following code.
/* Roboto Fontkit (LOCAL)
-----------------------------------------*/
/*(1) Roboto-Regular-webfont
.......................................*/
#font-face {
font-family: "Roboto";
src: url("Roboto-Regular-webfont.eot");
src: url("Roboto-Regular-webfont.eot?#iefix"), url("Roboto-Regular-webfont.woff") format("woff"), url("Roboto-Regular-webfont.ttf") format("truetype"), url("Roboto-Regular-webfont.svg#Roboto") format("svg");
font-weight: normal;
font-style: normal;
}
/*(2) Roboto-Italic-webfont
.......................................*/
#font-face {
font-family: "Roboto";
src: url("Roboto-Italic-webfont.eot");
src: url("Roboto-Italic-webfont.eot?#iefix"), url("Roboto-Italic-webfont.woff") format("woff"), url("Roboto-Italic-webfont.ttf") format("truetype"), url("Roboto-Italic-webfont.svg#Roboto") format("svg");
font-weight: normal;
font-style: italic;
}
/*(3) Roboto-Medium-webfont
.......................................*/
#font-face {
font-family: "Roboto";
src: url("Roboto-Medium-webfont.eot");
src: url("Roboto-Medium-webfont.eot?#iefix"), url("Roboto-Medium-webfont.woff") format("woff"), url("Roboto-Medium-webfont.ttf") format("truetype"), url("Roboto-Medium-webfont.svg#Roboto") format("svg");
font-weight: 500;
font-style: normal;
}
/*(4) Roboto-MediumItalic-webfont
.......................................*/
#font-face {
font-family: "Roboto";
src: url("Roboto-MediumItalic-webfont.eot");
src: url("Roboto-MediumItalic-webfont.eot?#iefix"), url("Roboto-MediumItalic-webfont.woff") format("woff"), url("Roboto-MediumItalic-webfont.ttf") format("truetype"), url("Roboto-MediumItalic-webfont.svg#Roboto") format("svg");
font-weight: 500;
font-style: italic;
}
/*(5) Roboto-Bold-webfont
.......................................*/
#font-face {
font-family: "Roboto";
src: url("Roboto-Bold-webfont.eot");
src: url("Roboto-Bold-webfont.eot?#iefix"), url("Roboto-Bold-webfont.woff") format("woff"), url("Roboto-Bold-webfont.ttf") format("truetype"), url("Roboto-Bold-webfont.svg#Roboto") format("svg");
font-weight: bold;
font-style: normal;
}
/*(6) Roboto-BoldItalic-webfont
.......................................*/
#font-face {
font-family: "Roboto";
src: url("Roboto-BoldItalic-webfont.eot");
src: url("Roboto-BoldItalic-webfont.eot?#iefix"), url("Roboto-BoldItalic-webfont.woff") format("woff"), url("Roboto-BoldItalic-webfont.ttf") format("truetype"), url("Roboto-BoldItalic-webfont.svg#Roboto") format("svg");
font-weight: bold;
font-style: italic;
}
/*(7) Roboto-Light-webfont
.......................................*/
#font-face {
font-family: "Roboto";
src: url("Roboto-Light-webfont.eot");
src: url("Roboto-Light-webfont.eot?#iefix"), url("Roboto-Light-webfont.woff") format("woff"), url("Roboto-Light-webfont.ttf") format("truetype"), url("Roboto-Light-webfont.svg#Roboto") format("svg");
font-weight: 300;
font-style: normal;
}
/*(8) Roboto-LightItalic-webfont
.......................................*/
#font-face {
font-family: "Roboto";
src: url("Roboto-LightItalic-webfont.eot");
src: url("Roboto-LightItalic-webfont.eot?#iefix"), url("Roboto-LightItalic-webfont.woff") format("woff"), url("Roboto-LightItalic-webfont.ttf") format("truetype"), url("Roboto-LightItalic-webfont.svg#Roboto") format("svg");
font-weight: 300;
font-style: italic;
}
/*(9) Roboto-Black-webfont
.......................................*/
#font-face {
font-family: "Roboto";
src: url("Roboto-Black-webfont.eot");
src: url("Roboto-Black-webfont.eot?#iefix"), url("Roboto-Black-webfont.woff") format("woff"), url("Roboto-Black-webfont.ttf") format("truetype"), url("Roboto-Black-webfont.svg#Roboto") format("svg");
font-weight: 900;
font-style: normal;
}
/*(10) Roboto-BlackItalic-webfont
.......................................*/
#font-face {
font-family: "Roboto";
src: url("Roboto-BlackItalic-webfont.eot");
src: url("Roboto-BlackItalic-webfont.eot?#iefix"), url("Roboto-BlackItalic-webfont.woff") format("woff"), url("Roboto-BlackItalic-webfont.ttf") format("truetype"), url("Roboto-BlackItalic-webfont.svg#Roboto") format("svg");
font-weight: 900;
font-style: italic;
}
I'm not sure what's causing the error I'm experiencing. This seems like it should be working perfectly fine.
I have not done modified the CSS file at all.
When you uploaded the font to your server, did you make sure you were in Binary Mode instead of ASCII (text)? That was my issue and uploading the files again in the correct mode resolved my issue.

Font Face Issues - Text compacting

I'm having a few problems with font-face that seems to occur every time I use it to include fonts. The only way to fix it is (I'm using Chrome btw) to go to the page in IE and let it redownload the font locally. The domain is: http://chahlesmc.us/
The first image shows the content how it should be, the other images show my issue with the bug. Thanks in advance!
#font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-weight: 100;
src: url('./fonts/sourcesanspro-extralight-webfont.eot');
src: url('./fonts/sourcesanspro-extralight-webfont.eot?#iefix') format('embedded-opentype'),
url('./fonts/sourcesanspro-extralight-webfont.svg') format('svg'),
url('./fonts/sourcesanspro-extralight-webfont.woff') format('woff'),
url('./fonts/sourcesanspro-extralight-webfont.ttf') format('truetype');
}
#font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-weight: 200;
src: url('./fonts/sourcesanspro-light-webfont.eot');
src: url('./fonts/sourcesanspro-light-webfont.eot?#iefix') format('embedded-opentype'),
url('./fonts/sourcesanspro-light-webfont.svg') format('svg'),
url('./fonts/sourcesanspro-light-webfont.woff') format('woff'),
url('./fonts/sourcesanspro-light-webfont.ttf') format('truetype');
}
#font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-weight: 300;
src: url('./fonts/sourcesanspro-regular-webfont.eot');
src: url('./fonts/sourcesanspro-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('./fonts/sourcesanspro-regular-webfont.svg') format('svg'),
url('./fonts/sourcesanspro-regular-webfont.woff') format('woff'),
url('./fonts/sourcesanspro-regular-webfont.ttf') format('truetype');
}
#font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-weight: 400;
src: url('./fonts/sourcesanspro-semibold-webfont.eot');
src: url('./fonts/sourcesanspro-semibold-webfont.eot?#iefix') format('embedded-opentype'),
url('./fonts/sourcesanspro-semibold-webfont.svg') format('svg'),
url('./fonts/sourcesanspro-semibold-webfont.woff') format('woff'),
url('./fonts/sourcesanspro-semibold-webfont.ttf') format('truetype');
}
#font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-weight: 500;
src: url('./fonts/sourcesanspro-bold-webfont.eot');
src: url('./fonts/sourcesanspro-bold-webfont.eot?#iefix') format('embedded-opentype'),
url('./fonts/sourcesanspro-bold-webfont.svg') format('svg'),
url('./fonts/sourcesanspro-bold-webfont.woff') format('woff'),
url('./fonts/sourcesanspro-bold-webfont.ttf') format('truetype');
}
#font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-weight: 600;
src: url('./fonts/sourcesanspro-black-webfont.eot');
src: url('./fonts/sourcesanspro-black-webfont.eot?#iefix') format('embedded-opentype'),
url('./fonts/sourcesanspro-black-webfont.svg') format('svg'),
url('./fonts/sourcesanspro-black-webfont.woff') format('woff'),
url('./fonts/sourcesanspro-black-webfont.ttf') format('truetype');
}