How To Download Fonts From Google Fonts
How to become the font download urls, including SVG and woff2.
The user-agents required to download each font are as follows. source.
module.exports = { USER_AGENTS: { eot: 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT vi.1; Trident/4.0)', woff: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0', woff2: 'Mozilla/5.0 (Windows NT six.three; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/38.0.2125.104 Safari/537.36', // complete woff2 file for one variant svg: 'Mozilla/4.0 (iPad; CPU OS 4_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/4.1 Mobile/9A405 Safari/7534.48.three', ttf: 'Mozilla/5.0 (Windows NT half dozen.1) AppleWebKit/534.54.16 (KHTML, like Gecko) Version/5.i.4 Safari/534.54.16' }, GOOGLE_FONTS_API_KEY: 'AIzaSyDY-C-Lt9uyPP5fSTjMCR4bB944SlI4spw', CACHE_DIR: __dirname + "/cachedFonts/", } Add together these useragents using devtool.
source
you can now visit https://fonts.googleapis.com/css?family=Open up+Sans and spoof your user agent, download the fonts past visiting the url found in the @font-face.
Alternatively google-webfonts-helper does it all for you.
There'due south a great blog post here from the programmer where I acquired the paradigm.
Why do you desire to self host?
E'er use a common CDN if possible, its a lot more probable that your font won't even need downloading(browser cached).
If you are worried about google sending the wrong font to users, most likely considering they are spoofing their user-agent, So in that location in another option and all the same go the benefits of using google hosting.
Insert the @font-face yourself, just use the steps above to find the google font url and insert this into the <head>;
<way>
@font-face { font-family: 'Open up Sans'; font-style: normal; font-weight: 400; src: url(google-font-url-here/opensans.eot); src: local('Open Sans'), local('OpenSans'), url(google-font-url-hither/opensans.eot?#iefix) format('embedded-opentype'), url(google-font-url-here/opensans.woff2) format('woff2'), url(google-font-url-here/opensans.woff) format('woff'), url(google-font-url-here/opensans.ttf) format('truetype'), url(google-font-url-hither/opensans.svg#OpenSans) format('svg'); } </mode>
This comes with its risks every bit the URLS may change!
Source: https://stackoverflow.com/questions/10300143/how-to-download-multiple-formats-of-a-web-font-from-the-official-google-web-fo
Posted by: sharpthicy1994.blogspot.com

0 Response to "How To Download Fonts From Google Fonts"
Post a Comment