user9812546
user9812546

Reputation:

How to replace the use of google fonts to local hosted fonts?

I have purchased on theme which is using two fonts "roboto" & "open sens" & used in following manner under site.css

@import url("https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700");
@import url("https://fonts.googleapis.com/css?family=Roboto:400,300,500,700");

Now the issue is the application is hosted under the environment which do not have internet access so the application looks ugly.

I download both of these fonts & tried to refer locally but still seems i have not refereed correctly as i can see the style is not yet exact it has to be.

can someone guide me how I can mimic this code so that fonts came from hosted application path not the google url with no change in design.

Ref: I tried following but no luck.( font path are correct, I double checked )

@font-face {
    font-family: 'Open Sans';
    src: url('../fonts/Open_Sans/OpenSans-ExtraBoldItalic.woff2') format('woff2'), url('../fonts/Open_Sans/OpenSans-ExtraBoldItalic.woff') format('woff');
    font-weight: 800;
    font-style: italic;
}

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/Roboto/Roboto-Italic.woff2') format('woff2'), url('../fonts/Roboto/Roboto-Italic.woff') format('woff');
    font-weight: normal;
    font-style: italic;
}

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/Roboto/Roboto-Light.woff2') format('woff2'), url('../fonts/Roboto/Roboto-Light.woff') format('woff');
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/Roboto/Roboto-Regular.woff2') format('woff2'), url('../fonts/Roboto/Roboto-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Open Sans';
    src: url('../fonts/Open_Sans/OpenSans-Italic.woff2') format('woff2'), url('../fonts/Open_Sans/OpenSans-Italic.woff') format('woff');
    font-weight: normal;
    font-style: italic;
}

@font-face {
    font-family: 'Open Sans';
    src: url('../fonts/Open_Sans/OpenSans-LightItalic.woff2') format('woff2'), url('../fonts/Open_Sans/OpenSans-LightItalic.woff') format('woff');
    font-weight: 300;
    font-style: italic;
}

@font-face {
    font-family: 'Open Sans';
    src: url('../fonts/Open_Sans/OpenSans-SemiBold.woff2') format('woff2'), url('../fonts/Open_Sans/OpenSans-SemiBold.woff') format('woff');
    font-weight: 600;
    font-style: normal;
}

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/Roboto/Roboto-ThinItalic.woff2') format('woff2'), url('../fonts/Roboto/Roboto-ThinItalic.woff') format('woff');
    font-weight: 100;
    font-style: italic;
}

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/Roboto/Roboto-Thin.woff2') format('woff2'), url('../fonts/Roboto/Roboto-Thin.woff') format('woff');
    font-weight: 100;
    font-style: normal;
}

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/Roboto/Roboto-Medium.woff2') format('woff2'), url('../fonts/Roboto/Roboto-Medium.woff') format('woff');
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'Open Sans';
    src: url('../fonts/Open_Sans/OpenSans-Light.woff2') format('woff2'), url('../fonts/Open_Sans/OpenSans-Light.woff') format('woff');
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: 'Open Sans';
    src: url('../fonts/Open_Sans/OpenSans-SemiBoldItalic.woff2') format('woff2'), url('../fonts/Open_Sans/OpenSans-SemiBoldItalic.woff') format('woff');
    font-weight: 600;
    font-style: italic;
}

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/Roboto/Roboto-BlackItalic.woff2') format('woff2'), url('../fonts/Roboto/Roboto-BlackItalic.woff') format('woff');
    font-weight: 900;
    font-style: italic;
}

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/Roboto/Roboto-Black.woff2') format('woff2'), url('../fonts/Roboto/Roboto-Black.woff') format('woff');
    font-weight: 900;
    font-style: normal;
}

@font-face {
    font-family: 'Open Sans';
    src: url('../fonts/Open_Sans/OpenSans-BoldItalic.woff2') format('woff2'), url('../fonts/Open_Sans/OpenSans-BoldItalic.woff') format('woff');
    font-weight: bold;
    font-style: italic;
}

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/Roboto/Roboto-Bold.woff2') format('woff2'), url('../fonts/Roboto/Roboto-Bold.woff') format('woff');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'Open Sans';
    src: url('../fonts/Open_Sans/OpenSans-ExtraBold.woff2') format('woff2'), url('../fonts/Open_Sans/OpenSans-ExtraBold.woff') format('woff');
    font-weight: 800;
    font-style: normal;
}

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/Roboto/Roboto-MediumItalic.woff2') format('woff2'), url('../fonts/Roboto/Roboto-MediumItalic.woff') format('woff');
    font-weight: 500;
    font-style: italic;
}

@font-face {
    font-family: 'Open Sans';
    src: url('../fonts/Open_Sans/OpenSans-Bold.woff2') format('woff2'), url('../fonts/Open_Sans/OpenSans-Bold.woff') format('woff');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/Roboto/Roboto-LightItalic.woff2') format('woff2'), url('../fonts/Roboto/Roboto-LightItalic.woff') format('woff');
    font-weight: 300;
    font-style: italic;
}

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/Roboto/Roboto-BoldItalic.woff2') format('woff2'), url('../fonts/Roboto/Roboto-BoldItalic.woff') format('woff');
    font-weight: bold;
    font-style: italic;
}

@font-face {
    font-family: 'Open Sans';
    src: url('../fonts/Open_Sans/OpenSans-Regular.woff2') format('woff2'), url('../fonts/Open_Sans/OpenSans-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

Upvotes: 1

Views: 3633

Answers (1)

Roy Bogado
Roy Bogado

Reputation: 4472

Download the Google Font and place it in your proyect. (ttf files)

And then use:

@font-face {
  font-family: 'Your-font-Name-for-usage';
  src: url('your-path-font.ttf')  format('truetype')
}

Check this post to include fonts

Upvotes: 1

Related Questions