On my website's index.html I've included the following code:
<link rel="preload" href="assets/fonts/Raleway-Black.ttf" as="font" type="font/ttf" crossorigin>
<link rel="preload" href="assets/fonts/Raleway-Bold.ttf" as="font" type="font/ttf" crossorigin>
<link rel="preload" href="assets/fonts/Raleway-ExtraBold.ttf" as="font" type="font/ttf" crossorigin>
<link rel="preload" href="assets/fonts/Raleway-Medium.ttf" as="font" type="font/ttf" crossorigin>
<link rel="preload" href="assets/fonts/Raleway-Regular.ttf" as="font" type="font/ttf" crossorigin>
<link rel="preload" href="assets/fonts/Raleway-SemiBold.ttf" as="font" type="font/ttf" crossorigin>
<link rel="preload" href="assets/fonts/raleway-v12-latin-regular.woff" as="font" type="font/woff" crossorigin>
<link rel="preload" href="assets/fonts/raleway-v12-latin-regular.woff2" as="font" type="font/woff2" crossorigin>
For my stylesheets, I have added:
@font-face {
font-family: 'Raleway';
font-style: normal;
font-weight: 400;
src: url('assets/fonts/raleway-v12-latin-regular.eot'); /* IE9 Compat Modes */
src: local('Raleway'), local('Raleway-Regular'),
url('assets/fonts/raleway-v12-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('assets/fonts/raleway-v12-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('assets/fonts/raleway-v12-latin-regular.woff') format('woff'), /* Modern Browsers */
url('assets/fonts/raleway-v12-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('assets/fonts/raleway-v12-latin-regular.svg#Raleway') format('svg'); /* Legacy iOS */
}
@font-face {
font-family: 'RalewayMedium';
font-style: normal;
font-weight: 500;
src: local('Raleway'), local('Raleway-Regular'),
url('assets/fonts/Raleway-Medium.ttf') format('truetype');
}
@font-face {
font-family: 'RalewayBold';
font-style: normal;
font-weight: 700;
src: local('Raleway'), local('Raleway-Regular'),
url('assets/fonts/Raleway-Bold.ttf') format('truetype');
}
@font-face {
font-family: 'RalewayExtraBold';
font-style: normal;
font-weight: 800;
src: local('Raleway'), local('Raleway-Regular'),
url('assets/fonts/Raleway-ExtraBold.ttf') format('truetype');
}
@font-face {
font-family: 'RalewayBlack';
font-style: normal;
font-weight: 900;
src: local('Raleway'), local('Raleway-Regular'),
url('assets/fonts/Raleway-Black.ttf') format('truetype');
}
When running Google's Lighthouse test,
I'm advised to preload these fonts.
Here are my questions:
1) How can I properly preload these fonts?
2) Is there a way to consolidate all these font files into one for efficiency? If so, how do I achieve this for fonts like Ralway, RalewayBold, RalewayMedium, etc.?
3) I seem to only find .ttf files, where can I locate the .woff2 formats for the same fonts?